Skip to content

Commit

Permalink
Add template changes
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljurek committed Mar 1, 2024
1 parent 6e633ed commit 2d887a4
Show file tree
Hide file tree
Showing 40 changed files with 159 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ param serviceBinds array = []
@description('The target port for the container')
param targetPort int = 80

resource existingApp 'Microsoft.App/containerApps@2023-05-02-preview' existing = if (exists) {
resource existingApp 'Microsoft.App/containerApps@2023-04-01-preview' existing = if (exists) {
name: name
}

Expand Down
4 changes: 2 additions & 2 deletions templates/common/infra/bicep/core/host/container-app.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ module containerRegistryAccess '../security/registry-access.bicep' = if (usePriv
}
}

resource app 'Microsoft.App/containerApps@2023-05-02-preview' = {
resource app 'Microsoft.App/containerApps@2023-04-01-preview' = {
name: name
location: location
tags: tags
Expand Down Expand Up @@ -150,7 +150,7 @@ resource app 'Microsoft.App/containerApps@2023-05-02-preview' = {
}
}

resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2023-05-01' existing = {
resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2023-04-01-preview' existing = {
name: containerAppsEnvironmentName
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ param daprEnabled bool = false
@description('Name of the Log Analytics workspace')
param logAnalyticsWorkspaceName string

resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2023-05-01' = {
resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2023-04-01-preview' = {
name: name
location: location
tags: tags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ param zoneRedundancy string = 'Disabled'
@description('The log analytics workspace ID used for logging and monitoring')
param workspaceId string = ''

// 2023-01-01-preview needed for anonymousPullEnabled
resource containerRegistry 'Microsoft.ContainerRegistry/registries@2023-01-01-preview' = {
// 2022-02-01-preview needed for anonymousPullEnabled
resource containerRegistry 'Microsoft.ContainerRegistry/registries@2022-02-01-preview' = {
name: name
location: location
tags: tags
Expand Down
10 changes: 3 additions & 7 deletions templates/common/infra/bicep/core/search/search-services.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,14 @@ param replicaCount int = 1
])
param semanticSearch string = 'disabled'

var searchIdentityProvider = (sku.name == 'free') ? null : {
type: 'SystemAssigned'
}

resource search 'Microsoft.Search/searchServices@2021-04-01-preview' = {
name: name
location: location
tags: tags
// The free tier does not support managed identity
identity: searchIdentityProvider
identity: (sku.name == 'free') ? null : {
type: 'SystemAssigned'
}
properties: {
authOptions: authOptions
disableLocalAuth: disableLocalAuth
Expand All @@ -64,5 +62,3 @@ resource search 'Microsoft.Search/searchServices@2021-04-01-preview' = {
output id string = search.id
output endpoint string = 'https://${name}.search.windows.net/'
output name string = search.name
output principalId string = !empty(searchIdentityProvider) ? search.identity.principalId : ''

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ resource aksAcrPull 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
}
}

resource containerRegistry 'Microsoft.ContainerRegistry/registries@2023-01-01-preview' existing = {
resource containerRegistry 'Microsoft.ContainerRegistry/registries@2022-02-01-preview' existing = {
name: containerRegistryName
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ resource "azurerm_cosmosdb_mongo_collection" "list" {

index {
keys = ["_id"]
unique = true
}
}

Expand All @@ -80,5 +81,6 @@ resource "azurerm_cosmosdb_mongo_collection" "item" {

index {
keys = ["_id"]
unique = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ output "URI" {
output "IDENTITY_PRINCIPAL_ID" {
value = length(azurerm_linux_web_app.web.identity) == 0 ? "" : azurerm_linux_web_app.web.identity.0.principal_id
sensitive = true
}
}

output "APPSERVICE_NAME" {
value = azurerm_linux_web_app.web.name
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ output "URI" {
output "IDENTITY_PRINCIPAL_ID" {
value = length(azurerm_linux_web_app.web.identity) == 0 ? "" : azurerm_linux_web_app.web.identity.0.principal_id
sensitive = true
}
}
output "APPSERVICE_NAME" {
value = azurerm_linux_web_app.web.name
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ param apimServiceName string = ''
@description('Flag to use Azure API Management to mediate the calls between the Web frontend and the backend API')
param useAPIM bool = false

@description('API Management SKU to use if APIM is enabled')
param apimSku string = 'Consumption'

@description('Id of the user or app to assign application roles')
param principalId string = ''

Expand Down Expand Up @@ -178,6 +181,7 @@ module apim '../../../../../../common/infra/bicep/core/gateway/apim.bicep' = if
scope: rg
params: {
name: !empty(apimServiceName) ? apimServiceName : '${abbrs.apiManagementService}${resourceToken}'
sku: apimSku
location: location
tags: tags
applicationInsightsName: monitoring.outputs.applicationInsightsName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
},
"useAPIM": {
"value": "${USE_APIM=false}"
},
"apimSku": {
"value": "${APIM_SKU=Consumption}"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ param apimServiceName string = ''
@description('Flag to use Azure API Management to mediate the calls between the Web frontend and the backend API')
param useAPIM bool = false

@description('API Management SKU to use if APIM is enabled')
param apimSku string = 'Consumption'

@description('Id of the user or app to assign application roles')
param principalId string = ''

Expand Down Expand Up @@ -163,6 +166,7 @@ module apim '../../../../../../common/infra/bicep/core/gateway/apim.bicep' = if
scope: rg
params: {
name: !empty(apimServiceName) ? apimServiceName : '${abbrs.apiManagementService}${resourceToken}'
sku: apimSku
location: location
tags: tags
applicationInsightsName: monitoring.outputs.applicationInsightsName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
},
"useAPIM": {
"value": "${USE_APIM=false}"
},
"apimSku": {
"value": "${APIM_SKU=Consumption}"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ param apimServiceName string = ''
@description('Flag to use Azure API Management to mediate the calls between the Web frontend and the backend API')
param useAPIM bool = false

@description('API Management SKU to use if APIM is enabled')
param apimSku string = 'Consumption'

@description('Id of the user or app to assign application roles')
param principalId string = ''

Expand Down Expand Up @@ -163,6 +166,7 @@ module apim '../../../../../../common/infra/bicep/core/gateway/apim.bicep' = if
scope: rg
params: {
name: !empty(apimServiceName) ? apimServiceName : '${abbrs.apiManagementService}${resourceToken}'
sku: apimSku
location: location
tags: tags
applicationInsightsName: monitoring.outputs.applicationInsightsName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
},
"useAPIM": {
"value": "${USE_APIM=false}"
},
"apimSku": {
"value": "${APIM_SKU=Consumption}"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ param webAppExists bool = false
@description('Flag to use Azure API Management to mediate the calls between the Web frontend and the backend API')
param useAPIM bool = false

@description('API Management SKU to use if APIM is enabled')
param apimSku string = 'Consumption'

@description('Id of the user or app to assign application roles')
param principalId string = ''

Expand Down Expand Up @@ -151,6 +154,7 @@ module apim '../../../../../../common/infra/bicep/core/gateway/apim.bicep' = if
scope: rg
params: {
name: !empty(apimServiceName) ? apimServiceName : '${abbrs.apiManagementService}${resourceToken}'
sku: apimSku
location: location
tags: tags
applicationInsightsName: monitoring.outputs.applicationInsightsName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
},
"useAPIM": {
"value": "${USE_APIM=false}"
},
"apimSku": {
"value": "${APIM_SKU=Consumption}"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ param apimServiceName string = ''
@description('Flag to use Azure API Management to mediate the calls between the Web frontend and the backend API')
param useAPIM bool = false

@description('API Management SKU to use if APIM is enabled')
param apimSku string = 'Consumption'

@description('Id of the user or app to assign application roles')
param principalId string = ''

Expand Down Expand Up @@ -156,6 +159,7 @@ module apim '../../../../../../common/infra/bicep/core/gateway/apim.bicep' = if
scope: rg
params: {
name: !empty(apimServiceName) ? apimServiceName : '${abbrs.apiManagementService}${resourceToken}'
sku: apimSku
location: location
tags: tags
applicationInsightsName: monitoring.outputs.applicationInsightsName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
},
"useAPIM": {
"value": "${USE_APIM=false}"
},
"apimSku": {
"value": "${APIM_SKU=Consumption}"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ module "web" {
app_settings = {
"SCM_DO_BUILD_DURING_DEPLOYMENT" = "false"
"REACT_APP_APPLICATIONINSIGHTS_CONNECTION_STRING" = module.applicationinsights.APPLICATIONINSIGHTS_CONNECTION_STRING
"REACT_APP_API_BASE_URL" = "https://app-api-${local.resource_token}.azurewebsites.net"
"REACT_APP_API_BASE_URL" = module.api.URI
}

app_command_line = "./entrypoint.sh -o ./env-config.js && pm2 serve /home/site/wwwroot --no-daemon --spa"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ param webAppExists bool = false
@description('Flag to use Azure API Management to mediate the calls between the Web frontend and the backend API')
param useAPIM bool = false

@description('API Management SKU to use if APIM is enabled')
param apimSku string = 'Consumption'

@description('Id of the user or app to assign application roles')
param principalId string = ''

Expand Down Expand Up @@ -151,6 +154,7 @@ module apim '../../../../../../common/infra/bicep/core/gateway/apim.bicep' = if
scope: rg
params: {
name: !empty(apimServiceName) ? apimServiceName : '${abbrs.apiManagementService}${resourceToken}'
sku: apimSku
location: location
tags: tags
applicationInsightsName: monitoring.outputs.applicationInsightsName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
},
"useAPIM": {
"value": "${USE_APIM=false}"
},
"apimSku": {
"value": "${APIM_SKU=Consumption}"
}
}
}
16 changes: 12 additions & 4 deletions templates/todo/projects/nodejs-mongo-aks/.repo/bicep/azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ services:
host: aks
hooks:
postdeploy:
shell: sh
run: azd env set REACT_APP_WEB_BASE_URL ${SERVICE_WEB_ENDPOINT_URL}
windows:
shell: pwsh
run: azd env set REACT_APP_WEB_BASE_URL $env:SERVICE_WEB_ENDPOINT_URL
posix:
shell: sh
run: azd env set REACT_APP_WEB_BASE_URL ${SERVICE_WEB_ENDPOINT_URL}
api:
project: ../../api/js
language: js
Expand All @@ -22,5 +26,9 @@ services:
relativePath: api
hooks:
postdeploy:
shell: sh
run: azd env set REACT_APP_API_BASE_URL ${SERVICE_API_ENDPOINT_URL}
windows:
shell: pwsh
run: azd env set REACT_APP_API_BASE_URL $env:SERVICE_API_ENDPOINT_URL
posix:
shell: sh
run: azd env set REACT_APP_API_BASE_URL ${SERVICE_API_ENDPOINT_URL}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ param apimServiceName string = ''
@description('Flag to use Azure API Management to mediate the calls between the Web frontend and the backend API')
param useAPIM bool = false

@description('API Management SKU to use if APIM is enabled')
param apimSku string = 'Consumption'

@description('Id of the user or app to assign application roles')
param principalId string = ''

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
},
"useAPIM": {
"value": "${USE_APIM=false}"
},
"apimSku": {
"value": "${APIM_SKU=Consumption}"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ param apimServiceName string = ''
@description('Flag to use Azure API Management to mediate the calls between the Web frontend and the backend API')
param useAPIM bool = false

@description('API Management SKU to use if APIM is enabled')
param apimSku string = 'Consumption'

@description('Id of the user or app to assign application roles')
param principalId string = ''

Expand Down Expand Up @@ -156,6 +159,7 @@ module apim '../../../../../../common/infra/bicep/core/gateway/apim.bicep' = if
scope: rg
params: {
name: !empty(apimServiceName) ? apimServiceName : '${abbrs.apiManagementService}${resourceToken}'
sku: apimSku
location: location
tags: tags
applicationInsightsName: monitoring.outputs.applicationInsightsName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
},
"useAPIM": {
"value": "${USE_APIM=false}"
},
"apimSku": {
"value": "${APIM_SKU=Consumption}"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ To use APIM on this template you just need to set the environment variable with
```bash
azd env set USE_APIM true
```

The default SKU is `Consumption` but you can change it by setting the `APIM_SKU` environment variable:

```bash
azd env set APIM_SKU Standard
```

And then execute `azd up` to provision and deploy. No worries if you already did `azd up`! You can set the `USE_APIM` environment variable at anytime and then just repeat the `azd up` command to run the incremental deployment.

Here's the high level architecture diagram when APIM is used:
Expand Down
Loading

0 comments on commit 2d887a4

Please sign in to comment.