From cdbb5cfe169fc96ba3294b044ba120a9b140abcd Mon Sep 17 00:00:00 2001 From: luxu-ms Date: Fri, 1 Mar 2024 02:45:08 +0000 Subject: [PATCH] Rebuild ARM templates --- Environments/Todo-Mongo-ACA/azuredeploy.json | 4387 +++++------------ Environments/Todo-Shared-ACA/azuredeploy.json | 2880 +---------- 2 files changed, 1419 insertions(+), 5848 deletions(-) diff --git a/Environments/Todo-Mongo-ACA/azuredeploy.json b/Environments/Todo-Mongo-ACA/azuredeploy.json index 65c1d9f7..d4d8456a 100644 --- a/Environments/Todo-Mongo-ACA/azuredeploy.json +++ b/Environments/Todo-Mongo-ACA/azuredeploy.json @@ -5,7 +5,7 @@ "_generator": { "name": "bicep", "version": "0.25.53.49325", - "templateHash": "5915759848307494038" + "templateHash": "7624760505230248688" } }, "parameters": { @@ -29,17 +29,20 @@ "type": "string", "defaultValue": "" }, - "applicationInsightsDashboardName": { + "containerAppsEnvironmentName": { + "type": "string" + }, + "containerAppsEnvironmentResourceGroupName": { "type": "string", - "defaultValue": "" + "defaultValue": "[resourceGroup().name]" }, "applicationInsightsName": { "type": "string", "defaultValue": "" }, - "containerAppsEnvironmentName": { + "applicationInsightsResourceGroupName": { "type": "string", - "defaultValue": "" + "defaultValue": "[parameters('containerAppsEnvironmentResourceGroupName')]" }, "containerRegistryName": { "type": "string", @@ -57,10 +60,6 @@ "type": "string", "defaultValue": "" }, - "logAnalyticsName": { - "type": "string", - "defaultValue": "" - }, "webContainerAppName": { "type": "string", "defaultValue": "" @@ -97,6 +96,13 @@ "metadata": { "description": "The base URL used by the web service for sending API requests" } + }, + "corsAcaUrl": { + "type": "string" + }, + "containerRegistryAdminUserEnabled": { + "type": "bool", + "defaultValue": false } }, "variables": { @@ -240,39 +246,47 @@ "resourceToken": "[toLower(uniqueString(subscription().id, parameters('environmentName'), parameters('location')))]", "tags": { "azd-env-name": "[parameters('environmentName')]" - }, - "apiContainerAppNameOrDefault": "[format('{0}web-{1}', variables('abbrs').appContainerApps, variables('resourceToken'))]" + } }, "resources": [ { "type": "Microsoft.Resources/deployments", "apiVersion": "2022-09-01", - "name": "container-apps", + "name": "web", "properties": { "expressionEvaluationOptions": { "scope": "inner" }, "mode": "Incremental", "parameters": { - "name": { - "value": "app" - }, + "name": "[if(not(empty(parameters('webContainerAppName'))), createObject('value', parameters('webContainerAppName')), createObject('value', format('{0}web-{1}', variables('abbrs').appContainerApps, variables('resourceToken'))))]", "location": { "value": "[parameters('location')]" }, "tags": { "value": "[variables('tags')]" }, - "containerAppsEnvironmentName": "[if(not(empty(parameters('containerAppsEnvironmentName'))), createObject('value', parameters('containerAppsEnvironmentName')), createObject('value', format('{0}{1}', variables('abbrs').appManagedEnvironments, variables('resourceToken'))))]", - "containerRegistryName": "[if(not(empty(parameters('containerRegistryName'))), createObject('value', parameters('containerRegistryName')), createObject('value', format('{0}{1}', variables('abbrs').containerRegistryRegistries, variables('resourceToken'))))]", - "containerRegistryAdminUserEnabled": { - "value": true - }, - "logAnalyticsWorkspaceName": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'monitoring'), '2022-09-01').outputs.logAnalyticsWorkspaceName.value]" + "identityName": { + "value": "[format('{0}web-{1}', variables('abbrs').managedIdentityUserAssignedIdentities, variables('resourceToken'))]" }, + "apiBaseUrl": "[if(not(empty(parameters('webApiBaseUrl'))), createObject('value', parameters('webApiBaseUrl')), createObject('value', reference(resourceId('Microsoft.Resources/deployments', 'api'), '2022-09-01').outputs.SERVICE_API_URI.value))]", "applicationInsightsName": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'monitoring'), '2022-09-01').outputs.applicationInsightsName.value]" + "value": "[parameters('applicationInsightsName')]" + }, + "applicationInsightsResourceGroupName": { + "value": "[parameters('applicationInsightsResourceGroupName')]" + }, + "containerAppsEnvironmentName": { + "value": "[parameters('containerAppsEnvironmentName')]" + }, + "containerAppsEnvironmentResourceGroupName": { + "value": "[parameters('containerAppsEnvironmentResourceGroupName')]" + }, + "containerRegistryName": { + "value": "[reference(resourceId('Microsoft.Resources/deployments', 'app-container-registry'), '2022-09-01').outputs.name.value]" + }, + "exists": { + "value": "[parameters('webAppExists')]" } }, "template": { @@ -282,9 +296,8 @@ "_generator": { "name": "bicep", "version": "0.25.53.49325", - "templateHash": "14116108111976192358" - }, - "description": "Creates an Azure Container Registry and an Azure Container Apps environment." + "templateHash": "12761856845851580026" + } }, "parameters": { "name": { @@ -298,33 +311,46 @@ "type": "object", "defaultValue": {} }, + "identityName": { + "type": "string" + }, + "apiBaseUrl": { + "type": "string" + }, + "applicationInsightsName": { + "type": "string" + }, + "applicationInsightsResourceGroupName": { + "type": "string" + }, "containerAppsEnvironmentName": { "type": "string" }, "containerRegistryName": { "type": "string" }, - "containerRegistryResourceGroupName": { + "serviceName": { "type": "string", - "defaultValue": "" + "defaultValue": "web" }, - "containerRegistryAdminUserEnabled": { - "type": "bool", - "defaultValue": false + "exists": { + "type": "bool" }, - "logAnalyticsWorkspaceName": { + "containerAppsEnvironmentResourceGroupName": { "type": "string" - }, - "applicationInsightsName": { - "type": "string", - "defaultValue": "" } }, "resources": [ + { + "type": "Microsoft.ManagedIdentity/userAssignedIdentities", + "apiVersion": "2023-01-31", + "name": "[parameters('identityName')]", + "location": "[parameters('location')]" + }, { "type": "Microsoft.Resources/deployments", "apiVersion": "2022-09-01", - "name": "[format('{0}-container-apps-environment', parameters('name'))]", + "name": "[format('{0}-container-app', parameters('serviceName'))]", "properties": { "expressionEvaluationOptions": { "scope": "inner" @@ -332,19 +358,50 @@ "mode": "Incremental", "parameters": { "name": { - "value": "[parameters('containerAppsEnvironmentName')]" + "value": "[parameters('name')]" }, "location": { "value": "[parameters('location')]" }, "tags": { - "value": "[parameters('tags')]" + "value": "[union(parameters('tags'), createObject('azd-service-name', parameters('serviceName')))]" + }, + "identityType": { + "value": "UserAssigned" + }, + "identityName": { + "value": "[parameters('identityName')]" + }, + "exists": { + "value": "[parameters('exists')]" + }, + "containerAppsEnvironmentName": { + "value": "[parameters('containerAppsEnvironmentName')]" + }, + "containerAppsEnvironmentResourceGroupName": { + "value": "[parameters('containerAppsEnvironmentResourceGroupName')]" + }, + "containerRegistryName": { + "value": "[parameters('containerRegistryName')]" }, - "logAnalyticsWorkspaceName": { - "value": "[parameters('logAnalyticsWorkspaceName')]" + "env": { + "value": [ + { + "name": "REACT_APP_APPLICATIONINSIGHTS_CONNECTION_STRING", + "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, parameters('applicationInsightsResourceGroupName')), 'Microsoft.Insights/components', parameters('applicationInsightsName')), '2020-02-02').ConnectionString]" + }, + { + "name": "REACT_APP_API_BASE_URL", + "value": "[parameters('apiBaseUrl')]" + }, + { + "name": "APPLICATIONINSIGHTS_CONNECTION_STRING", + "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, parameters('applicationInsightsResourceGroupName')), 'Microsoft.Insights/components', parameters('applicationInsightsName')), '2020-02-02').ConnectionString]" + } + ] }, - "applicationInsightsName": { - "value": "[parameters('applicationInsightsName')]" + "targetPort": { + "value": 80 } }, "template": { @@ -354,9 +411,9 @@ "_generator": { "name": "bicep", "version": "0.25.53.49325", - "templateHash": "4766903245227392386" + "templateHash": "12494944888544926830" }, - "description": "Creates an Azure Container Apps environment." + "description": "Creates or updates an existing Azure Container App." }, "parameters": { "name": { @@ -370,1402 +427,139 @@ "type": "object", "defaultValue": {} }, - "applicationInsightsName": { + "containerAppsEnvironmentName": { "type": "string", - "defaultValue": "", "metadata": { - "description": "Name of the Application Insights resource" + "description": "The environment name for the container apps" } }, - "daprEnabled": { - "type": "bool", - "defaultValue": false, + "containerAppsEnvironmentResourceGroupName": { + "type": "string", "metadata": { - "description": "Specifies if Dapr is enabled" + "description": "Resource Group Name of the environment for container apps" } }, - "logAnalyticsWorkspaceName": { + "containerCpuCoreCount": { "type": "string", + "defaultValue": "0.5", "metadata": { - "description": "Name of the Log Analytics workspace" + "description": "The number of CPU cores allocated to a single container instance, e.g., 0.5" } - } - }, - "resources": [ - { - "type": "Microsoft.App/managedEnvironments", - "apiVersion": "2023-04-01-preview", - "name": "[parameters('name')]", - "location": "[parameters('location')]", - "tags": "[parameters('tags')]", - "properties": { - "appLogsConfiguration": { - "destination": "log-analytics", - "logAnalyticsConfiguration": { - "customerId": "[reference(resourceId('Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceName')), '2022-10-01').customerId]", - "sharedKey": "[listKeys(resourceId('Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceName')), '2022-10-01').primarySharedKey]" - } - }, - "daprAIInstrumentationKey": "[if(and(parameters('daprEnabled'), not(empty(parameters('applicationInsightsName')))), reference(resourceId('Microsoft.Insights/components', parameters('applicationInsightsName')), '2020-02-02').InstrumentationKey, '')]" + }, + "containerMaxReplicas": { + "type": "int", + "defaultValue": 10, + "minValue": 1, + "metadata": { + "description": "The maximum number of replicas to run. Must be at least 1." } - } - ], - "outputs": { - "defaultDomain": { - "type": "string", - "value": "[reference(resourceId('Microsoft.App/managedEnvironments', parameters('name')), '2023-04-01-preview').defaultDomain]" }, - "id": { + "containerMemory": { "type": "string", - "value": "[resourceId('Microsoft.App/managedEnvironments', parameters('name'))]" + "defaultValue": "1.0Gi", + "metadata": { + "description": "The amount of memory allocated to a single container instance, e.g., 1Gi" + } }, - "name": { - "type": "string", - "value": "[parameters('name')]" - } - } - } - } - }, - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "[format('{0}-container-registry', parameters('name'))]", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "name": { - "value": "[parameters('containerRegistryName')]" - }, - "location": { - "value": "[parameters('location')]" - }, - "adminUserEnabled": { - "value": "[parameters('containerRegistryAdminUserEnabled')]" - }, - "tags": { - "value": "[parameters('tags')]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "12834334744516280883" + "containerMinReplicas": { + "type": "int", + "defaultValue": 1, + "minValue": 1, + "metadata": { + "description": "The minimum number of replicas to run. Must be at least 1." + } }, - "description": "Creates an Azure Container Registry." - }, - "parameters": { - "name": { - "type": "string" + "containerName": { + "type": "string", + "defaultValue": "main", + "metadata": { + "description": "The name of the container" + } }, - "location": { + "containerRegistryName": { "type": "string", - "defaultValue": "[resourceGroup().location]" + "defaultValue": "", + "metadata": { + "description": "The name of the container registry" + } }, - "tags": { - "type": "object", - "defaultValue": {} + "daprAppProtocol": { + "type": "string", + "defaultValue": "http", + "allowedValues": [ + "http", + "grpc" + ], + "metadata": { + "description": "The protocol used by Dapr to connect to the app, e.g., HTTP or gRPC" + } }, - "adminUserEnabled": { + "daprEnabled": { "type": "bool", "defaultValue": false, "metadata": { - "description": "Indicates whether admin user is enabled" + "description": "Enable or disable Dapr for the container app" } }, - "anonymousPullEnabled": { - "type": "bool", - "defaultValue": false, + "daprAppId": { + "type": "string", + "defaultValue": "[parameters('containerName')]", "metadata": { - "description": "Indicates whether anonymous pull is enabled" + "description": "The Dapr app ID" } }, - "dataEndpointEnabled": { + "exists": { "type": "bool", "defaultValue": false, "metadata": { - "description": "Indicates whether data endpoint is enabled" + "description": "Specifies if the resource already exists" } }, - "encryption": { - "type": "object", - "defaultValue": { - "status": "disabled" - }, + "ingressEnabled": { + "type": "bool", + "defaultValue": true, "metadata": { - "description": "Encryption settings" + "description": "Specifies if Ingress is enabled for the container app" } }, - "networkRuleBypassOptions": { + "identityType": { "type": "string", - "defaultValue": "AzureServices", + "defaultValue": "None", + "allowedValues": [ + "None", + "SystemAssigned", + "UserAssigned" + ], "metadata": { - "description": "Options for bypassing network rules" + "description": "The type of identity for the resource" } }, - "publicNetworkAccess": { + "identityName": { "type": "string", - "defaultValue": "Enabled", + "defaultValue": "", "metadata": { - "description": "Public network access setting" + "description": "The name of the user-assigned identity" } }, - "sku": { - "type": "object", - "defaultValue": { - "name": "Basic" - }, + "imageName": { + "type": "string", + "defaultValue": "", "metadata": { - "description": "SKU settings" + "description": "The name of the container image" } }, - "zoneRedundancy": { - "type": "string", - "defaultValue": "Disabled", + "secrets": { + "type": "array", + "defaultValue": [], "metadata": { - "description": "Zone redundancy setting" + "description": "The secrets required for the container" } }, - "workspaceId": { - "type": "string", - "defaultValue": "", + "env": { + "type": "array", + "defaultValue": [], "metadata": { - "description": "The log analytics workspace ID used for logging and monitoring" - } - } - }, - "resources": [ - { - "type": "Microsoft.ContainerRegistry/registries", - "apiVersion": "2022-02-01-preview", - "name": "[parameters('name')]", - "location": "[parameters('location')]", - "tags": "[parameters('tags')]", - "sku": "[parameters('sku')]", - "properties": { - "adminUserEnabled": "[parameters('adminUserEnabled')]", - "anonymousPullEnabled": "[parameters('anonymousPullEnabled')]", - "dataEndpointEnabled": "[parameters('dataEndpointEnabled')]", - "encryption": "[parameters('encryption')]", - "networkRuleBypassOptions": "[parameters('networkRuleBypassOptions')]", - "publicNetworkAccess": "[parameters('publicNetworkAccess')]", - "zoneRedundancy": "[parameters('zoneRedundancy')]" - } - }, - { - "condition": "[not(empty(parameters('workspaceId')))]", - "type": "Microsoft.Insights/diagnosticSettings", - "apiVersion": "2021-05-01-preview", - "scope": "[format('Microsoft.ContainerRegistry/registries/{0}', parameters('name'))]", - "name": "registry-diagnostics", - "properties": { - "workspaceId": "[parameters('workspaceId')]", - "logs": [ - { - "category": "ContainerRegistryRepositoryEvents", - "enabled": true - }, - { - "category": "ContainerRegistryLoginEvents", - "enabled": true - } - ], - "metrics": [ - { - "category": "AllMetrics", - "enabled": true, - "timeGrain": "PT1M" - } - ] - }, - "dependsOn": [ - "[resourceId('Microsoft.ContainerRegistry/registries', parameters('name'))]" - ] - } - ], - "outputs": { - "loginServer": { - "type": "string", - "value": "[reference(resourceId('Microsoft.ContainerRegistry/registries', parameters('name')), '2022-02-01-preview').loginServer]" - }, - "name": { - "type": "string", - "value": "[parameters('name')]" - } - } - } - } - } - ], - "outputs": { - "defaultDomain": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-apps-environment', parameters('name'))), '2022-09-01').outputs.defaultDomain.value]" - }, - "environmentName": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-apps-environment', parameters('name'))), '2022-09-01').outputs.name.value]" - }, - "environmentId": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-apps-environment', parameters('name'))), '2022-09-01').outputs.id.value]" - }, - "registryLoginServer": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-registry', parameters('name'))), '2022-09-01').outputs.loginServer.value]" - }, - "registryName": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-registry', parameters('name'))), '2022-09-01').outputs.name.value]" - } - } - } - }, - "dependsOn": [ - "[resourceId('Microsoft.Resources/deployments', 'monitoring')]" - ] - }, - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "web", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "name": "[if(not(empty(parameters('webContainerAppName'))), createObject('value', parameters('webContainerAppName')), createObject('value', format('{0}web-{1}', variables('abbrs').appContainerApps, variables('resourceToken'))))]", - "location": { - "value": "[parameters('location')]" - }, - "tags": { - "value": "[variables('tags')]" - }, - "identityName": { - "value": "[format('{0}web-{1}', variables('abbrs').managedIdentityUserAssignedIdentities, variables('resourceToken'))]" - }, - "apiBaseUrl": "[if(not(empty(parameters('webApiBaseUrl'))), createObject('value', parameters('webApiBaseUrl')), createObject('value', reference(resourceId('Microsoft.Resources/deployments', 'api'), '2022-09-01').outputs.SERVICE_API_URI.value))]", - "applicationInsightsName": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'monitoring'), '2022-09-01').outputs.applicationInsightsName.value]" - }, - "containerAppsEnvironmentName": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'container-apps'), '2022-09-01').outputs.environmentName.value]" - }, - "containerRegistryName": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'container-apps'), '2022-09-01').outputs.registryName.value]" - }, - "exists": { - "value": "[parameters('webAppExists')]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "5244656399300381833" - } - }, - "parameters": { - "name": { - "type": "string" - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]" - }, - "tags": { - "type": "object", - "defaultValue": {} - }, - "identityName": { - "type": "string" - }, - "apiBaseUrl": { - "type": "string" - }, - "applicationInsightsName": { - "type": "string" - }, - "containerAppsEnvironmentName": { - "type": "string" - }, - "containerRegistryName": { - "type": "string" - }, - "serviceName": { - "type": "string", - "defaultValue": "web" - }, - "exists": { - "type": "bool" - } - }, - "resources": [ - { - "type": "Microsoft.ManagedIdentity/userAssignedIdentities", - "apiVersion": "2023-01-31", - "name": "[parameters('identityName')]", - "location": "[parameters('location')]" - }, - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "[format('{0}-container-app', parameters('serviceName'))]", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "name": { - "value": "[parameters('name')]" - }, - "location": { - "value": "[parameters('location')]" - }, - "tags": { - "value": "[union(parameters('tags'), createObject('azd-service-name', parameters('serviceName')))]" - }, - "identityType": { - "value": "UserAssigned" - }, - "identityName": { - "value": "[parameters('identityName')]" - }, - "exists": { - "value": "[parameters('exists')]" - }, - "containerAppsEnvironmentName": { - "value": "[parameters('containerAppsEnvironmentName')]" - }, - "containerRegistryName": { - "value": "[parameters('containerRegistryName')]" - }, - "env": { - "value": [ - { - "name": "REACT_APP_APPLICATIONINSIGHTS_CONNECTION_STRING", - "value": "[reference(resourceId('Microsoft.Insights/components', parameters('applicationInsightsName')), '2020-02-02').ConnectionString]" - }, - { - "name": "REACT_APP_API_BASE_URL", - "value": "[parameters('apiBaseUrl')]" - }, - { - "name": "APPLICATIONINSIGHTS_CONNECTION_STRING", - "value": "[reference(resourceId('Microsoft.Insights/components', parameters('applicationInsightsName')), '2020-02-02').ConnectionString]" - } - ] - }, - "targetPort": { - "value": 80 - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "17242409915151931414" - }, - "description": "Creates or updates an existing Azure Container App." - }, - "parameters": { - "name": { - "type": "string" - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]" - }, - "tags": { - "type": "object", - "defaultValue": {} - }, - "containerAppsEnvironmentName": { - "type": "string", - "metadata": { - "description": "The environment name for the container apps" - } - }, - "containerCpuCoreCount": { - "type": "string", - "defaultValue": "0.5", - "metadata": { - "description": "The number of CPU cores allocated to a single container instance, e.g., 0.5" - } - }, - "containerMaxReplicas": { - "type": "int", - "defaultValue": 10, - "minValue": 1, - "metadata": { - "description": "The maximum number of replicas to run. Must be at least 1." - } - }, - "containerMemory": { - "type": "string", - "defaultValue": "1.0Gi", - "metadata": { - "description": "The amount of memory allocated to a single container instance, e.g., 1Gi" - } - }, - "containerMinReplicas": { - "type": "int", - "defaultValue": 1, - "minValue": 1, - "metadata": { - "description": "The minimum number of replicas to run. Must be at least 1." - } - }, - "containerName": { - "type": "string", - "defaultValue": "main", - "metadata": { - "description": "The name of the container" - } - }, - "containerRegistryName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the container registry" - } - }, - "daprAppProtocol": { - "type": "string", - "defaultValue": "http", - "allowedValues": [ - "http", - "grpc" - ], - "metadata": { - "description": "The protocol used by Dapr to connect to the app, e.g., HTTP or gRPC" - } - }, - "daprEnabled": { - "type": "bool", - "defaultValue": false, - "metadata": { - "description": "Enable or disable Dapr for the container app" - } - }, - "daprAppId": { - "type": "string", - "defaultValue": "[parameters('containerName')]", - "metadata": { - "description": "The Dapr app ID" - } - }, - "exists": { - "type": "bool", - "defaultValue": false, - "metadata": { - "description": "Specifies if the resource already exists" - } - }, - "ingressEnabled": { - "type": "bool", - "defaultValue": true, - "metadata": { - "description": "Specifies if Ingress is enabled for the container app" - } - }, - "identityType": { - "type": "string", - "defaultValue": "None", - "allowedValues": [ - "None", - "SystemAssigned", - "UserAssigned" - ], - "metadata": { - "description": "The type of identity for the resource" - } - }, - "identityName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the user-assigned identity" - } - }, - "imageName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the container image" - } - }, - "secrets": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "The secrets required for the container" - } - }, - "env": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "The environment variables for the container" - } - }, - "external": { - "type": "bool", - "defaultValue": true, - "metadata": { - "description": "Specifies if the resource ingress is exposed externally" - } - }, - "serviceBinds": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "The service binds associated with the container" - } - }, - "targetPort": { - "type": "int", - "defaultValue": 80, - "metadata": { - "description": "The target port for the container" - } - } - }, - "resources": [ - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "[format('{0}-update', deployment().name)]", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "name": { - "value": "[parameters('name')]" - }, - "location": { - "value": "[parameters('location')]" - }, - "tags": { - "value": "[parameters('tags')]" - }, - "identityType": { - "value": "[parameters('identityType')]" - }, - "identityName": { - "value": "[parameters('identityName')]" - }, - "ingressEnabled": { - "value": "[parameters('ingressEnabled')]" - }, - "containerName": { - "value": "[parameters('containerName')]" - }, - "containerAppsEnvironmentName": { - "value": "[parameters('containerAppsEnvironmentName')]" - }, - "containerRegistryName": { - "value": "[parameters('containerRegistryName')]" - }, - "containerCpuCoreCount": { - "value": "[parameters('containerCpuCoreCount')]" - }, - "containerMemory": { - "value": "[parameters('containerMemory')]" - }, - "containerMinReplicas": { - "value": "[parameters('containerMinReplicas')]" - }, - "containerMaxReplicas": { - "value": "[parameters('containerMaxReplicas')]" - }, - "daprEnabled": { - "value": "[parameters('daprEnabled')]" - }, - "daprAppId": { - "value": "[parameters('daprAppId')]" - }, - "daprAppProtocol": { - "value": "[parameters('daprAppProtocol')]" - }, - "secrets": { - "value": "[parameters('secrets')]" - }, - "external": { - "value": "[parameters('external')]" - }, - "env": { - "value": "[parameters('env')]" - }, - "imageName": "[if(not(empty(parameters('imageName'))), createObject('value', parameters('imageName')), if(parameters('exists'), createObject('value', reference(resourceId('Microsoft.App/containerApps', parameters('name')), '2023-04-01-preview').template.containers[0].image), createObject('value', '')))]", - "targetPort": { - "value": "[parameters('targetPort')]" - }, - "serviceBinds": { - "value": "[parameters('serviceBinds')]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "1912096201798605494" - }, - "description": "Creates a container app in an Azure Container App environment." - }, - "parameters": { - "name": { - "type": "string" - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]" - }, - "tags": { - "type": "object", - "defaultValue": {} - }, - "allowedOrigins": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "Allowed origins" - } - }, - "containerAppsEnvironmentName": { - "type": "string", - "metadata": { - "description": "Name of the environment for container apps" - } - }, - "containerCpuCoreCount": { - "type": "string", - "defaultValue": "0.5", - "metadata": { - "description": "CPU cores allocated to a single container instance, e.g., 0.5" - } - }, - "containerMaxReplicas": { - "type": "int", - "defaultValue": 10, - "minValue": 1, - "metadata": { - "description": "The maximum number of replicas to run. Must be at least 1." - } - }, - "containerMemory": { - "type": "string", - "defaultValue": "1.0Gi", - "metadata": { - "description": "Memory allocated to a single container instance, e.g., 1Gi" - } - }, - "containerMinReplicas": { - "type": "int", - "defaultValue": 1, - "metadata": { - "description": "The minimum number of replicas to run. Must be at least 1." - } - }, - "containerName": { - "type": "string", - "defaultValue": "main", - "metadata": { - "description": "The name of the container" - } - }, - "containerRegistryName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the container registry" - } - }, - "daprAppProtocol": { - "type": "string", - "defaultValue": "http", - "allowedValues": [ - "http", - "grpc" - ], - "metadata": { - "description": "The protocol used by Dapr to connect to the app, e.g., http or grpc" - } - }, - "daprAppId": { - "type": "string", - "defaultValue": "[parameters('containerName')]", - "metadata": { - "description": "The Dapr app ID" - } - }, - "daprEnabled": { - "type": "bool", - "defaultValue": false, - "metadata": { - "description": "Enable Dapr" - } - }, - "env": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "The environment variables for the container" - } - }, - "external": { - "type": "bool", - "defaultValue": true, - "metadata": { - "description": "Specifies if the resource ingress is exposed externally" - } - }, - "identityName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the user-assigned identity" - } - }, - "identityType": { - "type": "string", - "defaultValue": "None", - "allowedValues": [ - "None", - "SystemAssigned", - "UserAssigned" - ], - "metadata": { - "description": "The type of identity for the resource" - } - }, - "imageName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the container image" - } - }, - "ingressEnabled": { - "type": "bool", - "defaultValue": true, - "metadata": { - "description": "Specifies if Ingress is enabled for the container app" - } - }, - "revisionMode": { - "type": "string", - "defaultValue": "Single" - }, - "secrets": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "The secrets required for the container" - } - }, - "serviceBinds": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "The service binds associated with the container" - } - }, - "serviceType": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the container apps add-on to use. e.g. redis" - } - }, - "targetPort": { - "type": "int", - "defaultValue": 80, - "metadata": { - "description": "The target port for the container" - } - } - }, - "variables": { - "usePrivateRegistry": "[and(not(empty(parameters('identityName'))), not(empty(parameters('containerRegistryName'))))]", - "normalizedIdentityType": "[if(not(empty(parameters('identityName'))), 'UserAssigned', parameters('identityType'))]" - }, - "resources": [ - { - "type": "Microsoft.App/containerApps", - "apiVersion": "2023-04-01-preview", - "name": "[parameters('name')]", - "location": "[parameters('location')]", - "tags": "[parameters('tags')]", - "identity": { - "type": "[variables('normalizedIdentityType')]", - "userAssignedIdentities": "[if(and(not(empty(parameters('identityName'))), equals(variables('normalizedIdentityType'), 'UserAssigned')), createObject(format('{0}', resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName'))), createObject()), null())]" - }, - "properties": { - "managedEnvironmentId": "[resourceId('Microsoft.App/managedEnvironments', parameters('containerAppsEnvironmentName'))]", - "configuration": { - "activeRevisionsMode": "[parameters('revisionMode')]", - "ingress": "[if(parameters('ingressEnabled'), createObject('external', parameters('external'), 'targetPort', parameters('targetPort'), 'transport', 'auto', 'corsPolicy', createObject('allowedOrigins', union(createArray('https://portal.azure.com', 'https://ms.portal.azure.com'), parameters('allowedOrigins')))), null())]", - "dapr": "[if(parameters('daprEnabled'), createObject('enabled', true(), 'appId', parameters('daprAppId'), 'appProtocol', parameters('daprAppProtocol'), 'appPort', if(parameters('ingressEnabled'), parameters('targetPort'), 0)), createObject('enabled', false()))]", - "secrets": "[parameters('secrets')]", - "service": "[if(not(empty(parameters('serviceType'))), createObject('type', parameters('serviceType')), null())]", - "registries": "[if(variables('usePrivateRegistry'), createArray(createObject('server', format('{0}.azurecr.io', parameters('containerRegistryName')), 'identity', resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')))), createArray())]" - }, - "template": { - "serviceBinds": "[if(not(empty(parameters('serviceBinds'))), parameters('serviceBinds'), null())]", - "containers": [ - { - "image": "[if(not(empty(parameters('imageName'))), parameters('imageName'), 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest')]", - "name": "[parameters('containerName')]", - "env": "[parameters('env')]", - "resources": { - "cpu": "[json(parameters('containerCpuCoreCount'))]", - "memory": "[parameters('containerMemory')]" - } - } - ], - "scale": { - "minReplicas": "[parameters('containerMinReplicas')]", - "maxReplicas": "[parameters('containerMaxReplicas')]" - } - } - }, - "dependsOn": [ - "[resourceId('Microsoft.Resources/deployments', format('{0}-registry-access', deployment().name))]" - ] - }, - { - "condition": "[variables('usePrivateRegistry')]", - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "[format('{0}-registry-access', deployment().name)]", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "containerRegistryName": { - "value": "[parameters('containerRegistryName')]" - }, - "principalId": "[if(variables('usePrivateRegistry'), createObject('value', reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')), '2023-01-31').principalId), createObject('value', ''))]" - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "15144906240959446537" - }, - "description": "Assigns ACR Pull permissions to access an Azure Container Registry." - }, - "parameters": { - "containerRegistryName": { - "type": "string" - }, - "principalId": { - "type": "string" - } - }, - "variables": { - "acrPullRole": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '7f951dda-4ed3-4680-a7ca-43fe172d538d')]" - }, - "resources": [ - { - "type": "Microsoft.Authorization/roleAssignments", - "apiVersion": "2022-04-01", - "scope": "[format('Microsoft.ContainerRegistry/registries/{0}', parameters('containerRegistryName'))]", - "name": "[guid(subscription().id, resourceGroup().id, parameters('principalId'), variables('acrPullRole'))]", - "properties": { - "roleDefinitionId": "[variables('acrPullRole')]", - "principalType": "ServicePrincipal", - "principalId": "[parameters('principalId')]" - } - } - ] - } - } - } - ], - "outputs": { - "defaultDomain": { - "type": "string", - "value": "[reference(resourceId('Microsoft.App/managedEnvironments', parameters('containerAppsEnvironmentName')), '2023-04-01-preview').defaultDomain]" - }, - "identityPrincipalId": { - "type": "string", - "value": "[if(equals(variables('normalizedIdentityType'), 'None'), '', if(empty(parameters('identityName')), reference(resourceId('Microsoft.App/containerApps', parameters('name')), '2023-04-01-preview', 'full').identity.principalId, reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')), '2023-01-31').principalId))]" - }, - "imageName": { - "type": "string", - "value": "[parameters('imageName')]" - }, - "name": { - "type": "string", - "value": "[parameters('name')]" - }, - "serviceBind": { - "type": "object", - "value": "[if(not(empty(parameters('serviceType'))), createObject('serviceId', resourceId('Microsoft.App/containerApps', parameters('name')), 'name', parameters('name')), createObject())]" - }, - "uri": { - "type": "string", - "value": "[if(parameters('ingressEnabled'), format('https://{0}', reference(resourceId('Microsoft.App/containerApps', parameters('name')), '2023-04-01-preview').configuration.ingress.fqdn), '')]" - } - } - } - } - } - ], - "outputs": { - "defaultDomain": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-update', deployment().name)), '2022-09-01').outputs.defaultDomain.value]" - }, - "imageName": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-update', deployment().name)), '2022-09-01').outputs.imageName.value]" - }, - "name": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-update', deployment().name)), '2022-09-01').outputs.name.value]" - }, - "uri": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-update', deployment().name)), '2022-09-01').outputs.uri.value]" - } - } - } - } - } - ], - "outputs": { - "SERVICE_WEB_IDENTITY_PRINCIPAL_ID": { - "type": "string", - "value": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')), '2023-01-31').principalId]" - }, - "SERVICE_WEB_NAME": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-app', parameters('serviceName'))), '2022-09-01').outputs.name.value]" - }, - "SERVICE_WEB_URI": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-app', parameters('serviceName'))), '2022-09-01').outputs.uri.value]" - }, - "SERVICE_WEB_IMAGE_NAME": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-app', parameters('serviceName'))), '2022-09-01').outputs.imageName.value]" - } - } - } - }, - "dependsOn": [ - "[resourceId('Microsoft.Resources/deployments', 'api')]", - "[resourceId('Microsoft.Resources/deployments', 'container-apps')]", - "[resourceId('Microsoft.Resources/deployments', 'monitoring')]" - ] - }, - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "api", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "name": "[if(not(empty(parameters('apiContainerAppName'))), createObject('value', parameters('apiContainerAppName')), createObject('value', format('{0}api-{1}', variables('abbrs').appContainerApps, variables('resourceToken'))))]", - "location": { - "value": "[parameters('location')]" - }, - "tags": { - "value": "[variables('tags')]" - }, - "identityName": { - "value": "[format('{0}api-{1}', variables('abbrs').managedIdentityUserAssignedIdentities, variables('resourceToken'))]" - }, - "applicationInsightsName": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'monitoring'), '2022-09-01').outputs.applicationInsightsName.value]" - }, - "containerAppsEnvironmentName": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'container-apps'), '2022-09-01').outputs.environmentName.value]" - }, - "containerRegistryName": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'container-apps'), '2022-09-01').outputs.registryName.value]" - }, - "keyVaultName": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'keyvault'), '2022-09-01').outputs.name.value]" - }, - "corsAcaUrl": { - "value": "[format('https://{0}.{1}', variables('apiContainerAppNameOrDefault'), reference(resourceId('Microsoft.Resources/deployments', 'container-apps'), '2022-09-01').outputs.defaultDomain.value)]" - }, - "exists": { - "value": "[parameters('apiAppExists')]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "11092891629527222377" - } - }, - "parameters": { - "name": { - "type": "string" - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]" - }, - "tags": { - "type": "object", - "defaultValue": {} - }, - "identityName": { - "type": "string" - }, - "applicationInsightsName": { - "type": "string" - }, - "containerAppsEnvironmentName": { - "type": "string" - }, - "containerRegistryName": { - "type": "string" - }, - "keyVaultName": { - "type": "string" - }, - "serviceName": { - "type": "string", - "defaultValue": "api" - }, - "corsAcaUrl": { - "type": "string" - }, - "exists": { - "type": "bool" - } - }, - "resources": [ - { - "type": "Microsoft.ManagedIdentity/userAssignedIdentities", - "apiVersion": "2023-01-31", - "name": "[parameters('identityName')]", - "location": "[parameters('location')]" - }, - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "api-keyvault-access", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "keyVaultName": { - "value": "[parameters('keyVaultName')]" - }, - "principalId": { - "value": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')), '2023-01-31').principalId]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "815983560956742247" - }, - "description": "Assigns an Azure Key Vault access policy." - }, - "parameters": { - "name": { - "type": "string", - "defaultValue": "add" - }, - "keyVaultName": { - "type": "string" - }, - "permissions": { - "type": "object", - "defaultValue": { - "secrets": [ - "get", - "list" - ] - } - }, - "principalId": { - "type": "string" - } - }, - "resources": [ - { - "type": "Microsoft.KeyVault/vaults/accessPolicies", - "apiVersion": "2022-07-01", - "name": "[format('{0}/{1}', parameters('keyVaultName'), parameters('name'))]", - "properties": { - "accessPolicies": [ - { - "objectId": "[parameters('principalId')]", - "tenantId": "[subscription().tenantId]", - "permissions": "[parameters('permissions')]" - } - ] - } - } - ] - } - }, - "dependsOn": [ - "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName'))]" - ] - }, - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "[format('{0}-container-app', parameters('serviceName'))]", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "name": { - "value": "[parameters('name')]" - }, - "location": { - "value": "[parameters('location')]" - }, - "tags": { - "value": "[union(parameters('tags'), createObject('azd-service-name', parameters('serviceName')))]" - }, - "identityType": { - "value": "UserAssigned" - }, - "identityName": { - "value": "[parameters('identityName')]" - }, - "exists": { - "value": "[parameters('exists')]" - }, - "containerAppsEnvironmentName": { - "value": "[parameters('containerAppsEnvironmentName')]" - }, - "containerRegistryName": { - "value": "[parameters('containerRegistryName')]" - }, - "containerCpuCoreCount": { - "value": "1.0" - }, - "containerMemory": { - "value": "2.0Gi" - }, - "env": { - "value": [ - { - "name": "AZURE_CLIENT_ID", - "value": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')), '2023-01-31').clientId]" - }, - { - "name": "AZURE_KEY_VAULT_ENDPOINT", - "value": "[reference(resourceId('Microsoft.KeyVault/vaults', parameters('keyVaultName')), '2022-07-01').vaultUri]" - }, - { - "name": "APPLICATIONINSIGHTS_CONNECTION_STRING", - "value": "[reference(resourceId('Microsoft.Insights/components', parameters('applicationInsightsName')), '2020-02-02').ConnectionString]" - }, - { - "name": "API_ALLOW_ORIGINS", - "value": "[parameters('corsAcaUrl')]" - } - ] - }, - "targetPort": { - "value": 3100 - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "17242409915151931414" - }, - "description": "Creates or updates an existing Azure Container App." - }, - "parameters": { - "name": { - "type": "string" - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]" - }, - "tags": { - "type": "object", - "defaultValue": {} - }, - "containerAppsEnvironmentName": { - "type": "string", - "metadata": { - "description": "The environment name for the container apps" - } - }, - "containerCpuCoreCount": { - "type": "string", - "defaultValue": "0.5", - "metadata": { - "description": "The number of CPU cores allocated to a single container instance, e.g., 0.5" - } - }, - "containerMaxReplicas": { - "type": "int", - "defaultValue": 10, - "minValue": 1, - "metadata": { - "description": "The maximum number of replicas to run. Must be at least 1." - } - }, - "containerMemory": { - "type": "string", - "defaultValue": "1.0Gi", - "metadata": { - "description": "The amount of memory allocated to a single container instance, e.g., 1Gi" - } - }, - "containerMinReplicas": { - "type": "int", - "defaultValue": 1, - "minValue": 1, - "metadata": { - "description": "The minimum number of replicas to run. Must be at least 1." - } - }, - "containerName": { - "type": "string", - "defaultValue": "main", - "metadata": { - "description": "The name of the container" - } - }, - "containerRegistryName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the container registry" - } - }, - "daprAppProtocol": { - "type": "string", - "defaultValue": "http", - "allowedValues": [ - "http", - "grpc" - ], - "metadata": { - "description": "The protocol used by Dapr to connect to the app, e.g., HTTP or gRPC" - } - }, - "daprEnabled": { - "type": "bool", - "defaultValue": false, - "metadata": { - "description": "Enable or disable Dapr for the container app" - } - }, - "daprAppId": { - "type": "string", - "defaultValue": "[parameters('containerName')]", - "metadata": { - "description": "The Dapr app ID" - } - }, - "exists": { - "type": "bool", - "defaultValue": false, - "metadata": { - "description": "Specifies if the resource already exists" - } - }, - "ingressEnabled": { - "type": "bool", - "defaultValue": true, - "metadata": { - "description": "Specifies if Ingress is enabled for the container app" - } - }, - "identityType": { - "type": "string", - "defaultValue": "None", - "allowedValues": [ - "None", - "SystemAssigned", - "UserAssigned" - ], - "metadata": { - "description": "The type of identity for the resource" - } - }, - "identityName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the user-assigned identity" - } - }, - "imageName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the container image" - } - }, - "secrets": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "The secrets required for the container" - } - }, - "env": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "The environment variables for the container" + "description": "The environment variables for the container" } }, "external": { @@ -1825,6 +619,9 @@ "containerAppsEnvironmentName": { "value": "[parameters('containerAppsEnvironmentName')]" }, + "containerAppsEnvironmentResourceGroupName": { + "value": "[parameters('containerAppsEnvironmentResourceGroupName')]" + }, "containerRegistryName": { "value": "[parameters('containerRegistryName')]" }, @@ -1873,7 +670,7 @@ "_generator": { "name": "bicep", "version": "0.25.53.49325", - "templateHash": "1912096201798605494" + "templateHash": "10348832124348087726" }, "description": "Creates a container app in an Azure Container App environment." }, @@ -1902,6 +699,12 @@ "description": "Name of the environment for container apps" } }, + "containerAppsEnvironmentResourceGroupName": { + "type": "string", + "metadata": { + "description": "Resource Group Name of the environment for container apps" + } + }, "containerCpuCoreCount": { "type": "string", "defaultValue": "0.5", @@ -2066,7 +869,7 @@ "userAssignedIdentities": "[if(and(not(empty(parameters('identityName'))), equals(variables('normalizedIdentityType'), 'UserAssigned')), createObject(format('{0}', resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName'))), createObject()), null())]" }, "properties": { - "managedEnvironmentId": "[resourceId('Microsoft.App/managedEnvironments', parameters('containerAppsEnvironmentName'))]", + "managedEnvironmentId": "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, parameters('containerAppsEnvironmentResourceGroupName')), 'Microsoft.App/managedEnvironments', parameters('containerAppsEnvironmentName'))]", "configuration": { "activeRevisionsMode": "[parameters('revisionMode')]", "ingress": "[if(parameters('ingressEnabled'), createObject('external', parameters('external'), 'targetPort', parameters('targetPort'), 'transport', 'auto', 'corsPolicy', createObject('allowedOrigins', union(createArray('https://portal.azure.com', 'https://ms.portal.azure.com'), parameters('allowedOrigins')))), null())]", @@ -2156,7 +959,7 @@ "outputs": { "defaultDomain": { "type": "string", - "value": "[reference(resourceId('Microsoft.App/managedEnvironments', parameters('containerAppsEnvironmentName')), '2023-04-01-preview').defaultDomain]" + "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, parameters('containerAppsEnvironmentResourceGroupName')), 'Microsoft.App/managedEnvironments', parameters('containerAppsEnvironmentName')), '2023-04-01-preview').defaultDomain]" }, "identityPrincipalId": { "type": "string", @@ -2202,27 +1005,23 @@ } } } - }, - "dependsOn": [ - "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName'))]", - "[resourceId('Microsoft.Resources/deployments', 'api-keyvault-access')]" - ] + } } ], "outputs": { - "SERVICE_API_IDENTITY_PRINCIPAL_ID": { + "SERVICE_WEB_IDENTITY_PRINCIPAL_ID": { "type": "string", "value": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')), '2023-01-31').principalId]" }, - "SERVICE_API_NAME": { + "SERVICE_WEB_NAME": { "type": "string", "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-app', parameters('serviceName'))), '2022-09-01').outputs.name.value]" }, - "SERVICE_API_URI": { + "SERVICE_WEB_URI": { "type": "string", "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-app', parameters('serviceName'))), '2022-09-01').outputs.uri.value]" }, - "SERVICE_API_IMAGE_NAME": { + "SERVICE_WEB_IMAGE_NAME": { "type": "string", "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-app', parameters('serviceName'))), '2022-09-01').outputs.imageName.value]" } @@ -2230,33 +1029,53 @@ } }, "dependsOn": [ - "[resourceId('Microsoft.Resources/deployments', 'container-apps')]", - "[resourceId('Microsoft.Resources/deployments', 'keyvault')]", - "[resourceId('Microsoft.Resources/deployments', 'monitoring')]" + "[resourceId('Microsoft.Resources/deployments', 'api')]", + "[resourceId('Microsoft.Resources/deployments', 'app-container-registry')]" ] }, { "type": "Microsoft.Resources/deployments", "apiVersion": "2022-09-01", - "name": "cosmos", + "name": "api", "properties": { "expressionEvaluationOptions": { "scope": "inner" }, "mode": "Incremental", "parameters": { - "accountName": "[if(not(empty(parameters('cosmosAccountName'))), createObject('value', parameters('cosmosAccountName')), createObject('value', format('{0}{1}', variables('abbrs').documentDBDatabaseAccounts, variables('resourceToken'))))]", - "databaseName": { - "value": "[parameters('cosmosDatabaseName')]" - }, + "name": "[if(not(empty(parameters('apiContainerAppName'))), createObject('value', parameters('apiContainerAppName')), createObject('value', format('{0}api-{1}', variables('abbrs').appContainerApps, variables('resourceToken'))))]", "location": { "value": "[parameters('location')]" }, "tags": { "value": "[variables('tags')]" }, + "identityName": { + "value": "[format('{0}api-{1}', variables('abbrs').managedIdentityUserAssignedIdentities, variables('resourceToken'))]" + }, + "applicationInsightsName": { + "value": "[parameters('applicationInsightsName')]" + }, + "applicationInsightsResourceGroupName": { + "value": "[parameters('applicationInsightsResourceGroupName')]" + }, + "containerAppsEnvironmentName": { + "value": "[parameters('containerAppsEnvironmentName')]" + }, + "containerAppsEnvironmentResourceGroupName": { + "value": "[parameters('containerAppsEnvironmentResourceGroupName')]" + }, + "containerRegistryName": { + "value": "[reference(resourceId('Microsoft.Resources/deployments', 'app-container-registry'), '2022-09-01').outputs.name.value]" + }, "keyVaultName": { "value": "[reference(resourceId('Microsoft.Resources/deployments', 'keyvault'), '2022-09-01').outputs.name.value]" + }, + "corsAcaUrl": { + "value": "[parameters('corsAcaUrl')]" + }, + "exists": { + "value": "[parameters('apiAppExists')]" } }, "template": { @@ -2266,11 +1085,11 @@ "_generator": { "name": "bicep", "version": "0.25.53.49325", - "templateHash": "5730728686647632614" + "templateHash": "12086032597939785" } }, "parameters": { - "accountName": { + "name": { "type": "string" }, "location": { @@ -2281,63 +1100,181 @@ "type": "object", "defaultValue": {} }, - "collections": { - "type": "array", - "defaultValue": [ - { - "name": "TodoList", - "id": "TodoList", - "shardKey": "Hash", - "indexKey": "_id" - }, - { - "name": "TodoItem", - "id": "TodoItem", - "shardKey": "Hash", - "indexKey": "_id" - } - ] + "identityName": { + "type": "string" }, - "databaseName": { - "type": "string", - "defaultValue": "" + "applicationInsightsName": { + "type": "string" + }, + "applicationInsightsResourceGroupName": { + "type": "string" + }, + "containerAppsEnvironmentName": { + "type": "string" + }, + "containerAppsEnvironmentResourceGroupName": { + "type": "string" + }, + "containerRegistryName": { + "type": "string" }, "keyVaultName": { "type": "string" + }, + "serviceName": { + "type": "string", + "defaultValue": "api" + }, + "corsAcaUrl": { + "type": "string" + }, + "exists": { + "type": "bool" } }, - "variables": { - "defaultDatabaseName": "Todo", - "actualDatabaseName": "[if(not(empty(parameters('databaseName'))), parameters('databaseName'), variables('defaultDatabaseName'))]" - }, "resources": [ + { + "type": "Microsoft.ManagedIdentity/userAssignedIdentities", + "apiVersion": "2023-01-31", + "name": "[parameters('identityName')]", + "location": "[parameters('location')]" + }, { "type": "Microsoft.Resources/deployments", "apiVersion": "2022-09-01", - "name": "cosmos-mongo", + "name": "api-keyvault-access", "properties": { "expressionEvaluationOptions": { "scope": "inner" }, "mode": "Incremental", "parameters": { - "accountName": { - "value": "[parameters('accountName')]" + "keyVaultName": { + "value": "[parameters('keyVaultName')]" }, - "databaseName": { - "value": "[variables('actualDatabaseName')]" + "principalId": { + "value": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')), '2023-01-31').principalId]" + } + }, + "template": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "metadata": { + "_generator": { + "name": "bicep", + "version": "0.25.53.49325", + "templateHash": "815983560956742247" + }, + "description": "Assigns an Azure Key Vault access policy." + }, + "parameters": { + "name": { + "type": "string", + "defaultValue": "add" + }, + "keyVaultName": { + "type": "string" + }, + "permissions": { + "type": "object", + "defaultValue": { + "secrets": [ + "get", + "list" + ] + } + }, + "principalId": { + "type": "string" + } + }, + "resources": [ + { + "type": "Microsoft.KeyVault/vaults/accessPolicies", + "apiVersion": "2022-07-01", + "name": "[format('{0}/{1}', parameters('keyVaultName'), parameters('name'))]", + "properties": { + "accessPolicies": [ + { + "objectId": "[parameters('principalId')]", + "tenantId": "[subscription().tenantId]", + "permissions": "[parameters('permissions')]" + } + ] + } + } + ] + } + }, + "dependsOn": [ + "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName'))]" + ] + }, + { + "type": "Microsoft.Resources/deployments", + "apiVersion": "2022-09-01", + "name": "[format('{0}-container-app', parameters('serviceName'))]", + "properties": { + "expressionEvaluationOptions": { + "scope": "inner" + }, + "mode": "Incremental", + "parameters": { + "name": { + "value": "[parameters('name')]" }, "location": { "value": "[parameters('location')]" }, - "collections": { - "value": "[parameters('collections')]" + "tags": { + "value": "[union(parameters('tags'), createObject('azd-service-name', parameters('serviceName')))]" + }, + "identityType": { + "value": "UserAssigned" + }, + "identityName": { + "value": "[parameters('identityName')]" + }, + "exists": { + "value": "[parameters('exists')]" + }, + "containerAppsEnvironmentName": { + "value": "[parameters('containerAppsEnvironmentName')]" + }, + "containerAppsEnvironmentResourceGroupName": { + "value": "[parameters('containerAppsEnvironmentResourceGroupName')]" + }, + "containerRegistryName": { + "value": "[parameters('containerRegistryName')]" + }, + "containerCpuCoreCount": { + "value": "1.0" + }, + "containerMemory": { + "value": "2.0Gi" }, - "keyVaultName": { - "value": "[parameters('keyVaultName')]" + "env": { + "value": [ + { + "name": "AZURE_CLIENT_ID", + "value": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')), '2023-01-31').clientId]" + }, + { + "name": "AZURE_KEY_VAULT_ENDPOINT", + "value": "[reference(resourceId('Microsoft.KeyVault/vaults', parameters('keyVaultName')), '2022-07-01').vaultUri]" + }, + { + "name": "APPLICATIONINSIGHTS_CONNECTION_STRING", + "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, parameters('applicationInsightsResourceGroupName')), 'Microsoft.Insights/components', parameters('applicationInsightsName')), '2020-02-02').ConnectionString]" + }, + { + "name": "API_ALLOW_ORIGINS", + "value": "[parameters('corsAcaUrl')]" + } + ] }, - "tags": { - "value": "[parameters('tags')]" + "targetPort": { + "value": 3100 } }, "template": { @@ -2347,15 +1284,12 @@ "_generator": { "name": "bicep", "version": "0.25.53.49325", - "templateHash": "14549161001187918251" + "templateHash": "12494944888544926830" }, - "description": "Creates an Azure Cosmos DB for MongoDB account with a database." + "description": "Creates or updates an existing Azure Container App." }, "parameters": { - "accountName": { - "type": "string" - }, - "databaseName": { + "name": { "type": "string" }, "location": { @@ -2366,66 +1300,168 @@ "type": "object", "defaultValue": {} }, - "collections": { - "type": "array", - "defaultValue": [] + "containerAppsEnvironmentName": { + "type": "string", + "metadata": { + "description": "The environment name for the container apps" + } }, - "connectionStringKey": { + "containerAppsEnvironmentResourceGroupName": { "type": "string", - "defaultValue": "AZURE-COSMOS-CONNECTION-STRING" + "metadata": { + "description": "Resource Group Name of the environment for container apps" + } }, - "keyVaultName": { - "type": "string" + "containerCpuCoreCount": { + "type": "string", + "defaultValue": "0.5", + "metadata": { + "description": "The number of CPU cores allocated to a single container instance, e.g., 0.5" + } + }, + "containerMaxReplicas": { + "type": "int", + "defaultValue": 10, + "minValue": 1, + "metadata": { + "description": "The maximum number of replicas to run. Must be at least 1." + } + }, + "containerMemory": { + "type": "string", + "defaultValue": "1.0Gi", + "metadata": { + "description": "The amount of memory allocated to a single container instance, e.g., 1Gi" + } + }, + "containerMinReplicas": { + "type": "int", + "defaultValue": 1, + "minValue": 1, + "metadata": { + "description": "The minimum number of replicas to run. Must be at least 1." + } + }, + "containerName": { + "type": "string", + "defaultValue": "main", + "metadata": { + "description": "The name of the container" + } + }, + "containerRegistryName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The name of the container registry" + } + }, + "daprAppProtocol": { + "type": "string", + "defaultValue": "http", + "allowedValues": [ + "http", + "grpc" + ], + "metadata": { + "description": "The protocol used by Dapr to connect to the app, e.g., HTTP or gRPC" + } + }, + "daprEnabled": { + "type": "bool", + "defaultValue": false, + "metadata": { + "description": "Enable or disable Dapr for the container app" + } + }, + "daprAppId": { + "type": "string", + "defaultValue": "[parameters('containerName')]", + "metadata": { + "description": "The Dapr app ID" + } + }, + "exists": { + "type": "bool", + "defaultValue": false, + "metadata": { + "description": "Specifies if the resource already exists" + } + }, + "ingressEnabled": { + "type": "bool", + "defaultValue": true, + "metadata": { + "description": "Specifies if Ingress is enabled for the container app" + } + }, + "identityType": { + "type": "string", + "defaultValue": "None", + "allowedValues": [ + "None", + "SystemAssigned", + "UserAssigned" + ], + "metadata": { + "description": "The type of identity for the resource" + } + }, + "identityName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The name of the user-assigned identity" + } + }, + "imageName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The name of the container image" + } + }, + "secrets": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "The secrets required for the container" + } + }, + "env": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "The environment variables for the container" + } + }, + "external": { + "type": "bool", + "defaultValue": true, + "metadata": { + "description": "Specifies if the resource ingress is exposed externally" + } + }, + "serviceBinds": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "The service binds associated with the container" + } + }, + "targetPort": { + "type": "int", + "defaultValue": 80, + "metadata": { + "description": "The target port for the container" + } } }, "resources": [ - { - "copy": { - "name": "list", - "count": "[length(parameters('collections'))]" - }, - "type": "Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/collections", - "apiVersion": "2022-08-15", - "name": "[format('{0}/{1}/{2}', split(format('{0}/{1}', parameters('accountName'), parameters('databaseName')), '/')[0], split(format('{0}/{1}', parameters('accountName'), parameters('databaseName')), '/')[1], parameters('collections')[copyIndex()].name)]", - "properties": { - "resource": { - "id": "[parameters('collections')[copyIndex()].id]", - "shardKey": { - "_id": "[parameters('collections')[copyIndex()].shardKey]" - }, - "indexes": [ - { - "key": { - "keys": [ - "[parameters('collections')[copyIndex()].indexKey]" - ] - } - } - ] - } - }, - "dependsOn": [ - "[resourceId('Microsoft.DocumentDB/databaseAccounts/mongodbDatabases', split(format('{0}/{1}', parameters('accountName'), parameters('databaseName')), '/')[0], split(format('{0}/{1}', parameters('accountName'), parameters('databaseName')), '/')[1])]" - ] - }, - { - "type": "Microsoft.DocumentDB/databaseAccounts/mongodbDatabases", - "apiVersion": "2022-08-15", - "name": "[format('{0}/{1}', parameters('accountName'), parameters('databaseName'))]", - "tags": "[parameters('tags')]", - "properties": { - "resource": { - "id": "[parameters('databaseName')]" - } - }, - "dependsOn": [ - "[resourceId('Microsoft.Resources/deployments', 'cosmos-mongo-account')]" - ] - }, { "type": "Microsoft.Resources/deployments", "apiVersion": "2022-09-01", - "name": "cosmos-mongo-account", + "name": "[format('{0}-update', deployment().name)]", "properties": { "expressionEvaluationOptions": { "scope": "inner" @@ -2433,19 +1469,71 @@ "mode": "Incremental", "parameters": { "name": { - "value": "[parameters('accountName')]" + "value": "[parameters('name')]" + }, + "location": { + "value": "[parameters('location')]" + }, + "tags": { + "value": "[parameters('tags')]" + }, + "identityType": { + "value": "[parameters('identityType')]" + }, + "identityName": { + "value": "[parameters('identityName')]" + }, + "ingressEnabled": { + "value": "[parameters('ingressEnabled')]" + }, + "containerName": { + "value": "[parameters('containerName')]" }, - "location": { - "value": "[parameters('location')]" + "containerAppsEnvironmentName": { + "value": "[parameters('containerAppsEnvironmentName')]" }, - "keyVaultName": { - "value": "[parameters('keyVaultName')]" + "containerAppsEnvironmentResourceGroupName": { + "value": "[parameters('containerAppsEnvironmentResourceGroupName')]" }, - "tags": { - "value": "[parameters('tags')]" + "containerRegistryName": { + "value": "[parameters('containerRegistryName')]" }, - "connectionStringKey": { - "value": "[parameters('connectionStringKey')]" + "containerCpuCoreCount": { + "value": "[parameters('containerCpuCoreCount')]" + }, + "containerMemory": { + "value": "[parameters('containerMemory')]" + }, + "containerMinReplicas": { + "value": "[parameters('containerMinReplicas')]" + }, + "containerMaxReplicas": { + "value": "[parameters('containerMaxReplicas')]" + }, + "daprEnabled": { + "value": "[parameters('daprEnabled')]" + }, + "daprAppId": { + "value": "[parameters('daprAppId')]" + }, + "daprAppProtocol": { + "value": "[parameters('daprAppProtocol')]" + }, + "secrets": { + "value": "[parameters('secrets')]" + }, + "external": { + "value": "[parameters('external')]" + }, + "env": { + "value": "[parameters('env')]" + }, + "imageName": "[if(not(empty(parameters('imageName'))), createObject('value', parameters('imageName')), if(parameters('exists'), createObject('value', reference(resourceId('Microsoft.App/containerApps', parameters('name')), '2023-04-01-preview').template.containers[0].image), createObject('value', '')))]", + "targetPort": { + "value": "[parameters('targetPort')]" + }, + "serviceBinds": { + "value": "[parameters('serviceBinds')]" } }, "template": { @@ -2455,9 +1543,9 @@ "_generator": { "name": "bicep", "version": "0.25.53.49325", - "templateHash": "8317058180807592714" + "templateHash": "10348832124348087726" }, - "description": "Creates an Azure Cosmos DB for MongoDB account." + "description": "Creates a container app in an Azure Container App environment." }, "parameters": { "name": { @@ -2471,43 +1559,236 @@ "type": "object", "defaultValue": {} }, - "keyVaultName": { - "type": "string" + "allowedOrigins": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "Allowed origins" + } + }, + "containerAppsEnvironmentName": { + "type": "string", + "metadata": { + "description": "Name of the environment for container apps" + } + }, + "containerAppsEnvironmentResourceGroupName": { + "type": "string", + "metadata": { + "description": "Resource Group Name of the environment for container apps" + } + }, + "containerCpuCoreCount": { + "type": "string", + "defaultValue": "0.5", + "metadata": { + "description": "CPU cores allocated to a single container instance, e.g., 0.5" + } + }, + "containerMaxReplicas": { + "type": "int", + "defaultValue": 10, + "minValue": 1, + "metadata": { + "description": "The maximum number of replicas to run. Must be at least 1." + } + }, + "containerMemory": { + "type": "string", + "defaultValue": "1.0Gi", + "metadata": { + "description": "Memory allocated to a single container instance, e.g., 1Gi" + } + }, + "containerMinReplicas": { + "type": "int", + "defaultValue": 1, + "metadata": { + "description": "The minimum number of replicas to run. Must be at least 1." + } + }, + "containerName": { + "type": "string", + "defaultValue": "main", + "metadata": { + "description": "The name of the container" + } + }, + "containerRegistryName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The name of the container registry" + } + }, + "daprAppProtocol": { + "type": "string", + "defaultValue": "http", + "allowedValues": [ + "http", + "grpc" + ], + "metadata": { + "description": "The protocol used by Dapr to connect to the app, e.g., http or grpc" + } + }, + "daprAppId": { + "type": "string", + "defaultValue": "[parameters('containerName')]", + "metadata": { + "description": "The Dapr app ID" + } + }, + "daprEnabled": { + "type": "bool", + "defaultValue": false, + "metadata": { + "description": "Enable Dapr" + } + }, + "env": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "The environment variables for the container" + } + }, + "external": { + "type": "bool", + "defaultValue": true, + "metadata": { + "description": "Specifies if the resource ingress is exposed externally" + } + }, + "identityName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The name of the user-assigned identity" + } + }, + "identityType": { + "type": "string", + "defaultValue": "None", + "allowedValues": [ + "None", + "SystemAssigned", + "UserAssigned" + ], + "metadata": { + "description": "The type of identity for the resource" + } + }, + "imageName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The name of the container image" + } + }, + "ingressEnabled": { + "type": "bool", + "defaultValue": true, + "metadata": { + "description": "Specifies if Ingress is enabled for the container app" + } + }, + "revisionMode": { + "type": "string", + "defaultValue": "Single" + }, + "secrets": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "The secrets required for the container" + } + }, + "serviceBinds": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "The service binds associated with the container" + } + }, + "serviceType": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The name of the container apps add-on to use. e.g. redis" + } + }, + "targetPort": { + "type": "int", + "defaultValue": 80, + "metadata": { + "description": "The target port for the container" + } + } + }, + "variables": { + "usePrivateRegistry": "[and(not(empty(parameters('identityName'))), not(empty(parameters('containerRegistryName'))))]", + "normalizedIdentityType": "[if(not(empty(parameters('identityName'))), 'UserAssigned', parameters('identityType'))]" + }, + "resources": [ + { + "type": "Microsoft.App/containerApps", + "apiVersion": "2023-04-01-preview", + "name": "[parameters('name')]", + "location": "[parameters('location')]", + "tags": "[parameters('tags')]", + "identity": { + "type": "[variables('normalizedIdentityType')]", + "userAssignedIdentities": "[if(and(not(empty(parameters('identityName'))), equals(variables('normalizedIdentityType'), 'UserAssigned')), createObject(format('{0}', resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName'))), createObject()), null())]" + }, + "properties": { + "managedEnvironmentId": "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, parameters('containerAppsEnvironmentResourceGroupName')), 'Microsoft.App/managedEnvironments', parameters('containerAppsEnvironmentName'))]", + "configuration": { + "activeRevisionsMode": "[parameters('revisionMode')]", + "ingress": "[if(parameters('ingressEnabled'), createObject('external', parameters('external'), 'targetPort', parameters('targetPort'), 'transport', 'auto', 'corsPolicy', createObject('allowedOrigins', union(createArray('https://portal.azure.com', 'https://ms.portal.azure.com'), parameters('allowedOrigins')))), null())]", + "dapr": "[if(parameters('daprEnabled'), createObject('enabled', true(), 'appId', parameters('daprAppId'), 'appProtocol', parameters('daprAppProtocol'), 'appPort', if(parameters('ingressEnabled'), parameters('targetPort'), 0)), createObject('enabled', false()))]", + "secrets": "[parameters('secrets')]", + "service": "[if(not(empty(parameters('serviceType'))), createObject('type', parameters('serviceType')), null())]", + "registries": "[if(variables('usePrivateRegistry'), createArray(createObject('server', format('{0}.azurecr.io', parameters('containerRegistryName')), 'identity', resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')))), createArray())]" + }, + "template": { + "serviceBinds": "[if(not(empty(parameters('serviceBinds'))), parameters('serviceBinds'), null())]", + "containers": [ + { + "image": "[if(not(empty(parameters('imageName'))), parameters('imageName'), 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest')]", + "name": "[parameters('containerName')]", + "env": "[parameters('env')]", + "resources": { + "cpu": "[json(parameters('containerCpuCoreCount'))]", + "memory": "[parameters('containerMemory')]" + } + } + ], + "scale": { + "minReplicas": "[parameters('containerMinReplicas')]", + "maxReplicas": "[parameters('containerMaxReplicas')]" + } + } + }, + "dependsOn": [ + "[resourceId('Microsoft.Resources/deployments', format('{0}-registry-access', deployment().name))]" + ] }, - "connectionStringKey": { - "type": "string", - "defaultValue": "AZURE-COSMOS-CONNECTION-STRING" - } - }, - "resources": [ { + "condition": "[variables('usePrivateRegistry')]", "type": "Microsoft.Resources/deployments", "apiVersion": "2022-09-01", - "name": "cosmos-account", + "name": "[format('{0}-registry-access', deployment().name)]", "properties": { "expressionEvaluationOptions": { "scope": "inner" }, "mode": "Incremental", "parameters": { - "name": { - "value": "[parameters('name')]" - }, - "location": { - "value": "[parameters('location')]" - }, - "connectionStringKey": { - "value": "[parameters('connectionStringKey')]" - }, - "keyVaultName": { - "value": "[parameters('keyVaultName')]" - }, - "kind": { - "value": "MongoDB" + "containerRegistryName": { + "value": "[parameters('containerRegistryName')]" }, - "tags": { - "value": "[parameters('tags')]" - } + "principalId": "[if(variables('usePrivateRegistry'), createObject('value', reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')), '2023-01-31').principalId), createObject('value', ''))]" }, "template": { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", @@ -2516,114 +1797,62 @@ "_generator": { "name": "bicep", "version": "0.25.53.49325", - "templateHash": "13614361263700788271" + "templateHash": "15144906240959446537" }, - "description": "Creates an Azure Cosmos DB account." + "description": "Assigns ACR Pull permissions to access an Azure Container Registry." }, "parameters": { - "name": { + "containerRegistryName": { "type": "string" }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]" - }, - "tags": { - "type": "object", - "defaultValue": {} - }, - "connectionStringKey": { - "type": "string", - "defaultValue": "AZURE-COSMOS-CONNECTION-STRING" - }, - "keyVaultName": { + "principalId": { "type": "string" - }, - "kind": { - "type": "string", - "allowedValues": [ - "GlobalDocumentDB", - "MongoDB", - "Parse" - ] } }, + "variables": { + "acrPullRole": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '7f951dda-4ed3-4680-a7ca-43fe172d538d')]" + }, "resources": [ { - "type": "Microsoft.DocumentDB/databaseAccounts", - "apiVersion": "2022-08-15", - "name": "[parameters('name')]", - "kind": "[parameters('kind')]", - "location": "[parameters('location')]", - "tags": "[parameters('tags')]", + "type": "Microsoft.Authorization/roleAssignments", + "apiVersion": "2022-04-01", + "scope": "[format('Microsoft.ContainerRegistry/registries/{0}', parameters('containerRegistryName'))]", + "name": "[guid(subscription().id, resourceGroup().id, parameters('principalId'), variables('acrPullRole'))]", "properties": { - "consistencyPolicy": { - "defaultConsistencyLevel": "Session" - }, - "locations": [ - { - "locationName": "[parameters('location')]", - "failoverPriority": 0, - "isZoneRedundant": false - } - ], - "databaseAccountOfferType": "Standard", - "enableAutomaticFailover": false, - "enableMultipleWriteLocations": false, - "apiProperties": "[if(equals(parameters('kind'), 'MongoDB'), createObject('serverVersion', '4.2'), createObject())]", - "capabilities": [ - { - "name": "EnableServerless" - } - ] + "roleDefinitionId": "[variables('acrPullRole')]", + "principalType": "ServicePrincipal", + "principalId": "[parameters('principalId')]" } - }, - { - "type": "Microsoft.KeyVault/vaults/secrets", - "apiVersion": "2022-07-01", - "name": "[format('{0}/{1}', parameters('keyVaultName'), parameters('connectionStringKey'))]", - "properties": { - "value": "[listConnectionStrings(resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('name')), '2022-08-15').connectionStrings[0].connectionString]" - }, - "dependsOn": [ - "[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('name'))]" - ] - } - ], - "outputs": { - "connectionStringKey": { - "type": "string", - "value": "[parameters('connectionStringKey')]" - }, - "endpoint": { - "type": "string", - "value": "[reference(resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('name')), '2022-08-15').documentEndpoint]" - }, - "id": { - "type": "string", - "value": "[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('name'))]" - }, - "name": { - "type": "string", - "value": "[parameters('name')]" } - } + ] } } } ], "outputs": { - "connectionStringKey": { + "defaultDomain": { "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos-account'), '2022-09-01').outputs.connectionStringKey.value]" + "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, parameters('containerAppsEnvironmentResourceGroupName')), 'Microsoft.App/managedEnvironments', parameters('containerAppsEnvironmentName')), '2023-04-01-preview').defaultDomain]" }, - "endpoint": { + "identityPrincipalId": { "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos-account'), '2022-09-01').outputs.endpoint.value]" + "value": "[if(equals(variables('normalizedIdentityType'), 'None'), '', if(empty(parameters('identityName')), reference(resourceId('Microsoft.App/containerApps', parameters('name')), '2023-04-01-preview', 'full').identity.principalId, reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')), '2023-01-31').principalId))]" }, - "id": { + "imageName": { "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos-account'), '2022-09-01').outputs.id.value]" + "value": "[parameters('imageName')]" + }, + "name": { + "type": "string", + "value": "[parameters('name')]" + }, + "serviceBind": { + "type": "object", + "value": "[if(not(empty(parameters('serviceType'))), createObject('serviceId', resourceId('Microsoft.App/containerApps', parameters('name')), 'name', parameters('name')), createObject())]" + }, + "uri": { + "type": "string", + "value": "[if(parameters('ingressEnabled'), format('https://{0}', reference(resourceId('Microsoft.App/containerApps', parameters('name')), '2023-04-01-preview').configuration.ingress.fqdn), '')]" } } } @@ -2631,62 +1860,77 @@ } ], "outputs": { - "connectionStringKey": { + "defaultDomain": { "type": "string", - "value": "[parameters('connectionStringKey')]" + "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-update', deployment().name)), '2022-09-01').outputs.defaultDomain.value]" }, - "databaseName": { + "imageName": { "type": "string", - "value": "[parameters('databaseName')]" + "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-update', deployment().name)), '2022-09-01').outputs.imageName.value]" }, - "endpoint": { + "name": { "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos-mongo-account'), '2022-09-01').outputs.endpoint.value]" + "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-update', deployment().name)), '2022-09-01').outputs.name.value]" + }, + "uri": { + "type": "string", + "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-update', deployment().name)), '2022-09-01').outputs.uri.value]" } } } - } + }, + "dependsOn": [ + "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName'))]", + "[resourceId('Microsoft.Resources/deployments', 'api-keyvault-access')]" + ] } ], "outputs": { - "connectionStringKey": { + "SERVICE_API_IDENTITY_PRINCIPAL_ID": { "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos-mongo'), '2022-09-01').outputs.connectionStringKey.value]" + "value": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')), '2023-01-31').principalId]" }, - "databaseName": { + "SERVICE_API_NAME": { "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos-mongo'), '2022-09-01').outputs.databaseName.value]" + "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-app', parameters('serviceName'))), '2022-09-01').outputs.name.value]" }, - "endpoint": { + "SERVICE_API_URI": { "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos-mongo'), '2022-09-01').outputs.endpoint.value]" + "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-app', parameters('serviceName'))), '2022-09-01').outputs.uri.value]" + }, + "SERVICE_API_IMAGE_NAME": { + "type": "string", + "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-app', parameters('serviceName'))), '2022-09-01').outputs.imageName.value]" } } } }, "dependsOn": [ + "[resourceId('Microsoft.Resources/deployments', 'app-container-registry')]", "[resourceId('Microsoft.Resources/deployments', 'keyvault')]" ] }, { "type": "Microsoft.Resources/deployments", "apiVersion": "2022-09-01", - "name": "keyvault", + "name": "app-container-registry", "properties": { "expressionEvaluationOptions": { "scope": "inner" }, "mode": "Incremental", "parameters": { - "name": "[if(not(empty(parameters('keyVaultName'))), createObject('value', parameters('keyVaultName')), createObject('value', format('{0}{1}', variables('abbrs').keyVaultVaults, variables('resourceToken'))))]", + "name": { + "value": "[parameters('containerRegistryName')]" + }, "location": { "value": "[parameters('location')]" }, + "adminUserEnabled": { + "value": "[parameters('containerRegistryAdminUserEnabled')]" + }, "tags": { "value": "[variables('tags')]" - }, - "principalId": { - "value": "[parameters('principalId')]" } }, "template": { @@ -2696,9 +1940,9 @@ "_generator": { "name": "bicep", "version": "0.25.53.49325", - "templateHash": "17948623451174129396" + "templateHash": "12834334744516280883" }, - "description": "Creates an Azure Key Vault." + "description": "Creates an Azure Container Registry." }, "parameters": { "name": { @@ -2712,32 +1956,127 @@ "type": "object", "defaultValue": {} }, - "principalId": { + "adminUserEnabled": { + "type": "bool", + "defaultValue": false, + "metadata": { + "description": "Indicates whether admin user is enabled" + } + }, + "anonymousPullEnabled": { + "type": "bool", + "defaultValue": false, + "metadata": { + "description": "Indicates whether anonymous pull is enabled" + } + }, + "dataEndpointEnabled": { + "type": "bool", + "defaultValue": false, + "metadata": { + "description": "Indicates whether data endpoint is enabled" + } + }, + "encryption": { + "type": "object", + "defaultValue": { + "status": "disabled" + }, + "metadata": { + "description": "Encryption settings" + } + }, + "networkRuleBypassOptions": { "type": "string", - "defaultValue": "" + "defaultValue": "AzureServices", + "metadata": { + "description": "Options for bypassing network rules" + } + }, + "publicNetworkAccess": { + "type": "string", + "defaultValue": "Enabled", + "metadata": { + "description": "Public network access setting" + } + }, + "sku": { + "type": "object", + "defaultValue": { + "name": "Basic" + }, + "metadata": { + "description": "SKU settings" + } + }, + "zoneRedundancy": { + "type": "string", + "defaultValue": "Disabled", + "metadata": { + "description": "Zone redundancy setting" + } + }, + "workspaceId": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The log analytics workspace ID used for logging and monitoring" + } } }, "resources": [ { - "type": "Microsoft.KeyVault/vaults", - "apiVersion": "2022-07-01", + "type": "Microsoft.ContainerRegistry/registries", + "apiVersion": "2022-02-01-preview", "name": "[parameters('name')]", "location": "[parameters('location')]", "tags": "[parameters('tags')]", + "sku": "[parameters('sku')]", "properties": { - "tenantId": "[subscription().tenantId]", - "sku": { - "family": "A", - "name": "standard" - }, - "accessPolicies": "[if(not(empty(parameters('principalId'))), createArray(createObject('objectId', parameters('principalId'), 'permissions', createObject('secrets', createArray('get', 'list')), 'tenantId', subscription().tenantId)), createArray())]" + "adminUserEnabled": "[parameters('adminUserEnabled')]", + "anonymousPullEnabled": "[parameters('anonymousPullEnabled')]", + "dataEndpointEnabled": "[parameters('dataEndpointEnabled')]", + "encryption": "[parameters('encryption')]", + "networkRuleBypassOptions": "[parameters('networkRuleBypassOptions')]", + "publicNetworkAccess": "[parameters('publicNetworkAccess')]", + "zoneRedundancy": "[parameters('zoneRedundancy')]" } + }, + { + "condition": "[not(empty(parameters('workspaceId')))]", + "type": "Microsoft.Insights/diagnosticSettings", + "apiVersion": "2021-05-01-preview", + "scope": "[format('Microsoft.ContainerRegistry/registries/{0}', parameters('name'))]", + "name": "registry-diagnostics", + "properties": { + "workspaceId": "[parameters('workspaceId')]", + "logs": [ + { + "category": "ContainerRegistryRepositoryEvents", + "enabled": true + }, + { + "category": "ContainerRegistryLoginEvents", + "enabled": true + } + ], + "metrics": [ + { + "category": "AllMetrics", + "enabled": true, + "timeGrain": "PT1M" + } + ] + }, + "dependsOn": [ + "[resourceId('Microsoft.ContainerRegistry/registries', parameters('name'))]" + ] } ], "outputs": { - "endpoint": { + "loginServer": { "type": "string", - "value": "[reference(resourceId('Microsoft.KeyVault/vaults', parameters('name')), '2022-07-01').vaultUri]" + "value": "[reference(resourceId('Microsoft.ContainerRegistry/registries', parameters('name')), '2022-02-01-preview').loginServer]" }, "name": { "type": "string", @@ -2750,22 +2089,26 @@ { "type": "Microsoft.Resources/deployments", "apiVersion": "2022-09-01", - "name": "monitoring", + "name": "cosmos", "properties": { "expressionEvaluationOptions": { "scope": "inner" }, "mode": "Incremental", "parameters": { + "accountName": "[if(not(empty(parameters('cosmosAccountName'))), createObject('value', parameters('cosmosAccountName')), createObject('value', format('{0}{1}', variables('abbrs').documentDBDatabaseAccounts, variables('resourceToken'))))]", + "databaseName": { + "value": "[parameters('cosmosDatabaseName')]" + }, "location": { "value": "[parameters('location')]" }, "tags": { "value": "[variables('tags')]" }, - "logAnalyticsName": "[if(not(empty(parameters('logAnalyticsName'))), createObject('value', parameters('logAnalyticsName')), createObject('value', format('{0}{1}', variables('abbrs').operationalInsightsWorkspaces, variables('resourceToken'))))]", - "applicationInsightsName": "[if(not(empty(parameters('applicationInsightsName'))), createObject('value', parameters('applicationInsightsName')), createObject('value', format('{0}{1}', variables('abbrs').insightsComponents, variables('resourceToken'))))]", - "applicationInsightsDashboardName": "[if(not(empty(parameters('applicationInsightsDashboardName'))), createObject('value', parameters('applicationInsightsDashboardName')), createObject('value', format('{0}{1}', variables('abbrs').portalDashboards, variables('resourceToken'))))]" + "keyVaultName": { + "value": "[reference(resourceId('Microsoft.Resources/deployments', 'keyvault'), '2022-09-01').outputs.name.value]" + } }, "template": { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", @@ -2774,21 +2117,13 @@ "_generator": { "name": "bicep", "version": "0.25.53.49325", - "templateHash": "10041669792322197047" - }, - "description": "Creates an Application Insights instance and a Log Analytics workspace." + "templateHash": "5730728686647632614" + } }, "parameters": { - "logAnalyticsName": { - "type": "string" - }, - "applicationInsightsName": { + "accountName": { "type": "string" }, - "applicationInsightsDashboardName": { - "type": "string", - "defaultValue": "" - }, "location": { "type": "string", "defaultValue": "[resourceGroup().location]" @@ -2796,108 +2131,64 @@ "tags": { "type": "object", "defaultValue": {} + }, + "collections": { + "type": "array", + "defaultValue": [ + { + "name": "TodoList", + "id": "TodoList", + "shardKey": "Hash", + "indexKey": "_id" + }, + { + "name": "TodoItem", + "id": "TodoItem", + "shardKey": "Hash", + "indexKey": "_id" + } + ] + }, + "databaseName": { + "type": "string", + "defaultValue": "" + }, + "keyVaultName": { + "type": "string" } }, + "variables": { + "defaultDatabaseName": "Todo", + "actualDatabaseName": "[if(not(empty(parameters('databaseName'))), parameters('databaseName'), variables('defaultDatabaseName'))]" + }, "resources": [ { "type": "Microsoft.Resources/deployments", "apiVersion": "2022-09-01", - "name": "loganalytics", + "name": "cosmos-mongo", "properties": { "expressionEvaluationOptions": { "scope": "inner" }, "mode": "Incremental", "parameters": { - "name": { - "value": "[parameters('logAnalyticsName')]" + "accountName": { + "value": "[parameters('accountName')]" + }, + "databaseName": { + "value": "[variables('actualDatabaseName')]" }, "location": { "value": "[parameters('location')]" }, - "tags": { - "value": "[parameters('tags')]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "9622176141085970536" - }, - "description": "Creates a Log Analytics workspace." - }, - "parameters": { - "name": { - "type": "string" - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]" - }, - "tags": { - "type": "object", - "defaultValue": {} - } - }, - "resources": [ - { - "type": "Microsoft.OperationalInsights/workspaces", - "apiVersion": "2021-12-01-preview", - "name": "[parameters('name')]", - "location": "[parameters('location')]", - "tags": "[parameters('tags')]", - "properties": { - "retentionInDays": 30, - "features": { - "searchVersion": 1 - }, - "sku": { - "name": "PerGB2018" - } - } - } - ], - "outputs": { - "id": { - "type": "string", - "value": "[resourceId('Microsoft.OperationalInsights/workspaces', parameters('name'))]" - }, - "name": { - "type": "string", - "value": "[parameters('name')]" - } - } - } - } - }, - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "applicationinsights", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "name": { - "value": "[parameters('applicationInsightsName')]" + "collections": { + "value": "[parameters('collections')]" }, - "location": { - "value": "[parameters('location')]" + "keyVaultName": { + "value": "[parameters('keyVaultName')]" }, "tags": { "value": "[parameters('tags')]" - }, - "dashboardName": { - "value": "[parameters('applicationInsightsDashboardName')]" - }, - "logAnalyticsWorkspaceId": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'loganalytics'), '2022-09-01').outputs.id.value]" } }, "template": { @@ -2907,17 +2198,16 @@ "_generator": { "name": "bicep", "version": "0.25.53.49325", - "templateHash": "1335628967363670282" + "templateHash": "14549161001187918251" }, - "description": "Creates an Application Insights instance based on an existing Log Analytics workspace." + "description": "Creates an Azure Cosmos DB for MongoDB account with a database." }, "parameters": { - "name": { + "accountName": { "type": "string" }, - "dashboardName": { - "type": "string", - "defaultValue": "" + "databaseName": { + "type": "string" }, "location": { "type": "string", @@ -2927,28 +2217,66 @@ "type": "object", "defaultValue": {} }, - "logAnalyticsWorkspaceId": { + "collections": { + "type": "array", + "defaultValue": [] + }, + "connectionStringKey": { + "type": "string", + "defaultValue": "AZURE-COSMOS-CONNECTION-STRING" + }, + "keyVaultName": { "type": "string" } }, "resources": [ { - "type": "Microsoft.Insights/components", - "apiVersion": "2020-02-02", - "name": "[parameters('name')]", - "location": "[parameters('location')]", + "copy": { + "name": "list", + "count": "[length(parameters('collections'))]" + }, + "type": "Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/collections", + "apiVersion": "2022-08-15", + "name": "[format('{0}/{1}/{2}', split(format('{0}/{1}', parameters('accountName'), parameters('databaseName')), '/')[0], split(format('{0}/{1}', parameters('accountName'), parameters('databaseName')), '/')[1], parameters('collections')[copyIndex()].name)]", + "properties": { + "resource": { + "id": "[parameters('collections')[copyIndex()].id]", + "shardKey": { + "_id": "[parameters('collections')[copyIndex()].shardKey]" + }, + "indexes": [ + { + "key": { + "keys": [ + "[parameters('collections')[copyIndex()].indexKey]" + ] + } + } + ] + } + }, + "dependsOn": [ + "[resourceId('Microsoft.DocumentDB/databaseAccounts/mongodbDatabases', split(format('{0}/{1}', parameters('accountName'), parameters('databaseName')), '/')[0], split(format('{0}/{1}', parameters('accountName'), parameters('databaseName')), '/')[1])]" + ] + }, + { + "type": "Microsoft.DocumentDB/databaseAccounts/mongodbDatabases", + "apiVersion": "2022-08-15", + "name": "[format('{0}/{1}', parameters('accountName'), parameters('databaseName'))]", "tags": "[parameters('tags')]", - "kind": "web", "properties": { - "Application_Type": "web", - "WorkspaceResourceId": "[parameters('logAnalyticsWorkspaceId')]" - } + "resource": { + "id": "[parameters('databaseName')]" + } + }, + "dependsOn": [ + "[resourceId('Microsoft.Resources/deployments', 'cosmos-mongo-account')]" + ] }, { - "condition": "[not(empty(parameters('dashboardName')))]", "type": "Microsoft.Resources/deployments", "apiVersion": "2022-09-01", - "name": "application-insights-dashboard", + "name": "cosmos-mongo-account", "properties": { "expressionEvaluationOptions": { "scope": "inner" @@ -2956,13 +2284,19 @@ "mode": "Incremental", "parameters": { "name": { - "value": "[parameters('dashboardName')]" + "value": "[parameters('accountName')]" }, "location": { "value": "[parameters('location')]" }, - "applicationInsightsName": { - "value": "[parameters('name')]" + "keyVaultName": { + "value": "[parameters('keyVaultName')]" + }, + "tags": { + "value": "[parameters('tags')]" + }, + "connectionStringKey": { + "value": "[parameters('connectionStringKey')]" } }, "template": { @@ -2972,17 +2306,14 @@ "_generator": { "name": "bicep", "version": "0.25.53.49325", - "templateHash": "2145880658446193205" + "templateHash": "8317058180807592714" }, - "description": "Creates a dashboard for an Application Insights instance." + "description": "Creates an Azure Cosmos DB for MongoDB account." }, "parameters": { "name": { "type": "string" }, - "applicationInsightsName": { - "type": "string" - }, "location": { "type": "string", "defaultValue": "[resourceGroup().location]" @@ -2990,1265 +2321,278 @@ "tags": { "type": "object", "defaultValue": {} + }, + "keyVaultName": { + "type": "string" + }, + "connectionStringKey": { + "type": "string", + "defaultValue": "AZURE-COSMOS-CONNECTION-STRING" } }, "resources": [ { - "type": "Microsoft.Portal/dashboards", - "apiVersion": "2020-09-01-preview", - "name": "[parameters('name')]", - "location": "[parameters('location')]", - "tags": "[parameters('tags')]", + "type": "Microsoft.Resources/deployments", + "apiVersion": "2022-09-01", + "name": "cosmos-account", "properties": { - "lenses": [ - { - "order": 0, - "parts": [ - { - "position": { - "x": 0, - "y": 0, - "colSpan": 2, - "rowSpan": 1 - }, - "metadata": { - "inputs": [ - { - "name": "id", - "value": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]" - }, - { - "name": "Version", - "value": "1.0" - } - ], - "type": "Extension/AppInsightsExtension/PartType/AspNetOverviewPinnedPart", - "asset": { - "idInputName": "id", - "type": "ApplicationInsights" - }, - "defaultMenuItemId": "overview" - } - }, - { - "position": { - "x": 2, - "y": 0, - "colSpan": 1, - "rowSpan": 1 - }, - "metadata": { - "inputs": [ - { - "name": "ComponentId", - "value": { - "Name": "[parameters('applicationInsightsName')]", - "SubscriptionId": "[subscription().subscriptionId]", - "ResourceGroup": "[resourceGroup().name]" - } - }, - { - "name": "Version", - "value": "1.0" - } - ], - "type": "Extension/AppInsightsExtension/PartType/ProactiveDetectionAsyncPart", - "asset": { - "idInputName": "ComponentId", - "type": "ApplicationInsights" - }, - "defaultMenuItemId": "ProactiveDetection" - } - }, - { - "position": { - "x": 3, - "y": 0, - "colSpan": 1, - "rowSpan": 1 - }, - "metadata": { - "inputs": [ - { - "name": "ComponentId", - "value": { - "Name": "[parameters('applicationInsightsName')]", - "SubscriptionId": "[subscription().subscriptionId]", - "ResourceGroup": "[resourceGroup().name]" - } - }, - { - "name": "ResourceId", - "value": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]" - } - ], - "type": "Extension/AppInsightsExtension/PartType/QuickPulseButtonSmallPart", - "asset": { - "idInputName": "ComponentId", - "type": "ApplicationInsights" - } - } - }, - { - "position": { - "x": 4, - "y": 0, - "colSpan": 1, - "rowSpan": 1 - }, - "metadata": { - "inputs": [ - { - "name": "ComponentId", - "value": { - "Name": "[parameters('applicationInsightsName')]", - "SubscriptionId": "[subscription().subscriptionId]", - "ResourceGroup": "[resourceGroup().name]" - } - }, - { - "name": "TimeContext", - "value": { - "durationMs": 86400000, - "endTime": null, - "createdTime": "2018-05-04T01:20:33.345Z", - "isInitialTime": true, - "grain": 1, - "useDashboardTimeRange": false - } - }, - { - "name": "Version", - "value": "1.0" - } - ], - "type": "Extension/AppInsightsExtension/PartType/AvailabilityNavButtonPart", - "asset": { - "idInputName": "ComponentId", - "type": "ApplicationInsights" - } - } - }, - { - "position": { - "x": 5, - "y": 0, - "colSpan": 1, - "rowSpan": 1 - }, - "metadata": { - "inputs": [ - { - "name": "ComponentId", - "value": { - "Name": "[parameters('applicationInsightsName')]", - "SubscriptionId": "[subscription().subscriptionId]", - "ResourceGroup": "[resourceGroup().name]" - } - }, - { - "name": "TimeContext", - "value": { - "durationMs": 86400000, - "endTime": null, - "createdTime": "2018-05-08T18:47:35.237Z", - "isInitialTime": true, - "grain": 1, - "useDashboardTimeRange": false - } - }, - { - "name": "ConfigurationId", - "value": "78ce933e-e864-4b05-a27b-71fd55a6afad" - } - ], - "type": "Extension/AppInsightsExtension/PartType/AppMapButtonPart", - "asset": { - "idInputName": "ComponentId", - "type": "ApplicationInsights" - } - } - }, - { - "position": { - "x": 0, - "y": 1, - "colSpan": 3, - "rowSpan": 1 - }, - "metadata": { - "inputs": [], - "type": "Extension/HubsExtension/PartType/MarkdownPart", - "settings": { - "content": { - "settings": { - "content": "# Usage", - "title": "", - "subtitle": "" - } - } - } - } - }, - { - "position": { - "x": 3, - "y": 1, - "colSpan": 1, - "rowSpan": 1 - }, - "metadata": { - "inputs": [ - { - "name": "ComponentId", - "value": { - "Name": "[parameters('applicationInsightsName')]", - "SubscriptionId": "[subscription().subscriptionId]", - "ResourceGroup": "[resourceGroup().name]" - } - }, - { - "name": "TimeContext", - "value": { - "durationMs": 86400000, - "endTime": null, - "createdTime": "2018-05-04T01:22:35.782Z", - "isInitialTime": true, - "grain": 1, - "useDashboardTimeRange": false - } - } - ], - "type": "Extension/AppInsightsExtension/PartType/UsageUsersOverviewPart", - "asset": { - "idInputName": "ComponentId", - "type": "ApplicationInsights" - } - } - }, - { - "position": { - "x": 4, - "y": 1, - "colSpan": 3, - "rowSpan": 1 - }, - "metadata": { - "inputs": [], - "type": "Extension/HubsExtension/PartType/MarkdownPart", - "settings": { - "content": { - "settings": { - "content": "# Reliability", - "title": "", - "subtitle": "" - } - } - } - } - }, - { - "position": { - "x": 7, - "y": 1, - "colSpan": 1, - "rowSpan": 1 - }, - "metadata": { - "inputs": [ - { - "name": "ResourceId", - "value": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]" - }, - { - "name": "DataModel", - "value": { - "version": "1.0.0", - "timeContext": { - "durationMs": 86400000, - "createdTime": "2018-05-04T23:42:40.072Z", - "isInitialTime": false, - "grain": 1, - "useDashboardTimeRange": false - } - }, - "isOptional": true - }, - { - "name": "ConfigurationId", - "value": "8a02f7bf-ac0f-40e1-afe9-f0e72cfee77f", - "isOptional": true - } - ], - "type": "Extension/AppInsightsExtension/PartType/CuratedBladeFailuresPinnedPart", - "isAdapter": true, - "asset": { - "idInputName": "ResourceId", - "type": "ApplicationInsights" - }, - "defaultMenuItemId": "failures" - } - }, - { - "position": { - "x": 8, - "y": 1, - "colSpan": 3, - "rowSpan": 1 + "expressionEvaluationOptions": { + "scope": "inner" + }, + "mode": "Incremental", + "parameters": { + "name": { + "value": "[parameters('name')]" + }, + "location": { + "value": "[parameters('location')]" + }, + "connectionStringKey": { + "value": "[parameters('connectionStringKey')]" + }, + "keyVaultName": { + "value": "[parameters('keyVaultName')]" + }, + "kind": { + "value": "MongoDB" + }, + "tags": { + "value": "[parameters('tags')]" + } + }, + "template": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "metadata": { + "_generator": { + "name": "bicep", + "version": "0.25.53.49325", + "templateHash": "13614361263700788271" + }, + "description": "Creates an Azure Cosmos DB account." + }, + "parameters": { + "name": { + "type": "string" + }, + "location": { + "type": "string", + "defaultValue": "[resourceGroup().location]" + }, + "tags": { + "type": "object", + "defaultValue": {} + }, + "connectionStringKey": { + "type": "string", + "defaultValue": "AZURE-COSMOS-CONNECTION-STRING" + }, + "keyVaultName": { + "type": "string" + }, + "kind": { + "type": "string", + "allowedValues": [ + "GlobalDocumentDB", + "MongoDB", + "Parse" + ] + } + }, + "resources": [ + { + "type": "Microsoft.DocumentDB/databaseAccounts", + "apiVersion": "2022-08-15", + "name": "[parameters('name')]", + "kind": "[parameters('kind')]", + "location": "[parameters('location')]", + "tags": "[parameters('tags')]", + "properties": { + "consistencyPolicy": { + "defaultConsistencyLevel": "Session" }, - "metadata": { - "inputs": [], - "type": "Extension/HubsExtension/PartType/MarkdownPart", - "settings": { - "content": { - "settings": { - "content": "# Responsiveness\r\n", - "title": "", - "subtitle": "" - } - } + "locations": [ + { + "locationName": "[parameters('location')]", + "failoverPriority": 0, + "isZoneRedundant": false } - } - }, - { - "position": { - "x": 11, - "y": 1, - "colSpan": 1, - "rowSpan": 1 - }, - "metadata": { - "inputs": [ - { - "name": "ResourceId", - "value": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]" - }, - { - "name": "DataModel", - "value": { - "version": "1.0.0", - "timeContext": { - "durationMs": 86400000, - "createdTime": "2018-05-04T23:43:37.804Z", - "isInitialTime": false, - "grain": 1, - "useDashboardTimeRange": false - } - }, - "isOptional": true - }, - { - "name": "ConfigurationId", - "value": "2a8ede4f-2bee-4b9c-aed9-2db0e8a01865", - "isOptional": true - } - ], - "type": "Extension/AppInsightsExtension/PartType/CuratedBladePerformancePinnedPart", - "isAdapter": true, - "asset": { - "idInputName": "ResourceId", - "type": "ApplicationInsights" - }, - "defaultMenuItemId": "performance" - } - }, - { - "position": { - "x": 12, - "y": 1, - "colSpan": 3, - "rowSpan": 1 - }, - "metadata": { - "inputs": [], - "type": "Extension/HubsExtension/PartType/MarkdownPart", - "settings": { - "content": { - "settings": { - "content": "# Browser", - "title": "", - "subtitle": "" - } - } + ], + "databaseAccountOfferType": "Standard", + "enableAutomaticFailover": false, + "enableMultipleWriteLocations": false, + "apiProperties": "[if(equals(parameters('kind'), 'MongoDB'), createObject('serverVersion', '4.2'), createObject())]", + "capabilities": [ + { + "name": "EnableServerless" } - } - }, - { - "position": { - "x": 15, - "y": 1, - "colSpan": 1, - "rowSpan": 1 - }, - "metadata": { - "inputs": [ - { - "name": "ComponentId", - "value": { - "Name": "[parameters('applicationInsightsName')]", - "SubscriptionId": "[subscription().subscriptionId]", - "ResourceGroup": "[resourceGroup().name]" - } - }, - { - "name": "MetricsExplorerJsonDefinitionId", - "value": "BrowserPerformanceTimelineMetrics" - }, - { - "name": "TimeContext", - "value": { - "durationMs": 86400000, - "createdTime": "2018-05-08T12:16:27.534Z", - "isInitialTime": false, - "grain": 1, - "useDashboardTimeRange": false - } - }, - { - "name": "CurrentFilter", - "value": { - "eventTypes": [ - 4, - 1, - 3, - 5, - 2, - 6, - 13 - ], - "typeFacets": {}, - "isPermissive": false - } - }, - { - "name": "id", - "value": { - "Name": "[parameters('applicationInsightsName')]", - "SubscriptionId": "[subscription().subscriptionId]", - "ResourceGroup": "[resourceGroup().name]" - } - }, - { - "name": "Version", - "value": "1.0" - } - ], - "type": "Extension/AppInsightsExtension/PartType/MetricsExplorerBladePinnedPart", - "asset": { - "idInputName": "ComponentId", - "type": "ApplicationInsights" - }, - "defaultMenuItemId": "browser" - } - }, - { - "position": { - "x": 0, - "y": 2, - "colSpan": 4, - "rowSpan": 3 - }, - "metadata": { - "inputs": [ - { - "name": "options", - "value": { - "chart": { - "metrics": [ - { - "resourceMetadata": { - "id": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]" - }, - "name": "sessions/count", - "aggregationType": 5, - "namespace": "microsoft.insights/components/kusto", - "metricVisualization": { - "displayName": "Sessions", - "color": "#47BDF5" - } - }, - { - "resourceMetadata": { - "id": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]" - }, - "name": "users/count", - "aggregationType": 5, - "namespace": "microsoft.insights/components/kusto", - "metricVisualization": { - "displayName": "Users", - "color": "#7E58FF" - } - } - ], - "title": "Unique sessions and users", - "visualization": { - "chartType": 2, - "legendVisualization": { - "isVisible": true, - "position": 2, - "hideSubtitle": false - }, - "axisVisualization": { - "x": { - "isVisible": true, - "axisType": 2 - }, - "y": { - "isVisible": true, - "axisType": 1 - } - } - }, - "openBladeOnClick": { - "openBlade": true, - "destinationBlade": { - "extensionName": "HubsExtension", - "bladeName": "ResourceMenuBlade", - "parameters": { - "id": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]", - "menuid": "segmentationUsers" - } - } - } - } - } - }, - { - "name": "sharedTimeRange", - "isOptional": true - } - ], - "type": "Extension/HubsExtension/PartType/MonitorChartPart", - "settings": {} - } - }, - { - "position": { - "x": 4, - "y": 2, - "colSpan": 4, - "rowSpan": 3 - }, - "metadata": { - "inputs": [ - { - "name": "options", - "value": { - "chart": { - "metrics": [ - { - "resourceMetadata": { - "id": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]" - }, - "name": "requests/failed", - "aggregationType": 7, - "namespace": "microsoft.insights/components", - "metricVisualization": { - "displayName": "Failed requests", - "color": "#EC008C" - } - } - ], - "title": "Failed requests", - "visualization": { - "chartType": 3, - "legendVisualization": { - "isVisible": true, - "position": 2, - "hideSubtitle": false - }, - "axisVisualization": { - "x": { - "isVisible": true, - "axisType": 2 - }, - "y": { - "isVisible": true, - "axisType": 1 - } - } - }, - "openBladeOnClick": { - "openBlade": true, - "destinationBlade": { - "extensionName": "HubsExtension", - "bladeName": "ResourceMenuBlade", - "parameters": { - "id": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]", - "menuid": "failures" - } - } - } - } - } - }, - { - "name": "sharedTimeRange", - "isOptional": true - } - ], - "type": "Extension/HubsExtension/PartType/MonitorChartPart", - "settings": {} - } - }, - { - "position": { - "x": 8, - "y": 2, - "colSpan": 4, - "rowSpan": 3 - }, - "metadata": { - "inputs": [ - { - "name": "options", - "value": { - "chart": { - "metrics": [ - { - "resourceMetadata": { - "id": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]" - }, - "name": "requests/duration", - "aggregationType": 4, - "namespace": "microsoft.insights/components", - "metricVisualization": { - "displayName": "Server response time", - "color": "#00BCF2" - } - } - ], - "title": "Server response time", - "visualization": { - "chartType": 2, - "legendVisualization": { - "isVisible": true, - "position": 2, - "hideSubtitle": false - }, - "axisVisualization": { - "x": { - "isVisible": true, - "axisType": 2 - }, - "y": { - "isVisible": true, - "axisType": 1 - } - } - }, - "openBladeOnClick": { - "openBlade": true, - "destinationBlade": { - "extensionName": "HubsExtension", - "bladeName": "ResourceMenuBlade", - "parameters": { - "id": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]", - "menuid": "performance" - } - } - } - } - } - }, - { - "name": "sharedTimeRange", - "isOptional": true - } - ], - "type": "Extension/HubsExtension/PartType/MonitorChartPart", - "settings": {} - } - }, - { - "position": { - "x": 12, - "y": 2, - "colSpan": 4, - "rowSpan": 3 - }, - "metadata": { - "inputs": [ - { - "name": "options", - "value": { - "chart": { - "metrics": [ - { - "resourceMetadata": { - "id": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]" - }, - "name": "browserTimings/networkDuration", - "aggregationType": 4, - "namespace": "microsoft.insights/components", - "metricVisualization": { - "displayName": "Page load network connect time", - "color": "#7E58FF" - } - }, - { - "resourceMetadata": { - "id": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]" - }, - "name": "browserTimings/processingDuration", - "aggregationType": 4, - "namespace": "microsoft.insights/components", - "metricVisualization": { - "displayName": "Client processing time", - "color": "#44F1C8" - } - }, - { - "resourceMetadata": { - "id": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]" - }, - "name": "browserTimings/sendDuration", - "aggregationType": 4, - "namespace": "microsoft.insights/components", - "metricVisualization": { - "displayName": "Send request time", - "color": "#EB9371" - } - }, - { - "resourceMetadata": { - "id": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]" - }, - "name": "browserTimings/receiveDuration", - "aggregationType": 4, - "namespace": "microsoft.insights/components", - "metricVisualization": { - "displayName": "Receiving response time", - "color": "#0672F1" - } - } - ], - "title": "Average page load time breakdown", - "visualization": { - "chartType": 3, - "legendVisualization": { - "isVisible": true, - "position": 2, - "hideSubtitle": false - }, - "axisVisualization": { - "x": { - "isVisible": true, - "axisType": 2 - }, - "y": { - "isVisible": true, - "axisType": 1 - } - } - } - } - } - }, - { - "name": "sharedTimeRange", - "isOptional": true - } - ], - "type": "Extension/HubsExtension/PartType/MonitorChartPart", - "settings": {} - } - }, - { - "position": { - "x": 0, - "y": 5, - "colSpan": 4, - "rowSpan": 3 - }, - "metadata": { - "inputs": [ - { - "name": "options", - "value": { - "chart": { - "metrics": [ - { - "resourceMetadata": { - "id": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]" - }, - "name": "availabilityResults/availabilityPercentage", - "aggregationType": 4, - "namespace": "microsoft.insights/components", - "metricVisualization": { - "displayName": "Availability", - "color": "#47BDF5" - } - } - ], - "title": "Average availability", - "visualization": { - "chartType": 3, - "legendVisualization": { - "isVisible": true, - "position": 2, - "hideSubtitle": false - }, - "axisVisualization": { - "x": { - "isVisible": true, - "axisType": 2 - }, - "y": { - "isVisible": true, - "axisType": 1 - } - } - }, - "openBladeOnClick": { - "openBlade": true, - "destinationBlade": { - "extensionName": "HubsExtension", - "bladeName": "ResourceMenuBlade", - "parameters": { - "id": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]", - "menuid": "availability" - } - } - } - } - } - }, - { - "name": "sharedTimeRange", - "isOptional": true - } - ], - "type": "Extension/HubsExtension/PartType/MonitorChartPart", - "settings": {} - } - }, - { - "position": { - "x": 4, - "y": 5, - "colSpan": 4, - "rowSpan": 3 - }, - "metadata": { - "inputs": [ - { - "name": "options", - "value": { - "chart": { - "metrics": [ - { - "resourceMetadata": { - "id": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]" - }, - "name": "exceptions/server", - "aggregationType": 7, - "namespace": "microsoft.insights/components", - "metricVisualization": { - "displayName": "Server exceptions", - "color": "#47BDF5" - } - }, - { - "resourceMetadata": { - "id": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]" - }, - "name": "dependencies/failed", - "aggregationType": 7, - "namespace": "microsoft.insights/components", - "metricVisualization": { - "displayName": "Dependency failures", - "color": "#7E58FF" - } - } - ], - "title": "Server exceptions and Dependency failures", - "visualization": { - "chartType": 2, - "legendVisualization": { - "isVisible": true, - "position": 2, - "hideSubtitle": false - }, - "axisVisualization": { - "x": { - "isVisible": true, - "axisType": 2 - }, - "y": { - "isVisible": true, - "axisType": 1 - } - } - } - } - } - }, - { - "name": "sharedTimeRange", - "isOptional": true - } - ], - "type": "Extension/HubsExtension/PartType/MonitorChartPart", - "settings": {} - } - }, - { - "position": { - "x": 8, - "y": 5, - "colSpan": 4, - "rowSpan": 3 - }, - "metadata": { - "inputs": [ - { - "name": "options", - "value": { - "chart": { - "metrics": [ - { - "resourceMetadata": { - "id": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]" - }, - "name": "performanceCounters/processorCpuPercentage", - "aggregationType": 4, - "namespace": "microsoft.insights/components", - "metricVisualization": { - "displayName": "Processor time", - "color": "#47BDF5" - } - }, - { - "resourceMetadata": { - "id": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]" - }, - "name": "performanceCounters/processCpuPercentage", - "aggregationType": 4, - "namespace": "microsoft.insights/components", - "metricVisualization": { - "displayName": "Process CPU", - "color": "#7E58FF" - } - } - ], - "title": "Average processor and process CPU utilization", - "visualization": { - "chartType": 2, - "legendVisualization": { - "isVisible": true, - "position": 2, - "hideSubtitle": false - }, - "axisVisualization": { - "x": { - "isVisible": true, - "axisType": 2 - }, - "y": { - "isVisible": true, - "axisType": 1 - } - } - } - } - } - }, - { - "name": "sharedTimeRange", - "isOptional": true - } - ], - "type": "Extension/HubsExtension/PartType/MonitorChartPart", - "settings": {} - } - }, - { - "position": { - "x": 12, - "y": 5, - "colSpan": 4, - "rowSpan": 3 - }, - "metadata": { - "inputs": [ - { - "name": "options", - "value": { - "chart": { - "metrics": [ - { - "resourceMetadata": { - "id": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]" - }, - "name": "exceptions/browser", - "aggregationType": 7, - "namespace": "microsoft.insights/components", - "metricVisualization": { - "displayName": "Browser exceptions", - "color": "#47BDF5" - } - } - ], - "title": "Browser exceptions", - "visualization": { - "chartType": 2, - "legendVisualization": { - "isVisible": true, - "position": 2, - "hideSubtitle": false - }, - "axisVisualization": { - "x": { - "isVisible": true, - "axisType": 2 - }, - "y": { - "isVisible": true, - "axisType": 1 - } - } - } - } - } - }, - { - "name": "sharedTimeRange", - "isOptional": true - } - ], - "type": "Extension/HubsExtension/PartType/MonitorChartPart", - "settings": {} - } - }, - { - "position": { - "x": 0, - "y": 8, - "colSpan": 4, - "rowSpan": 3 - }, - "metadata": { - "inputs": [ - { - "name": "options", - "value": { - "chart": { - "metrics": [ - { - "resourceMetadata": { - "id": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]" - }, - "name": "availabilityResults/count", - "aggregationType": 7, - "namespace": "microsoft.insights/components", - "metricVisualization": { - "displayName": "Availability test results count", - "color": "#47BDF5" - } - } - ], - "title": "Availability test results count", - "visualization": { - "chartType": 2, - "legendVisualization": { - "isVisible": true, - "position": 2, - "hideSubtitle": false - }, - "axisVisualization": { - "x": { - "isVisible": true, - "axisType": 2 - }, - "y": { - "isVisible": true, - "axisType": 1 - } - } - } - } - } - }, - { - "name": "sharedTimeRange", - "isOptional": true - } - ], - "type": "Extension/HubsExtension/PartType/MonitorChartPart", - "settings": {} - } - }, - { - "position": { - "x": 4, - "y": 8, - "colSpan": 4, - "rowSpan": 3 - }, - "metadata": { - "inputs": [ - { - "name": "options", - "value": { - "chart": { - "metrics": [ - { - "resourceMetadata": { - "id": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]" - }, - "name": "performanceCounters/processIOBytesPerSecond", - "aggregationType": 4, - "namespace": "microsoft.insights/components", - "metricVisualization": { - "displayName": "Process IO rate", - "color": "#47BDF5" - } - } - ], - "title": "Average process I/O rate", - "visualization": { - "chartType": 2, - "legendVisualization": { - "isVisible": true, - "position": 2, - "hideSubtitle": false - }, - "axisVisualization": { - "x": { - "isVisible": true, - "axisType": 2 - }, - "y": { - "isVisible": true, - "axisType": 1 - } - } - } - } - } - }, - { - "name": "sharedTimeRange", - "isOptional": true - } - ], - "type": "Extension/HubsExtension/PartType/MonitorChartPart", - "settings": {} - } - }, - { - "position": { - "x": 8, - "y": 8, - "colSpan": 4, - "rowSpan": 3 - }, - "metadata": { - "inputs": [ - { - "name": "options", - "value": { - "chart": { - "metrics": [ - { - "resourceMetadata": { - "id": "[format('/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Insights/components/{2}', subscription().subscriptionId, resourceGroup().name, parameters('applicationInsightsName'))]" - }, - "name": "performanceCounters/memoryAvailableBytes", - "aggregationType": 4, - "namespace": "microsoft.insights/components", - "metricVisualization": { - "displayName": "Available memory", - "color": "#47BDF5" - } - } - ], - "title": "Average available memory", - "visualization": { - "chartType": 2, - "legendVisualization": { - "isVisible": true, - "position": 2, - "hideSubtitle": false - }, - "axisVisualization": { - "x": { - "isVisible": true, - "axisType": 2 - }, - "y": { - "isVisible": true, - "axisType": 1 - } - } - } - } - } - }, - { - "name": "sharedTimeRange", - "isOptional": true - } - ], - "type": "Extension/HubsExtension/PartType/MonitorChartPart", - "settings": {} - } + ] } - ] + }, + { + "type": "Microsoft.KeyVault/vaults/secrets", + "apiVersion": "2022-07-01", + "name": "[format('{0}/{1}', parameters('keyVaultName'), parameters('connectionStringKey'))]", + "properties": { + "value": "[listConnectionStrings(resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('name')), '2022-08-15').connectionStrings[0].connectionString]" + }, + "dependsOn": [ + "[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('name'))]" + ] + } + ], + "outputs": { + "connectionStringKey": { + "type": "string", + "value": "[parameters('connectionStringKey')]" + }, + "endpoint": { + "type": "string", + "value": "[reference(resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('name')), '2022-08-15').documentEndpoint]" + }, + "id": { + "type": "string", + "value": "[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('name'))]" + }, + "name": { + "type": "string", + "value": "[parameters('name')]" + } } - ] + } } } - ] + ], + "outputs": { + "connectionStringKey": { + "type": "string", + "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos-account'), '2022-09-01').outputs.connectionStringKey.value]" + }, + "endpoint": { + "type": "string", + "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos-account'), '2022-09-01').outputs.endpoint.value]" + }, + "id": { + "type": "string", + "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos-account'), '2022-09-01').outputs.id.value]" + } + } } - }, - "dependsOn": [ - "[resourceId('Microsoft.Insights/components', parameters('name'))]" - ] + } } ], "outputs": { - "connectionString": { + "connectionStringKey": { "type": "string", - "value": "[reference(resourceId('Microsoft.Insights/components', parameters('name')), '2020-02-02').ConnectionString]" + "value": "[parameters('connectionStringKey')]" }, - "instrumentationKey": { + "databaseName": { "type": "string", - "value": "[reference(resourceId('Microsoft.Insights/components', parameters('name')), '2020-02-02').InstrumentationKey]" + "value": "[parameters('databaseName')]" }, - "name": { + "endpoint": { "type": "string", - "value": "[parameters('name')]" + "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos-mongo-account'), '2022-09-01').outputs.endpoint.value]" } } } - }, - "dependsOn": [ - "[resourceId('Microsoft.Resources/deployments', 'loganalytics')]" - ] + } } ], "outputs": { - "applicationInsightsConnectionString": { + "connectionStringKey": { "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'applicationinsights'), '2022-09-01').outputs.connectionString.value]" + "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos-mongo'), '2022-09-01').outputs.connectionStringKey.value]" }, - "applicationInsightsInstrumentationKey": { + "databaseName": { "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'applicationinsights'), '2022-09-01').outputs.instrumentationKey.value]" + "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos-mongo'), '2022-09-01').outputs.databaseName.value]" }, - "applicationInsightsName": { + "endpoint": { + "type": "string", + "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos-mongo'), '2022-09-01').outputs.endpoint.value]" + } + } + } + }, + "dependsOn": [ + "[resourceId('Microsoft.Resources/deployments', 'keyvault')]" + ] + }, + { + "type": "Microsoft.Resources/deployments", + "apiVersion": "2022-09-01", + "name": "keyvault", + "properties": { + "expressionEvaluationOptions": { + "scope": "inner" + }, + "mode": "Incremental", + "parameters": { + "name": "[if(not(empty(parameters('keyVaultName'))), createObject('value', parameters('keyVaultName')), createObject('value', format('{0}{1}', variables('abbrs').keyVaultVaults, variables('resourceToken'))))]", + "location": { + "value": "[parameters('location')]" + }, + "tags": { + "value": "[variables('tags')]" + }, + "principalId": { + "value": "[parameters('principalId')]" + } + }, + "template": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "metadata": { + "_generator": { + "name": "bicep", + "version": "0.25.53.49325", + "templateHash": "17948623451174129396" + }, + "description": "Creates an Azure Key Vault." + }, + "parameters": { + "name": { + "type": "string" + }, + "location": { "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'applicationinsights'), '2022-09-01').outputs.name.value]" + "defaultValue": "[resourceGroup().location]" + }, + "tags": { + "type": "object", + "defaultValue": {} }, - "logAnalyticsWorkspaceId": { + "principalId": { + "type": "string", + "defaultValue": "" + } + }, + "resources": [ + { + "type": "Microsoft.KeyVault/vaults", + "apiVersion": "2022-07-01", + "name": "[parameters('name')]", + "location": "[parameters('location')]", + "tags": "[parameters('tags')]", + "properties": { + "tenantId": "[subscription().tenantId]", + "sku": { + "family": "A", + "name": "standard" + }, + "accessPolicies": "[if(not(empty(parameters('principalId'))), createArray(createObject('objectId', parameters('principalId'), 'permissions', createObject('secrets', createArray('get', 'list')), 'tenantId', subscription().tenantId)), createArray())]" + } + } + ], + "outputs": { + "endpoint": { "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'loganalytics'), '2022-09-01').outputs.id.value]" + "value": "[reference(resourceId('Microsoft.KeyVault/vaults', parameters('name')), '2022-07-01').vaultUri]" }, - "logAnalyticsWorkspaceName": { + "name": { "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'loganalytics'), '2022-09-01').outputs.name.value]" + "value": "[parameters('name')]" } } } @@ -4273,7 +2617,7 @@ "value": "[variables('tags')]" }, "applicationInsightsName": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'monitoring'), '2022-09-01').outputs.applicationInsightsName.value]" + "value": "[parameters('applicationInsightsName')]" } }, "template": { @@ -4390,10 +2734,7 @@ } } } - }, - "dependsOn": [ - "[resourceId('Microsoft.Resources/deployments', 'monitoring')]" - ] + } }, { "condition": "[parameters('useAPIM')]", @@ -4609,27 +2950,15 @@ }, "API_CORS_ACA_URL": { "type": "string", - "value": "[format('https://{0}.{1}', variables('apiContainerAppNameOrDefault'), reference(resourceId('Microsoft.Resources/deployments', 'container-apps'), '2022-09-01').outputs.defaultDomain.value)]" - }, - "APPLICATIONINSIGHTS_CONNECTION_STRING": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'monitoring'), '2022-09-01').outputs.applicationInsightsConnectionString.value]" - }, - "APPLICATIONINSIGHTS_NAME": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'monitoring'), '2022-09-01').outputs.applicationInsightsName.value]" - }, - "AZURE_CONTAINER_ENVIRONMENT_NAME": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'container-apps'), '2022-09-01').outputs.environmentName.value]" + "value": "[parameters('corsAcaUrl')]" }, "AZURE_CONTAINER_REGISTRY_ENDPOINT": { "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'container-apps'), '2022-09-01').outputs.registryLoginServer.value]" + "value": "[reference(resourceId('Microsoft.Resources/deployments', 'app-container-registry'), '2022-09-01').outputs.loginServer.value]" }, "AZURE_CONTAINER_REGISTRY_NAME": { "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'container-apps'), '2022-09-01').outputs.registryName.value]" + "value": "[reference(resourceId('Microsoft.Resources/deployments', 'app-container-registry'), '2022-09-01').outputs.name.value]" }, "AZURE_KEY_VAULT_ENDPOINT": { "type": "string", @@ -4651,10 +2980,6 @@ "type": "string", "value": "[if(parameters('useAPIM'), reference(resourceId('Microsoft.Resources/deployments', 'apim-api-deployment'), '2022-09-01').outputs.SERVICE_API_URI.value, reference(resourceId('Microsoft.Resources/deployments', 'api'), '2022-09-01').outputs.SERVICE_API_URI.value)]" }, - "REACT_APP_APPLICATIONINSIGHTS_CONNECTION_STRING": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'monitoring'), '2022-09-01').outputs.applicationInsightsConnectionString.value]" - }, "REACT_APP_WEB_BASE_URL": { "type": "string", "value": "[reference(resourceId('Microsoft.Resources/deployments', 'web'), '2022-09-01').outputs.SERVICE_WEB_URI.value]" @@ -4674,6 +2999,14 @@ "SERVICE_API_ENDPOINTS": { "type": "array", "value": "[if(parameters('useAPIM'), createArray(reference(resourceId('Microsoft.Resources/deployments', 'apim-api-deployment'), '2022-09-01').outputs.SERVICE_API_URI.value, reference(resourceId('Microsoft.Resources/deployments', 'api'), '2022-09-01').outputs.SERVICE_API_URI.value), createArray())]" + }, + "registryLoginServer": { + "type": "string", + "value": "[reference(resourceId('Microsoft.Resources/deployments', 'app-container-registry'), '2022-09-01').outputs.loginServer.value]" + }, + "registryName": { + "type": "string", + "value": "[reference(resourceId('Microsoft.Resources/deployments', 'app-container-registry'), '2022-09-01').outputs.name.value]" } } } \ No newline at end of file diff --git a/Environments/Todo-Shared-ACA/azuredeploy.json b/Environments/Todo-Shared-ACA/azuredeploy.json index 65c1d9f7..94f1cb0a 100644 --- a/Environments/Todo-Shared-ACA/azuredeploy.json +++ b/Environments/Todo-Shared-ACA/azuredeploy.json @@ -5,7 +5,7 @@ "_generator": { "name": "bicep", "version": "0.25.53.49325", - "templateHash": "5915759848307494038" + "templateHash": "7010794115259852587" } }, "parameters": { @@ -25,10 +25,6 @@ "description": "Primary location for all resources" } }, - "apiContainerAppName": { - "type": "string", - "defaultValue": "" - }, "applicationInsightsDashboardName": { "type": "string", "defaultValue": "" @@ -41,62 +37,9 @@ "type": "string", "defaultValue": "" }, - "containerRegistryName": { - "type": "string", - "defaultValue": "" - }, - "cosmosAccountName": { - "type": "string", - "defaultValue": "" - }, - "cosmosDatabaseName": { - "type": "string", - "defaultValue": "" - }, - "keyVaultName": { - "type": "string", - "defaultValue": "" - }, "logAnalyticsName": { "type": "string", "defaultValue": "" - }, - "webContainerAppName": { - "type": "string", - "defaultValue": "" - }, - "apimServiceName": { - "type": "string", - "defaultValue": "" - }, - "apiAppExists": { - "type": "bool", - "defaultValue": false - }, - "webAppExists": { - "type": "bool", - "defaultValue": false - }, - "useAPIM": { - "type": "bool", - "defaultValue": false, - "metadata": { - "description": "Flag to use Azure API Management to mediate the calls between the Web frontend and the backend API" - } - }, - "principalId": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "Id of the user or app to assign application roles" - } - }, - "webApiBaseUrl": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The base URL used by the web service for sending API requests" - } } }, "variables": { @@ -264,10 +207,6 @@ "value": "[variables('tags')]" }, "containerAppsEnvironmentName": "[if(not(empty(parameters('containerAppsEnvironmentName'))), createObject('value', parameters('containerAppsEnvironmentName')), createObject('value', format('{0}{1}', variables('abbrs').appManagedEnvironments, variables('resourceToken'))))]", - "containerRegistryName": "[if(not(empty(parameters('containerRegistryName'))), createObject('value', parameters('containerRegistryName')), createObject('value', format('{0}{1}', variables('abbrs').containerRegistryRegistries, variables('resourceToken'))))]", - "containerRegistryAdminUserEnabled": { - "value": true - }, "logAnalyticsWorkspaceName": { "value": "[reference(resourceId('Microsoft.Resources/deployments', 'monitoring'), '2022-09-01').outputs.logAnalyticsWorkspaceName.value]" }, @@ -282,7 +221,7 @@ "_generator": { "name": "bicep", "version": "0.25.53.49325", - "templateHash": "14116108111976192358" + "templateHash": "10266908178814002202" }, "description": "Creates an Azure Container Registry and an Azure Container Apps environment." }, @@ -301,17 +240,6 @@ "containerAppsEnvironmentName": { "type": "string" }, - "containerRegistryName": { - "type": "string" - }, - "containerRegistryResourceGroupName": { - "type": "string", - "defaultValue": "" - }, - "containerRegistryAdminUserEnabled": { - "type": "bool", - "defaultValue": false - }, "logAnalyticsWorkspaceName": { "type": "string" }, @@ -380,2372 +308,73 @@ "daprEnabled": { "type": "bool", "defaultValue": false, - "metadata": { - "description": "Specifies if Dapr is enabled" - } - }, - "logAnalyticsWorkspaceName": { - "type": "string", - "metadata": { - "description": "Name of the Log Analytics workspace" - } - } - }, - "resources": [ - { - "type": "Microsoft.App/managedEnvironments", - "apiVersion": "2023-04-01-preview", - "name": "[parameters('name')]", - "location": "[parameters('location')]", - "tags": "[parameters('tags')]", - "properties": { - "appLogsConfiguration": { - "destination": "log-analytics", - "logAnalyticsConfiguration": { - "customerId": "[reference(resourceId('Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceName')), '2022-10-01').customerId]", - "sharedKey": "[listKeys(resourceId('Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceName')), '2022-10-01').primarySharedKey]" - } - }, - "daprAIInstrumentationKey": "[if(and(parameters('daprEnabled'), not(empty(parameters('applicationInsightsName')))), reference(resourceId('Microsoft.Insights/components', parameters('applicationInsightsName')), '2020-02-02').InstrumentationKey, '')]" - } - } - ], - "outputs": { - "defaultDomain": { - "type": "string", - "value": "[reference(resourceId('Microsoft.App/managedEnvironments', parameters('name')), '2023-04-01-preview').defaultDomain]" - }, - "id": { - "type": "string", - "value": "[resourceId('Microsoft.App/managedEnvironments', parameters('name'))]" - }, - "name": { - "type": "string", - "value": "[parameters('name')]" - } - } - } - } - }, - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "[format('{0}-container-registry', parameters('name'))]", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "name": { - "value": "[parameters('containerRegistryName')]" - }, - "location": { - "value": "[parameters('location')]" - }, - "adminUserEnabled": { - "value": "[parameters('containerRegistryAdminUserEnabled')]" - }, - "tags": { - "value": "[parameters('tags')]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "12834334744516280883" - }, - "description": "Creates an Azure Container Registry." - }, - "parameters": { - "name": { - "type": "string" - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]" - }, - "tags": { - "type": "object", - "defaultValue": {} - }, - "adminUserEnabled": { - "type": "bool", - "defaultValue": false, - "metadata": { - "description": "Indicates whether admin user is enabled" - } - }, - "anonymousPullEnabled": { - "type": "bool", - "defaultValue": false, - "metadata": { - "description": "Indicates whether anonymous pull is enabled" - } - }, - "dataEndpointEnabled": { - "type": "bool", - "defaultValue": false, - "metadata": { - "description": "Indicates whether data endpoint is enabled" - } - }, - "encryption": { - "type": "object", - "defaultValue": { - "status": "disabled" - }, - "metadata": { - "description": "Encryption settings" - } - }, - "networkRuleBypassOptions": { - "type": "string", - "defaultValue": "AzureServices", - "metadata": { - "description": "Options for bypassing network rules" - } - }, - "publicNetworkAccess": { - "type": "string", - "defaultValue": "Enabled", - "metadata": { - "description": "Public network access setting" - } - }, - "sku": { - "type": "object", - "defaultValue": { - "name": "Basic" - }, - "metadata": { - "description": "SKU settings" - } - }, - "zoneRedundancy": { - "type": "string", - "defaultValue": "Disabled", - "metadata": { - "description": "Zone redundancy setting" - } - }, - "workspaceId": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The log analytics workspace ID used for logging and monitoring" - } - } - }, - "resources": [ - { - "type": "Microsoft.ContainerRegistry/registries", - "apiVersion": "2022-02-01-preview", - "name": "[parameters('name')]", - "location": "[parameters('location')]", - "tags": "[parameters('tags')]", - "sku": "[parameters('sku')]", - "properties": { - "adminUserEnabled": "[parameters('adminUserEnabled')]", - "anonymousPullEnabled": "[parameters('anonymousPullEnabled')]", - "dataEndpointEnabled": "[parameters('dataEndpointEnabled')]", - "encryption": "[parameters('encryption')]", - "networkRuleBypassOptions": "[parameters('networkRuleBypassOptions')]", - "publicNetworkAccess": "[parameters('publicNetworkAccess')]", - "zoneRedundancy": "[parameters('zoneRedundancy')]" - } - }, - { - "condition": "[not(empty(parameters('workspaceId')))]", - "type": "Microsoft.Insights/diagnosticSettings", - "apiVersion": "2021-05-01-preview", - "scope": "[format('Microsoft.ContainerRegistry/registries/{0}', parameters('name'))]", - "name": "registry-diagnostics", - "properties": { - "workspaceId": "[parameters('workspaceId')]", - "logs": [ - { - "category": "ContainerRegistryRepositoryEvents", - "enabled": true - }, - { - "category": "ContainerRegistryLoginEvents", - "enabled": true - } - ], - "metrics": [ - { - "category": "AllMetrics", - "enabled": true, - "timeGrain": "PT1M" - } - ] - }, - "dependsOn": [ - "[resourceId('Microsoft.ContainerRegistry/registries', parameters('name'))]" - ] - } - ], - "outputs": { - "loginServer": { - "type": "string", - "value": "[reference(resourceId('Microsoft.ContainerRegistry/registries', parameters('name')), '2022-02-01-preview').loginServer]" - }, - "name": { - "type": "string", - "value": "[parameters('name')]" - } - } - } - } - } - ], - "outputs": { - "defaultDomain": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-apps-environment', parameters('name'))), '2022-09-01').outputs.defaultDomain.value]" - }, - "environmentName": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-apps-environment', parameters('name'))), '2022-09-01').outputs.name.value]" - }, - "environmentId": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-apps-environment', parameters('name'))), '2022-09-01').outputs.id.value]" - }, - "registryLoginServer": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-registry', parameters('name'))), '2022-09-01').outputs.loginServer.value]" - }, - "registryName": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-registry', parameters('name'))), '2022-09-01').outputs.name.value]" - } - } - } - }, - "dependsOn": [ - "[resourceId('Microsoft.Resources/deployments', 'monitoring')]" - ] - }, - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "web", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "name": "[if(not(empty(parameters('webContainerAppName'))), createObject('value', parameters('webContainerAppName')), createObject('value', format('{0}web-{1}', variables('abbrs').appContainerApps, variables('resourceToken'))))]", - "location": { - "value": "[parameters('location')]" - }, - "tags": { - "value": "[variables('tags')]" - }, - "identityName": { - "value": "[format('{0}web-{1}', variables('abbrs').managedIdentityUserAssignedIdentities, variables('resourceToken'))]" - }, - "apiBaseUrl": "[if(not(empty(parameters('webApiBaseUrl'))), createObject('value', parameters('webApiBaseUrl')), createObject('value', reference(resourceId('Microsoft.Resources/deployments', 'api'), '2022-09-01').outputs.SERVICE_API_URI.value))]", - "applicationInsightsName": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'monitoring'), '2022-09-01').outputs.applicationInsightsName.value]" - }, - "containerAppsEnvironmentName": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'container-apps'), '2022-09-01').outputs.environmentName.value]" - }, - "containerRegistryName": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'container-apps'), '2022-09-01').outputs.registryName.value]" - }, - "exists": { - "value": "[parameters('webAppExists')]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "5244656399300381833" - } - }, - "parameters": { - "name": { - "type": "string" - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]" - }, - "tags": { - "type": "object", - "defaultValue": {} - }, - "identityName": { - "type": "string" - }, - "apiBaseUrl": { - "type": "string" - }, - "applicationInsightsName": { - "type": "string" - }, - "containerAppsEnvironmentName": { - "type": "string" - }, - "containerRegistryName": { - "type": "string" - }, - "serviceName": { - "type": "string", - "defaultValue": "web" - }, - "exists": { - "type": "bool" - } - }, - "resources": [ - { - "type": "Microsoft.ManagedIdentity/userAssignedIdentities", - "apiVersion": "2023-01-31", - "name": "[parameters('identityName')]", - "location": "[parameters('location')]" - }, - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "[format('{0}-container-app', parameters('serviceName'))]", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "name": { - "value": "[parameters('name')]" - }, - "location": { - "value": "[parameters('location')]" - }, - "tags": { - "value": "[union(parameters('tags'), createObject('azd-service-name', parameters('serviceName')))]" - }, - "identityType": { - "value": "UserAssigned" - }, - "identityName": { - "value": "[parameters('identityName')]" - }, - "exists": { - "value": "[parameters('exists')]" - }, - "containerAppsEnvironmentName": { - "value": "[parameters('containerAppsEnvironmentName')]" - }, - "containerRegistryName": { - "value": "[parameters('containerRegistryName')]" - }, - "env": { - "value": [ - { - "name": "REACT_APP_APPLICATIONINSIGHTS_CONNECTION_STRING", - "value": "[reference(resourceId('Microsoft.Insights/components', parameters('applicationInsightsName')), '2020-02-02').ConnectionString]" - }, - { - "name": "REACT_APP_API_BASE_URL", - "value": "[parameters('apiBaseUrl')]" - }, - { - "name": "APPLICATIONINSIGHTS_CONNECTION_STRING", - "value": "[reference(resourceId('Microsoft.Insights/components', parameters('applicationInsightsName')), '2020-02-02').ConnectionString]" - } - ] - }, - "targetPort": { - "value": 80 - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "17242409915151931414" - }, - "description": "Creates or updates an existing Azure Container App." - }, - "parameters": { - "name": { - "type": "string" - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]" - }, - "tags": { - "type": "object", - "defaultValue": {} - }, - "containerAppsEnvironmentName": { - "type": "string", - "metadata": { - "description": "The environment name for the container apps" - } - }, - "containerCpuCoreCount": { - "type": "string", - "defaultValue": "0.5", - "metadata": { - "description": "The number of CPU cores allocated to a single container instance, e.g., 0.5" - } - }, - "containerMaxReplicas": { - "type": "int", - "defaultValue": 10, - "minValue": 1, - "metadata": { - "description": "The maximum number of replicas to run. Must be at least 1." - } - }, - "containerMemory": { - "type": "string", - "defaultValue": "1.0Gi", - "metadata": { - "description": "The amount of memory allocated to a single container instance, e.g., 1Gi" - } - }, - "containerMinReplicas": { - "type": "int", - "defaultValue": 1, - "minValue": 1, - "metadata": { - "description": "The minimum number of replicas to run. Must be at least 1." - } - }, - "containerName": { - "type": "string", - "defaultValue": "main", - "metadata": { - "description": "The name of the container" - } - }, - "containerRegistryName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the container registry" - } - }, - "daprAppProtocol": { - "type": "string", - "defaultValue": "http", - "allowedValues": [ - "http", - "grpc" - ], - "metadata": { - "description": "The protocol used by Dapr to connect to the app, e.g., HTTP or gRPC" - } - }, - "daprEnabled": { - "type": "bool", - "defaultValue": false, - "metadata": { - "description": "Enable or disable Dapr for the container app" - } - }, - "daprAppId": { - "type": "string", - "defaultValue": "[parameters('containerName')]", - "metadata": { - "description": "The Dapr app ID" - } - }, - "exists": { - "type": "bool", - "defaultValue": false, - "metadata": { - "description": "Specifies if the resource already exists" - } - }, - "ingressEnabled": { - "type": "bool", - "defaultValue": true, - "metadata": { - "description": "Specifies if Ingress is enabled for the container app" - } - }, - "identityType": { - "type": "string", - "defaultValue": "None", - "allowedValues": [ - "None", - "SystemAssigned", - "UserAssigned" - ], - "metadata": { - "description": "The type of identity for the resource" - } - }, - "identityName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the user-assigned identity" - } - }, - "imageName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the container image" - } - }, - "secrets": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "The secrets required for the container" - } - }, - "env": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "The environment variables for the container" - } - }, - "external": { - "type": "bool", - "defaultValue": true, - "metadata": { - "description": "Specifies if the resource ingress is exposed externally" - } - }, - "serviceBinds": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "The service binds associated with the container" - } - }, - "targetPort": { - "type": "int", - "defaultValue": 80, - "metadata": { - "description": "The target port for the container" - } - } - }, - "resources": [ - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "[format('{0}-update', deployment().name)]", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "name": { - "value": "[parameters('name')]" - }, - "location": { - "value": "[parameters('location')]" - }, - "tags": { - "value": "[parameters('tags')]" - }, - "identityType": { - "value": "[parameters('identityType')]" - }, - "identityName": { - "value": "[parameters('identityName')]" - }, - "ingressEnabled": { - "value": "[parameters('ingressEnabled')]" - }, - "containerName": { - "value": "[parameters('containerName')]" - }, - "containerAppsEnvironmentName": { - "value": "[parameters('containerAppsEnvironmentName')]" - }, - "containerRegistryName": { - "value": "[parameters('containerRegistryName')]" - }, - "containerCpuCoreCount": { - "value": "[parameters('containerCpuCoreCount')]" - }, - "containerMemory": { - "value": "[parameters('containerMemory')]" - }, - "containerMinReplicas": { - "value": "[parameters('containerMinReplicas')]" - }, - "containerMaxReplicas": { - "value": "[parameters('containerMaxReplicas')]" - }, - "daprEnabled": { - "value": "[parameters('daprEnabled')]" - }, - "daprAppId": { - "value": "[parameters('daprAppId')]" - }, - "daprAppProtocol": { - "value": "[parameters('daprAppProtocol')]" - }, - "secrets": { - "value": "[parameters('secrets')]" - }, - "external": { - "value": "[parameters('external')]" - }, - "env": { - "value": "[parameters('env')]" - }, - "imageName": "[if(not(empty(parameters('imageName'))), createObject('value', parameters('imageName')), if(parameters('exists'), createObject('value', reference(resourceId('Microsoft.App/containerApps', parameters('name')), '2023-04-01-preview').template.containers[0].image), createObject('value', '')))]", - "targetPort": { - "value": "[parameters('targetPort')]" - }, - "serviceBinds": { - "value": "[parameters('serviceBinds')]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "1912096201798605494" - }, - "description": "Creates a container app in an Azure Container App environment." - }, - "parameters": { - "name": { - "type": "string" - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]" - }, - "tags": { - "type": "object", - "defaultValue": {} - }, - "allowedOrigins": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "Allowed origins" - } - }, - "containerAppsEnvironmentName": { - "type": "string", - "metadata": { - "description": "Name of the environment for container apps" - } - }, - "containerCpuCoreCount": { - "type": "string", - "defaultValue": "0.5", - "metadata": { - "description": "CPU cores allocated to a single container instance, e.g., 0.5" - } - }, - "containerMaxReplicas": { - "type": "int", - "defaultValue": 10, - "minValue": 1, - "metadata": { - "description": "The maximum number of replicas to run. Must be at least 1." - } - }, - "containerMemory": { - "type": "string", - "defaultValue": "1.0Gi", - "metadata": { - "description": "Memory allocated to a single container instance, e.g., 1Gi" - } - }, - "containerMinReplicas": { - "type": "int", - "defaultValue": 1, - "metadata": { - "description": "The minimum number of replicas to run. Must be at least 1." - } - }, - "containerName": { - "type": "string", - "defaultValue": "main", - "metadata": { - "description": "The name of the container" - } - }, - "containerRegistryName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the container registry" - } - }, - "daprAppProtocol": { - "type": "string", - "defaultValue": "http", - "allowedValues": [ - "http", - "grpc" - ], - "metadata": { - "description": "The protocol used by Dapr to connect to the app, e.g., http or grpc" - } - }, - "daprAppId": { - "type": "string", - "defaultValue": "[parameters('containerName')]", - "metadata": { - "description": "The Dapr app ID" - } - }, - "daprEnabled": { - "type": "bool", - "defaultValue": false, - "metadata": { - "description": "Enable Dapr" - } - }, - "env": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "The environment variables for the container" - } - }, - "external": { - "type": "bool", - "defaultValue": true, - "metadata": { - "description": "Specifies if the resource ingress is exposed externally" - } - }, - "identityName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the user-assigned identity" - } - }, - "identityType": { - "type": "string", - "defaultValue": "None", - "allowedValues": [ - "None", - "SystemAssigned", - "UserAssigned" - ], - "metadata": { - "description": "The type of identity for the resource" - } - }, - "imageName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the container image" - } - }, - "ingressEnabled": { - "type": "bool", - "defaultValue": true, - "metadata": { - "description": "Specifies if Ingress is enabled for the container app" - } - }, - "revisionMode": { - "type": "string", - "defaultValue": "Single" - }, - "secrets": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "The secrets required for the container" - } - }, - "serviceBinds": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "The service binds associated with the container" - } - }, - "serviceType": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the container apps add-on to use. e.g. redis" - } - }, - "targetPort": { - "type": "int", - "defaultValue": 80, - "metadata": { - "description": "The target port for the container" - } - } - }, - "variables": { - "usePrivateRegistry": "[and(not(empty(parameters('identityName'))), not(empty(parameters('containerRegistryName'))))]", - "normalizedIdentityType": "[if(not(empty(parameters('identityName'))), 'UserAssigned', parameters('identityType'))]" - }, - "resources": [ - { - "type": "Microsoft.App/containerApps", - "apiVersion": "2023-04-01-preview", - "name": "[parameters('name')]", - "location": "[parameters('location')]", - "tags": "[parameters('tags')]", - "identity": { - "type": "[variables('normalizedIdentityType')]", - "userAssignedIdentities": "[if(and(not(empty(parameters('identityName'))), equals(variables('normalizedIdentityType'), 'UserAssigned')), createObject(format('{0}', resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName'))), createObject()), null())]" - }, - "properties": { - "managedEnvironmentId": "[resourceId('Microsoft.App/managedEnvironments', parameters('containerAppsEnvironmentName'))]", - "configuration": { - "activeRevisionsMode": "[parameters('revisionMode')]", - "ingress": "[if(parameters('ingressEnabled'), createObject('external', parameters('external'), 'targetPort', parameters('targetPort'), 'transport', 'auto', 'corsPolicy', createObject('allowedOrigins', union(createArray('https://portal.azure.com', 'https://ms.portal.azure.com'), parameters('allowedOrigins')))), null())]", - "dapr": "[if(parameters('daprEnabled'), createObject('enabled', true(), 'appId', parameters('daprAppId'), 'appProtocol', parameters('daprAppProtocol'), 'appPort', if(parameters('ingressEnabled'), parameters('targetPort'), 0)), createObject('enabled', false()))]", - "secrets": "[parameters('secrets')]", - "service": "[if(not(empty(parameters('serviceType'))), createObject('type', parameters('serviceType')), null())]", - "registries": "[if(variables('usePrivateRegistry'), createArray(createObject('server', format('{0}.azurecr.io', parameters('containerRegistryName')), 'identity', resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')))), createArray())]" - }, - "template": { - "serviceBinds": "[if(not(empty(parameters('serviceBinds'))), parameters('serviceBinds'), null())]", - "containers": [ - { - "image": "[if(not(empty(parameters('imageName'))), parameters('imageName'), 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest')]", - "name": "[parameters('containerName')]", - "env": "[parameters('env')]", - "resources": { - "cpu": "[json(parameters('containerCpuCoreCount'))]", - "memory": "[parameters('containerMemory')]" - } - } - ], - "scale": { - "minReplicas": "[parameters('containerMinReplicas')]", - "maxReplicas": "[parameters('containerMaxReplicas')]" - } - } - }, - "dependsOn": [ - "[resourceId('Microsoft.Resources/deployments', format('{0}-registry-access', deployment().name))]" - ] - }, - { - "condition": "[variables('usePrivateRegistry')]", - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "[format('{0}-registry-access', deployment().name)]", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "containerRegistryName": { - "value": "[parameters('containerRegistryName')]" - }, - "principalId": "[if(variables('usePrivateRegistry'), createObject('value', reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')), '2023-01-31').principalId), createObject('value', ''))]" - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "15144906240959446537" - }, - "description": "Assigns ACR Pull permissions to access an Azure Container Registry." - }, - "parameters": { - "containerRegistryName": { - "type": "string" - }, - "principalId": { - "type": "string" - } - }, - "variables": { - "acrPullRole": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '7f951dda-4ed3-4680-a7ca-43fe172d538d')]" - }, - "resources": [ - { - "type": "Microsoft.Authorization/roleAssignments", - "apiVersion": "2022-04-01", - "scope": "[format('Microsoft.ContainerRegistry/registries/{0}', parameters('containerRegistryName'))]", - "name": "[guid(subscription().id, resourceGroup().id, parameters('principalId'), variables('acrPullRole'))]", - "properties": { - "roleDefinitionId": "[variables('acrPullRole')]", - "principalType": "ServicePrincipal", - "principalId": "[parameters('principalId')]" - } - } - ] - } - } - } - ], - "outputs": { - "defaultDomain": { - "type": "string", - "value": "[reference(resourceId('Microsoft.App/managedEnvironments', parameters('containerAppsEnvironmentName')), '2023-04-01-preview').defaultDomain]" - }, - "identityPrincipalId": { - "type": "string", - "value": "[if(equals(variables('normalizedIdentityType'), 'None'), '', if(empty(parameters('identityName')), reference(resourceId('Microsoft.App/containerApps', parameters('name')), '2023-04-01-preview', 'full').identity.principalId, reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')), '2023-01-31').principalId))]" - }, - "imageName": { - "type": "string", - "value": "[parameters('imageName')]" - }, - "name": { - "type": "string", - "value": "[parameters('name')]" - }, - "serviceBind": { - "type": "object", - "value": "[if(not(empty(parameters('serviceType'))), createObject('serviceId', resourceId('Microsoft.App/containerApps', parameters('name')), 'name', parameters('name')), createObject())]" - }, - "uri": { - "type": "string", - "value": "[if(parameters('ingressEnabled'), format('https://{0}', reference(resourceId('Microsoft.App/containerApps', parameters('name')), '2023-04-01-preview').configuration.ingress.fqdn), '')]" - } - } - } - } - } - ], - "outputs": { - "defaultDomain": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-update', deployment().name)), '2022-09-01').outputs.defaultDomain.value]" - }, - "imageName": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-update', deployment().name)), '2022-09-01').outputs.imageName.value]" - }, - "name": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-update', deployment().name)), '2022-09-01').outputs.name.value]" - }, - "uri": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-update', deployment().name)), '2022-09-01').outputs.uri.value]" - } - } - } - } - } - ], - "outputs": { - "SERVICE_WEB_IDENTITY_PRINCIPAL_ID": { - "type": "string", - "value": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')), '2023-01-31').principalId]" - }, - "SERVICE_WEB_NAME": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-app', parameters('serviceName'))), '2022-09-01').outputs.name.value]" - }, - "SERVICE_WEB_URI": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-app', parameters('serviceName'))), '2022-09-01').outputs.uri.value]" - }, - "SERVICE_WEB_IMAGE_NAME": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-app', parameters('serviceName'))), '2022-09-01').outputs.imageName.value]" - } - } - } - }, - "dependsOn": [ - "[resourceId('Microsoft.Resources/deployments', 'api')]", - "[resourceId('Microsoft.Resources/deployments', 'container-apps')]", - "[resourceId('Microsoft.Resources/deployments', 'monitoring')]" - ] - }, - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "api", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "name": "[if(not(empty(parameters('apiContainerAppName'))), createObject('value', parameters('apiContainerAppName')), createObject('value', format('{0}api-{1}', variables('abbrs').appContainerApps, variables('resourceToken'))))]", - "location": { - "value": "[parameters('location')]" - }, - "tags": { - "value": "[variables('tags')]" - }, - "identityName": { - "value": "[format('{0}api-{1}', variables('abbrs').managedIdentityUserAssignedIdentities, variables('resourceToken'))]" - }, - "applicationInsightsName": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'monitoring'), '2022-09-01').outputs.applicationInsightsName.value]" - }, - "containerAppsEnvironmentName": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'container-apps'), '2022-09-01').outputs.environmentName.value]" - }, - "containerRegistryName": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'container-apps'), '2022-09-01').outputs.registryName.value]" - }, - "keyVaultName": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'keyvault'), '2022-09-01').outputs.name.value]" - }, - "corsAcaUrl": { - "value": "[format('https://{0}.{1}', variables('apiContainerAppNameOrDefault'), reference(resourceId('Microsoft.Resources/deployments', 'container-apps'), '2022-09-01').outputs.defaultDomain.value)]" - }, - "exists": { - "value": "[parameters('apiAppExists')]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "11092891629527222377" - } - }, - "parameters": { - "name": { - "type": "string" - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]" - }, - "tags": { - "type": "object", - "defaultValue": {} - }, - "identityName": { - "type": "string" - }, - "applicationInsightsName": { - "type": "string" - }, - "containerAppsEnvironmentName": { - "type": "string" - }, - "containerRegistryName": { - "type": "string" - }, - "keyVaultName": { - "type": "string" - }, - "serviceName": { - "type": "string", - "defaultValue": "api" - }, - "corsAcaUrl": { - "type": "string" - }, - "exists": { - "type": "bool" - } - }, - "resources": [ - { - "type": "Microsoft.ManagedIdentity/userAssignedIdentities", - "apiVersion": "2023-01-31", - "name": "[parameters('identityName')]", - "location": "[parameters('location')]" - }, - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "api-keyvault-access", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "keyVaultName": { - "value": "[parameters('keyVaultName')]" - }, - "principalId": { - "value": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')), '2023-01-31').principalId]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "815983560956742247" - }, - "description": "Assigns an Azure Key Vault access policy." - }, - "parameters": { - "name": { - "type": "string", - "defaultValue": "add" - }, - "keyVaultName": { - "type": "string" - }, - "permissions": { - "type": "object", - "defaultValue": { - "secrets": [ - "get", - "list" - ] - } - }, - "principalId": { - "type": "string" - } - }, - "resources": [ - { - "type": "Microsoft.KeyVault/vaults/accessPolicies", - "apiVersion": "2022-07-01", - "name": "[format('{0}/{1}', parameters('keyVaultName'), parameters('name'))]", - "properties": { - "accessPolicies": [ - { - "objectId": "[parameters('principalId')]", - "tenantId": "[subscription().tenantId]", - "permissions": "[parameters('permissions')]" - } - ] - } - } - ] - } - }, - "dependsOn": [ - "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName'))]" - ] - }, - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "[format('{0}-container-app', parameters('serviceName'))]", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "name": { - "value": "[parameters('name')]" - }, - "location": { - "value": "[parameters('location')]" - }, - "tags": { - "value": "[union(parameters('tags'), createObject('azd-service-name', parameters('serviceName')))]" - }, - "identityType": { - "value": "UserAssigned" - }, - "identityName": { - "value": "[parameters('identityName')]" - }, - "exists": { - "value": "[parameters('exists')]" - }, - "containerAppsEnvironmentName": { - "value": "[parameters('containerAppsEnvironmentName')]" - }, - "containerRegistryName": { - "value": "[parameters('containerRegistryName')]" - }, - "containerCpuCoreCount": { - "value": "1.0" - }, - "containerMemory": { - "value": "2.0Gi" - }, - "env": { - "value": [ - { - "name": "AZURE_CLIENT_ID", - "value": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')), '2023-01-31').clientId]" - }, - { - "name": "AZURE_KEY_VAULT_ENDPOINT", - "value": "[reference(resourceId('Microsoft.KeyVault/vaults', parameters('keyVaultName')), '2022-07-01').vaultUri]" - }, - { - "name": "APPLICATIONINSIGHTS_CONNECTION_STRING", - "value": "[reference(resourceId('Microsoft.Insights/components', parameters('applicationInsightsName')), '2020-02-02').ConnectionString]" - }, - { - "name": "API_ALLOW_ORIGINS", - "value": "[parameters('corsAcaUrl')]" - } - ] - }, - "targetPort": { - "value": 3100 - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "17242409915151931414" - }, - "description": "Creates or updates an existing Azure Container App." - }, - "parameters": { - "name": { - "type": "string" - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]" - }, - "tags": { - "type": "object", - "defaultValue": {} - }, - "containerAppsEnvironmentName": { - "type": "string", - "metadata": { - "description": "The environment name for the container apps" - } - }, - "containerCpuCoreCount": { - "type": "string", - "defaultValue": "0.5", - "metadata": { - "description": "The number of CPU cores allocated to a single container instance, e.g., 0.5" - } - }, - "containerMaxReplicas": { - "type": "int", - "defaultValue": 10, - "minValue": 1, - "metadata": { - "description": "The maximum number of replicas to run. Must be at least 1." - } - }, - "containerMemory": { - "type": "string", - "defaultValue": "1.0Gi", - "metadata": { - "description": "The amount of memory allocated to a single container instance, e.g., 1Gi" - } - }, - "containerMinReplicas": { - "type": "int", - "defaultValue": 1, - "minValue": 1, - "metadata": { - "description": "The minimum number of replicas to run. Must be at least 1." - } - }, - "containerName": { - "type": "string", - "defaultValue": "main", - "metadata": { - "description": "The name of the container" - } - }, - "containerRegistryName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the container registry" - } - }, - "daprAppProtocol": { - "type": "string", - "defaultValue": "http", - "allowedValues": [ - "http", - "grpc" - ], - "metadata": { - "description": "The protocol used by Dapr to connect to the app, e.g., HTTP or gRPC" - } - }, - "daprEnabled": { - "type": "bool", - "defaultValue": false, - "metadata": { - "description": "Enable or disable Dapr for the container app" - } - }, - "daprAppId": { - "type": "string", - "defaultValue": "[parameters('containerName')]", - "metadata": { - "description": "The Dapr app ID" - } - }, - "exists": { - "type": "bool", - "defaultValue": false, - "metadata": { - "description": "Specifies if the resource already exists" - } - }, - "ingressEnabled": { - "type": "bool", - "defaultValue": true, - "metadata": { - "description": "Specifies if Ingress is enabled for the container app" - } - }, - "identityType": { - "type": "string", - "defaultValue": "None", - "allowedValues": [ - "None", - "SystemAssigned", - "UserAssigned" - ], - "metadata": { - "description": "The type of identity for the resource" - } - }, - "identityName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the user-assigned identity" - } - }, - "imageName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the container image" - } - }, - "secrets": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "The secrets required for the container" - } - }, - "env": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "The environment variables for the container" - } - }, - "external": { - "type": "bool", - "defaultValue": true, - "metadata": { - "description": "Specifies if the resource ingress is exposed externally" - } - }, - "serviceBinds": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "The service binds associated with the container" - } - }, - "targetPort": { - "type": "int", - "defaultValue": 80, - "metadata": { - "description": "The target port for the container" - } - } - }, - "resources": [ - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "[format('{0}-update', deployment().name)]", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "name": { - "value": "[parameters('name')]" - }, - "location": { - "value": "[parameters('location')]" - }, - "tags": { - "value": "[parameters('tags')]" - }, - "identityType": { - "value": "[parameters('identityType')]" - }, - "identityName": { - "value": "[parameters('identityName')]" - }, - "ingressEnabled": { - "value": "[parameters('ingressEnabled')]" - }, - "containerName": { - "value": "[parameters('containerName')]" - }, - "containerAppsEnvironmentName": { - "value": "[parameters('containerAppsEnvironmentName')]" - }, - "containerRegistryName": { - "value": "[parameters('containerRegistryName')]" - }, - "containerCpuCoreCount": { - "value": "[parameters('containerCpuCoreCount')]" - }, - "containerMemory": { - "value": "[parameters('containerMemory')]" - }, - "containerMinReplicas": { - "value": "[parameters('containerMinReplicas')]" - }, - "containerMaxReplicas": { - "value": "[parameters('containerMaxReplicas')]" - }, - "daprEnabled": { - "value": "[parameters('daprEnabled')]" - }, - "daprAppId": { - "value": "[parameters('daprAppId')]" - }, - "daprAppProtocol": { - "value": "[parameters('daprAppProtocol')]" - }, - "secrets": { - "value": "[parameters('secrets')]" - }, - "external": { - "value": "[parameters('external')]" - }, - "env": { - "value": "[parameters('env')]" - }, - "imageName": "[if(not(empty(parameters('imageName'))), createObject('value', parameters('imageName')), if(parameters('exists'), createObject('value', reference(resourceId('Microsoft.App/containerApps', parameters('name')), '2023-04-01-preview').template.containers[0].image), createObject('value', '')))]", - "targetPort": { - "value": "[parameters('targetPort')]" - }, - "serviceBinds": { - "value": "[parameters('serviceBinds')]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "1912096201798605494" - }, - "description": "Creates a container app in an Azure Container App environment." - }, - "parameters": { - "name": { - "type": "string" - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]" - }, - "tags": { - "type": "object", - "defaultValue": {} - }, - "allowedOrigins": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "Allowed origins" - } - }, - "containerAppsEnvironmentName": { - "type": "string", - "metadata": { - "description": "Name of the environment for container apps" - } - }, - "containerCpuCoreCount": { - "type": "string", - "defaultValue": "0.5", - "metadata": { - "description": "CPU cores allocated to a single container instance, e.g., 0.5" - } - }, - "containerMaxReplicas": { - "type": "int", - "defaultValue": 10, - "minValue": 1, - "metadata": { - "description": "The maximum number of replicas to run. Must be at least 1." - } - }, - "containerMemory": { - "type": "string", - "defaultValue": "1.0Gi", - "metadata": { - "description": "Memory allocated to a single container instance, e.g., 1Gi" - } - }, - "containerMinReplicas": { - "type": "int", - "defaultValue": 1, - "metadata": { - "description": "The minimum number of replicas to run. Must be at least 1." - } - }, - "containerName": { - "type": "string", - "defaultValue": "main", - "metadata": { - "description": "The name of the container" - } - }, - "containerRegistryName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the container registry" - } - }, - "daprAppProtocol": { - "type": "string", - "defaultValue": "http", - "allowedValues": [ - "http", - "grpc" - ], - "metadata": { - "description": "The protocol used by Dapr to connect to the app, e.g., http or grpc" - } - }, - "daprAppId": { - "type": "string", - "defaultValue": "[parameters('containerName')]", - "metadata": { - "description": "The Dapr app ID" - } - }, - "daprEnabled": { - "type": "bool", - "defaultValue": false, - "metadata": { - "description": "Enable Dapr" - } - }, - "env": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "The environment variables for the container" - } - }, - "external": { - "type": "bool", - "defaultValue": true, - "metadata": { - "description": "Specifies if the resource ingress is exposed externally" - } - }, - "identityName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the user-assigned identity" - } - }, - "identityType": { - "type": "string", - "defaultValue": "None", - "allowedValues": [ - "None", - "SystemAssigned", - "UserAssigned" - ], - "metadata": { - "description": "The type of identity for the resource" - } - }, - "imageName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the container image" - } - }, - "ingressEnabled": { - "type": "bool", - "defaultValue": true, - "metadata": { - "description": "Specifies if Ingress is enabled for the container app" - } - }, - "revisionMode": { - "type": "string", - "defaultValue": "Single" - }, - "secrets": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "The secrets required for the container" - } - }, - "serviceBinds": { - "type": "array", - "defaultValue": [], - "metadata": { - "description": "The service binds associated with the container" - } - }, - "serviceType": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "The name of the container apps add-on to use. e.g. redis" - } - }, - "targetPort": { - "type": "int", - "defaultValue": 80, - "metadata": { - "description": "The target port for the container" - } - } - }, - "variables": { - "usePrivateRegistry": "[and(not(empty(parameters('identityName'))), not(empty(parameters('containerRegistryName'))))]", - "normalizedIdentityType": "[if(not(empty(parameters('identityName'))), 'UserAssigned', parameters('identityType'))]" - }, - "resources": [ - { - "type": "Microsoft.App/containerApps", - "apiVersion": "2023-04-01-preview", - "name": "[parameters('name')]", - "location": "[parameters('location')]", - "tags": "[parameters('tags')]", - "identity": { - "type": "[variables('normalizedIdentityType')]", - "userAssignedIdentities": "[if(and(not(empty(parameters('identityName'))), equals(variables('normalizedIdentityType'), 'UserAssigned')), createObject(format('{0}', resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName'))), createObject()), null())]" - }, - "properties": { - "managedEnvironmentId": "[resourceId('Microsoft.App/managedEnvironments', parameters('containerAppsEnvironmentName'))]", - "configuration": { - "activeRevisionsMode": "[parameters('revisionMode')]", - "ingress": "[if(parameters('ingressEnabled'), createObject('external', parameters('external'), 'targetPort', parameters('targetPort'), 'transport', 'auto', 'corsPolicy', createObject('allowedOrigins', union(createArray('https://portal.azure.com', 'https://ms.portal.azure.com'), parameters('allowedOrigins')))), null())]", - "dapr": "[if(parameters('daprEnabled'), createObject('enabled', true(), 'appId', parameters('daprAppId'), 'appProtocol', parameters('daprAppProtocol'), 'appPort', if(parameters('ingressEnabled'), parameters('targetPort'), 0)), createObject('enabled', false()))]", - "secrets": "[parameters('secrets')]", - "service": "[if(not(empty(parameters('serviceType'))), createObject('type', parameters('serviceType')), null())]", - "registries": "[if(variables('usePrivateRegistry'), createArray(createObject('server', format('{0}.azurecr.io', parameters('containerRegistryName')), 'identity', resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')))), createArray())]" - }, - "template": { - "serviceBinds": "[if(not(empty(parameters('serviceBinds'))), parameters('serviceBinds'), null())]", - "containers": [ - { - "image": "[if(not(empty(parameters('imageName'))), parameters('imageName'), 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest')]", - "name": "[parameters('containerName')]", - "env": "[parameters('env')]", - "resources": { - "cpu": "[json(parameters('containerCpuCoreCount'))]", - "memory": "[parameters('containerMemory')]" - } - } - ], - "scale": { - "minReplicas": "[parameters('containerMinReplicas')]", - "maxReplicas": "[parameters('containerMaxReplicas')]" - } - } - }, - "dependsOn": [ - "[resourceId('Microsoft.Resources/deployments', format('{0}-registry-access', deployment().name))]" - ] - }, - { - "condition": "[variables('usePrivateRegistry')]", - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "[format('{0}-registry-access', deployment().name)]", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "containerRegistryName": { - "value": "[parameters('containerRegistryName')]" - }, - "principalId": "[if(variables('usePrivateRegistry'), createObject('value', reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')), '2023-01-31').principalId), createObject('value', ''))]" - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "15144906240959446537" - }, - "description": "Assigns ACR Pull permissions to access an Azure Container Registry." - }, - "parameters": { - "containerRegistryName": { - "type": "string" - }, - "principalId": { - "type": "string" - } - }, - "variables": { - "acrPullRole": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '7f951dda-4ed3-4680-a7ca-43fe172d538d')]" - }, - "resources": [ - { - "type": "Microsoft.Authorization/roleAssignments", - "apiVersion": "2022-04-01", - "scope": "[format('Microsoft.ContainerRegistry/registries/{0}', parameters('containerRegistryName'))]", - "name": "[guid(subscription().id, resourceGroup().id, parameters('principalId'), variables('acrPullRole'))]", - "properties": { - "roleDefinitionId": "[variables('acrPullRole')]", - "principalType": "ServicePrincipal", - "principalId": "[parameters('principalId')]" - } - } - ] - } - } - } - ], - "outputs": { - "defaultDomain": { - "type": "string", - "value": "[reference(resourceId('Microsoft.App/managedEnvironments', parameters('containerAppsEnvironmentName')), '2023-04-01-preview').defaultDomain]" - }, - "identityPrincipalId": { - "type": "string", - "value": "[if(equals(variables('normalizedIdentityType'), 'None'), '', if(empty(parameters('identityName')), reference(resourceId('Microsoft.App/containerApps', parameters('name')), '2023-04-01-preview', 'full').identity.principalId, reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')), '2023-01-31').principalId))]" - }, - "imageName": { - "type": "string", - "value": "[parameters('imageName')]" - }, - "name": { - "type": "string", - "value": "[parameters('name')]" - }, - "serviceBind": { - "type": "object", - "value": "[if(not(empty(parameters('serviceType'))), createObject('serviceId', resourceId('Microsoft.App/containerApps', parameters('name')), 'name', parameters('name')), createObject())]" - }, - "uri": { - "type": "string", - "value": "[if(parameters('ingressEnabled'), format('https://{0}', reference(resourceId('Microsoft.App/containerApps', parameters('name')), '2023-04-01-preview').configuration.ingress.fqdn), '')]" - } - } - } - } - } - ], - "outputs": { - "defaultDomain": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-update', deployment().name)), '2022-09-01').outputs.defaultDomain.value]" - }, - "imageName": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-update', deployment().name)), '2022-09-01').outputs.imageName.value]" - }, - "name": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-update', deployment().name)), '2022-09-01').outputs.name.value]" - }, - "uri": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-update', deployment().name)), '2022-09-01').outputs.uri.value]" - } - } - } - }, - "dependsOn": [ - "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName'))]", - "[resourceId('Microsoft.Resources/deployments', 'api-keyvault-access')]" - ] - } - ], - "outputs": { - "SERVICE_API_IDENTITY_PRINCIPAL_ID": { - "type": "string", - "value": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('identityName')), '2023-01-31').principalId]" - }, - "SERVICE_API_NAME": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-app', parameters('serviceName'))), '2022-09-01').outputs.name.value]" - }, - "SERVICE_API_URI": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-app', parameters('serviceName'))), '2022-09-01').outputs.uri.value]" - }, - "SERVICE_API_IMAGE_NAME": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-app', parameters('serviceName'))), '2022-09-01').outputs.imageName.value]" - } - } - } - }, - "dependsOn": [ - "[resourceId('Microsoft.Resources/deployments', 'container-apps')]", - "[resourceId('Microsoft.Resources/deployments', 'keyvault')]", - "[resourceId('Microsoft.Resources/deployments', 'monitoring')]" - ] - }, - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "cosmos", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "accountName": "[if(not(empty(parameters('cosmosAccountName'))), createObject('value', parameters('cosmosAccountName')), createObject('value', format('{0}{1}', variables('abbrs').documentDBDatabaseAccounts, variables('resourceToken'))))]", - "databaseName": { - "value": "[parameters('cosmosDatabaseName')]" - }, - "location": { - "value": "[parameters('location')]" - }, - "tags": { - "value": "[variables('tags')]" - }, - "keyVaultName": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'keyvault'), '2022-09-01').outputs.name.value]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "5730728686647632614" - } - }, - "parameters": { - "accountName": { - "type": "string" - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]" - }, - "tags": { - "type": "object", - "defaultValue": {} - }, - "collections": { - "type": "array", - "defaultValue": [ - { - "name": "TodoList", - "id": "TodoList", - "shardKey": "Hash", - "indexKey": "_id" - }, - { - "name": "TodoItem", - "id": "TodoItem", - "shardKey": "Hash", - "indexKey": "_id" - } - ] - }, - "databaseName": { - "type": "string", - "defaultValue": "" - }, - "keyVaultName": { - "type": "string" - } - }, - "variables": { - "defaultDatabaseName": "Todo", - "actualDatabaseName": "[if(not(empty(parameters('databaseName'))), parameters('databaseName'), variables('defaultDatabaseName'))]" - }, - "resources": [ - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "cosmos-mongo", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "accountName": { - "value": "[parameters('accountName')]" - }, - "databaseName": { - "value": "[variables('actualDatabaseName')]" - }, - "location": { - "value": "[parameters('location')]" - }, - "collections": { - "value": "[parameters('collections')]" - }, - "keyVaultName": { - "value": "[parameters('keyVaultName')]" - }, - "tags": { - "value": "[parameters('tags')]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "14549161001187918251" - }, - "description": "Creates an Azure Cosmos DB for MongoDB account with a database." - }, - "parameters": { - "accountName": { - "type": "string" - }, - "databaseName": { - "type": "string" - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]" - }, - "tags": { - "type": "object", - "defaultValue": {} - }, - "collections": { - "type": "array", - "defaultValue": [] - }, - "connectionStringKey": { - "type": "string", - "defaultValue": "AZURE-COSMOS-CONNECTION-STRING" - }, - "keyVaultName": { - "type": "string" - } - }, - "resources": [ - { - "copy": { - "name": "list", - "count": "[length(parameters('collections'))]" - }, - "type": "Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/collections", - "apiVersion": "2022-08-15", - "name": "[format('{0}/{1}/{2}', split(format('{0}/{1}', parameters('accountName'), parameters('databaseName')), '/')[0], split(format('{0}/{1}', parameters('accountName'), parameters('databaseName')), '/')[1], parameters('collections')[copyIndex()].name)]", - "properties": { - "resource": { - "id": "[parameters('collections')[copyIndex()].id]", - "shardKey": { - "_id": "[parameters('collections')[copyIndex()].shardKey]" - }, - "indexes": [ - { - "key": { - "keys": [ - "[parameters('collections')[copyIndex()].indexKey]" - ] - } - } - ] - } - }, - "dependsOn": [ - "[resourceId('Microsoft.DocumentDB/databaseAccounts/mongodbDatabases', split(format('{0}/{1}', parameters('accountName'), parameters('databaseName')), '/')[0], split(format('{0}/{1}', parameters('accountName'), parameters('databaseName')), '/')[1])]" - ] - }, - { - "type": "Microsoft.DocumentDB/databaseAccounts/mongodbDatabases", - "apiVersion": "2022-08-15", - "name": "[format('{0}/{1}', parameters('accountName'), parameters('databaseName'))]", - "tags": "[parameters('tags')]", - "properties": { - "resource": { - "id": "[parameters('databaseName')]" - } - }, - "dependsOn": [ - "[resourceId('Microsoft.Resources/deployments', 'cosmos-mongo-account')]" - ] - }, - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "cosmos-mongo-account", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "name": { - "value": "[parameters('accountName')]" - }, - "location": { - "value": "[parameters('location')]" - }, - "keyVaultName": { - "value": "[parameters('keyVaultName')]" - }, - "tags": { - "value": "[parameters('tags')]" - }, - "connectionStringKey": { - "value": "[parameters('connectionStringKey')]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "8317058180807592714" - }, - "description": "Creates an Azure Cosmos DB for MongoDB account." - }, - "parameters": { - "name": { - "type": "string" - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]" - }, - "tags": { - "type": "object", - "defaultValue": {} - }, - "keyVaultName": { - "type": "string" - }, - "connectionStringKey": { - "type": "string", - "defaultValue": "AZURE-COSMOS-CONNECTION-STRING" - } - }, - "resources": [ - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "cosmos-account", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "name": { - "value": "[parameters('name')]" - }, - "location": { - "value": "[parameters('location')]" - }, - "connectionStringKey": { - "value": "[parameters('connectionStringKey')]" - }, - "keyVaultName": { - "value": "[parameters('keyVaultName')]" - }, - "kind": { - "value": "MongoDB" - }, - "tags": { - "value": "[parameters('tags')]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "13614361263700788271" - }, - "description": "Creates an Azure Cosmos DB account." - }, - "parameters": { - "name": { - "type": "string" - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]" - }, - "tags": { - "type": "object", - "defaultValue": {} - }, - "connectionStringKey": { - "type": "string", - "defaultValue": "AZURE-COSMOS-CONNECTION-STRING" - }, - "keyVaultName": { - "type": "string" - }, - "kind": { - "type": "string", - "allowedValues": [ - "GlobalDocumentDB", - "MongoDB", - "Parse" - ] - } - }, - "resources": [ - { - "type": "Microsoft.DocumentDB/databaseAccounts", - "apiVersion": "2022-08-15", - "name": "[parameters('name')]", - "kind": "[parameters('kind')]", - "location": "[parameters('location')]", - "tags": "[parameters('tags')]", - "properties": { - "consistencyPolicy": { - "defaultConsistencyLevel": "Session" - }, - "locations": [ - { - "locationName": "[parameters('location')]", - "failoverPriority": 0, - "isZoneRedundant": false - } - ], - "databaseAccountOfferType": "Standard", - "enableAutomaticFailover": false, - "enableMultipleWriteLocations": false, - "apiProperties": "[if(equals(parameters('kind'), 'MongoDB'), createObject('serverVersion', '4.2'), createObject())]", - "capabilities": [ - { - "name": "EnableServerless" - } - ] - } - }, - { - "type": "Microsoft.KeyVault/vaults/secrets", - "apiVersion": "2022-07-01", - "name": "[format('{0}/{1}', parameters('keyVaultName'), parameters('connectionStringKey'))]", - "properties": { - "value": "[listConnectionStrings(resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('name')), '2022-08-15').connectionStrings[0].connectionString]" - }, - "dependsOn": [ - "[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('name'))]" - ] - } - ], - "outputs": { - "connectionStringKey": { - "type": "string", - "value": "[parameters('connectionStringKey')]" - }, - "endpoint": { - "type": "string", - "value": "[reference(resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('name')), '2022-08-15').documentEndpoint]" - }, - "id": { - "type": "string", - "value": "[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('name'))]" - }, - "name": { - "type": "string", - "value": "[parameters('name')]" - } - } - } - } - } - ], - "outputs": { - "connectionStringKey": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos-account'), '2022-09-01').outputs.connectionStringKey.value]" - }, - "endpoint": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos-account'), '2022-09-01').outputs.endpoint.value]" - }, - "id": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos-account'), '2022-09-01').outputs.id.value]" - } - } - } - } - } - ], - "outputs": { - "connectionStringKey": { - "type": "string", - "value": "[parameters('connectionStringKey')]" - }, - "databaseName": { - "type": "string", - "value": "[parameters('databaseName')]" - }, - "endpoint": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos-mongo-account'), '2022-09-01').outputs.endpoint.value]" - } - } - } - } - } - ], - "outputs": { - "connectionStringKey": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos-mongo'), '2022-09-01').outputs.connectionStringKey.value]" - }, - "databaseName": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos-mongo'), '2022-09-01').outputs.databaseName.value]" - }, - "endpoint": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos-mongo'), '2022-09-01').outputs.endpoint.value]" - } - } - } - }, - "dependsOn": [ - "[resourceId('Microsoft.Resources/deployments', 'keyvault')]" - ] - }, - { - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "keyvault", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "name": "[if(not(empty(parameters('keyVaultName'))), createObject('value', parameters('keyVaultName')), createObject('value', format('{0}{1}', variables('abbrs').keyVaultVaults, variables('resourceToken'))))]", - "location": { - "value": "[parameters('location')]" - }, - "tags": { - "value": "[variables('tags')]" - }, - "principalId": { - "value": "[parameters('principalId')]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "17948623451174129396" - }, - "description": "Creates an Azure Key Vault." - }, - "parameters": { - "name": { - "type": "string" - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]" - }, - "tags": { - "type": "object", - "defaultValue": {} - }, - "principalId": { - "type": "string", - "defaultValue": "" - } - }, - "resources": [ - { - "type": "Microsoft.KeyVault/vaults", - "apiVersion": "2022-07-01", - "name": "[parameters('name')]", - "location": "[parameters('location')]", - "tags": "[parameters('tags')]", - "properties": { - "tenantId": "[subscription().tenantId]", - "sku": { - "family": "A", - "name": "standard" - }, - "accessPolicies": "[if(not(empty(parameters('principalId'))), createArray(createObject('objectId', parameters('principalId'), 'permissions', createObject('secrets', createArray('get', 'list')), 'tenantId', subscription().tenantId)), createArray())]" + "metadata": { + "description": "Specifies if Dapr is enabled" + } + }, + "logAnalyticsWorkspaceName": { + "type": "string", + "metadata": { + "description": "Name of the Log Analytics workspace" + } + } + }, + "resources": [ + { + "type": "Microsoft.App/managedEnvironments", + "apiVersion": "2023-04-01-preview", + "name": "[parameters('name')]", + "location": "[parameters('location')]", + "tags": "[parameters('tags')]", + "properties": { + "appLogsConfiguration": { + "destination": "log-analytics", + "logAnalyticsConfiguration": { + "customerId": "[reference(resourceId('Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceName')), '2022-10-01').customerId]", + "sharedKey": "[listKeys(resourceId('Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceName')), '2022-10-01').primarySharedKey]" + } + }, + "daprAIInstrumentationKey": "[if(and(parameters('daprEnabled'), not(empty(parameters('applicationInsightsName')))), reference(resourceId('Microsoft.Insights/components', parameters('applicationInsightsName')), '2020-02-02').InstrumentationKey, '')]" + } + } + ], + "outputs": { + "defaultDomain": { + "type": "string", + "value": "[reference(resourceId('Microsoft.App/managedEnvironments', parameters('name')), '2023-04-01-preview').defaultDomain]" + }, + "id": { + "type": "string", + "value": "[resourceId('Microsoft.App/managedEnvironments', parameters('name'))]" + }, + "name": { + "type": "string", + "value": "[parameters('name')]" + } + } + } } } ], "outputs": { - "endpoint": { + "defaultDomain": { "type": "string", - "value": "[reference(resourceId('Microsoft.KeyVault/vaults', parameters('name')), '2022-07-01').vaultUri]" + "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-apps-environment', parameters('name'))), '2022-09-01').outputs.defaultDomain.value]" }, - "name": { + "environmentName": { + "type": "string", + "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-apps-environment', parameters('name'))), '2022-09-01').outputs.name.value]" + }, + "environmentId": { "type": "string", - "value": "[parameters('name')]" + "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-container-apps-environment', parameters('name'))), '2022-09-01').outputs.id.value]" } } } - } + }, + "dependsOn": [ + "[resourceId('Microsoft.Resources/deployments', 'monitoring')]" + ] }, { "type": "Microsoft.Resources/deployments", @@ -4253,360 +1882,9 @@ } } } - }, - { - "condition": "[parameters('useAPIM')]", - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "apim-deployment", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "name": "[if(not(empty(parameters('apimServiceName'))), createObject('value', parameters('apimServiceName')), createObject('value', format('{0}{1}', variables('abbrs').apiManagementService, variables('resourceToken'))))]", - "location": { - "value": "[parameters('location')]" - }, - "tags": { - "value": "[variables('tags')]" - }, - "applicationInsightsName": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'monitoring'), '2022-09-01').outputs.applicationInsightsName.value]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "3036576769636454145" - }, - "description": "Creates an Azure API Management instance." - }, - "parameters": { - "name": { - "type": "string" - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]" - }, - "tags": { - "type": "object", - "defaultValue": {} - }, - "publisherEmail": { - "type": "string", - "defaultValue": "noreply@microsoft.com", - "minLength": 1, - "metadata": { - "description": "The email address of the owner of the service" - } - }, - "publisherName": { - "type": "string", - "defaultValue": "n/a", - "minLength": 1, - "metadata": { - "description": "The name of the owner of the service" - } - }, - "sku": { - "type": "string", - "defaultValue": "Consumption", - "allowedValues": [ - "Consumption", - "Developer", - "Standard", - "Premium" - ], - "metadata": { - "description": "The pricing tier of this API Management service" - } - }, - "skuCount": { - "type": "int", - "defaultValue": 0, - "allowedValues": [ - 0, - 1, - 2 - ], - "metadata": { - "description": "The instance size of this API Management service." - } - }, - "applicationInsightsName": { - "type": "string", - "metadata": { - "description": "Azure Application Insights Name" - } - } - }, - "resources": [ - { - "type": "Microsoft.ApiManagement/service", - "apiVersion": "2021-08-01", - "name": "[parameters('name')]", - "location": "[parameters('location')]", - "tags": "[union(parameters('tags'), createObject('azd-service-name', parameters('name')))]", - "sku": { - "name": "[parameters('sku')]", - "capacity": "[if(equals(parameters('sku'), 'Consumption'), 0, if(equals(parameters('sku'), 'Developer'), 1, parameters('skuCount')))]" - }, - "properties": { - "publisherEmail": "[parameters('publisherEmail')]", - "publisherName": "[parameters('publisherName')]", - "customProperties": "[if(equals(parameters('sku'), 'Consumption'), createObject(), createObject('Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA', 'false', 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA', 'false', 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_GCM_SHA256', 'false', 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_256_CBC_SHA256', 'false', 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256', 'false', 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_256_CBC_SHA', 'false', 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA', 'false', 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168', 'false', 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10', 'false', 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11', 'false', 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30', 'false', 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10', 'false', 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11', 'false', 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30', 'false'))]" - } - }, - { - "condition": "[not(empty(parameters('applicationInsightsName')))]", - "type": "Microsoft.ApiManagement/service/loggers", - "apiVersion": "2021-12-01-preview", - "name": "[format('{0}/{1}', parameters('name'), 'app-insights-logger')]", - "properties": { - "credentials": { - "instrumentationKey": "[reference(resourceId('Microsoft.Insights/components', parameters('applicationInsightsName')), '2020-02-02').InstrumentationKey]" - }, - "description": "Logger to Azure Application Insights", - "isBuffered": false, - "loggerType": "applicationInsights", - "resourceId": "[resourceId('Microsoft.Insights/components', parameters('applicationInsightsName'))]" - }, - "dependsOn": [ - "[resourceId('Microsoft.ApiManagement/service', parameters('name'))]" - ] - } - ], - "outputs": { - "apimServiceName": { - "type": "string", - "value": "[parameters('name')]" - } - } - } - }, - "dependsOn": [ - "[resourceId('Microsoft.Resources/deployments', 'monitoring')]" - ] - }, - { - "condition": "[parameters('useAPIM')]", - "type": "Microsoft.Resources/deployments", - "apiVersion": "2022-09-01", - "name": "apim-api-deployment", - "properties": { - "expressionEvaluationOptions": { - "scope": "inner" - }, - "mode": "Incremental", - "parameters": { - "name": "[if(parameters('useAPIM'), createObject('value', reference(resourceId('Microsoft.Resources/deployments', 'apim-deployment'), '2022-09-01').outputs.apimServiceName.value), createObject('value', ''))]", - "apiName": { - "value": "todo-api" - }, - "apiDisplayName": { - "value": "Simple Todo API" - }, - "apiDescription": { - "value": "This is a simple Todo API" - }, - "apiPath": { - "value": "todo" - }, - "webFrontendUrl": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'web'), '2022-09-01').outputs.SERVICE_WEB_URI.value]" - }, - "apiBackendUrl": { - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'api'), '2022-09-01').outputs.SERVICE_API_URI.value]" - } - }, - "template": { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.25.53.49325", - "templateHash": "6615097664318461925" - } - }, - "parameters": { - "name": { - "type": "string" - }, - "apiName": { - "type": "string", - "minLength": 1, - "metadata": { - "description": "Resource name to uniquely identify this API within the API Management service instance" - } - }, - "apiDisplayName": { - "type": "string", - "minLength": 1, - "maxLength": 300, - "metadata": { - "description": "The Display Name of the API" - } - }, - "apiDescription": { - "type": "string", - "minLength": 1, - "metadata": { - "description": "Description of the API. May include HTML formatting tags." - } - }, - "apiPath": { - "type": "string", - "minLength": 1, - "metadata": { - "description": "Relative URL uniquely identifying this API and all of its resource paths within the API Management service instance. It is appended to the API endpoint base URL specified during the service instance creation to form a public URL for this API." - } - }, - "webFrontendUrl": { - "type": "string", - "metadata": { - "description": "Absolute URL of the web frontend" - } - }, - "apiBackendUrl": { - "type": "string", - "metadata": { - "description": "Absolute URL of the backend service implementing this API." - } - }, - "apiAppName": { - "type": "string", - "defaultValue": "", - "metadata": { - "description": "Resource name for backend Web App or Function App" - } - } - }, - "variables": { - "$fxv#0": "\n\n \n \n \n \n \n {origin}\n \n \n PUT\n GET\n POST\n DELETE\n PATCH\n \n \n
*
\n
\n \n
*
\n
\n
\n \n \n \n \n \n \n Call to the @(context.Api.Name)\n \n \n \n \n \n
\n \n \n \n \n \n \n \n \n \n \n \n = 200 && context.Response.StatusCode < 300)\">\n \n \n \n \n \n \n \n = 400 && context.Response.StatusCode < 600)\">\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Failed to process the @(context.Api.Name)\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n An unexpected error has occurred.\n \n \n
\n", - "$fxv#1": "openapi: 3.0.0\ninfo:\n description: Simple Todo API\n version: 3.0.0\n title: Simple Todo API\n contact:\n email: azdevteam@microsoft.com\n\ncomponents:\n schemas:\n TodoItem:\n type: object\n required:\n - listId\n - name\n - description\n description: A task that needs to be completed\n properties:\n id:\n type: string\n listId:\n type: string\n name:\n type: string\n description:\n type: string\n state:\n $ref: \"#/components/schemas/TodoState\"\n dueDate:\n type: string\n format: date-time\n completedDate:\n type: string\n format: date-time\n TodoList:\n type: object\n required:\n - name\n properties:\n id:\n type: string\n name:\n type: string\n description:\n type: string\n description: \" A list of related Todo items\"\n TodoState:\n type: string\n enum:\n - todo\n - inprogress\n - done\n parameters:\n listId:\n in: path\n required: true\n name: listId\n description: The Todo list unique identifier\n schema:\n type: string\n itemId:\n in: path\n required: true\n name: itemId\n description: The Todo item unique identifier\n schema:\n type: string\n state:\n in: path\n required: true\n name: state\n description: The Todo item state\n schema:\n $ref: \"#/components/schemas/TodoState\"\n top:\n in: query\n required: false\n name: top\n description: The max number of items to returns in a result\n schema:\n type: number\n default: 20\n skip:\n in: query\n required: false\n name: skip\n description: The number of items to skip within the results\n schema:\n type: number\n default: 0\n\n requestBodies:\n TodoList:\n description: The Todo List\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/TodoList\"\n TodoItem:\n description: The Todo Item\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/TodoItem\"\n\n responses:\n TodoList:\n description: A Todo list result\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/TodoList\"\n TodoListArray:\n description: An array of Todo lists\n content:\n application/json:\n schema:\n type: array\n items:\n $ref: \"#/components/schemas/TodoList\"\n TodoItem:\n description: A Todo item result\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/TodoItem\"\n TodoItemArray:\n description: An array of Todo items\n content:\n application/json:\n schema:\n type: array\n items:\n $ref: \"#/components/schemas/TodoItem\"\n\npaths:\n /lists:\n get:\n operationId: GetLists\n summary: Gets an array of Todo lists\n tags:\n - Lists\n parameters:\n - $ref: \"#/components/parameters/top\"\n - $ref: \"#/components/parameters/skip\"\n responses:\n 200:\n $ref: \"#/components/responses/TodoListArray\"\n post:\n operationId: CreateList\n summary: Creates a new Todo list\n tags:\n - Lists\n requestBody:\n $ref: \"#/components/requestBodies/TodoList\"\n responses:\n 201:\n $ref: \"#/components/responses/TodoList\"\n 400:\n description: Invalid request schema\n /lists/{listId}:\n get:\n operationId: GetListById\n summary: Gets a Todo list by unique identifier\n tags:\n - Lists\n parameters:\n - $ref: \"#/components/parameters/listId\"\n responses:\n 200:\n $ref: \"#/components/responses/TodoList\"\n 404:\n description: Todo list not found\n put:\n operationId: UpdateListById\n summary: Updates a Todo list by unique identifier\n tags:\n - Lists\n requestBody:\n $ref: \"#/components/requestBodies/TodoList\"\n parameters:\n - $ref: \"#/components/parameters/listId\"\n responses:\n 200:\n $ref: \"#/components/responses/TodoList\"\n 404:\n description: Todo list not found\n 400:\n description: Todo list is invalid\n delete:\n operationId: DeleteListById\n summary: Deletes a Todo list by unique identifier\n tags:\n - Lists\n parameters:\n - $ref: \"#/components/parameters/listId\"\n responses:\n 204:\n description: Todo list deleted successfully\n 404:\n description: Todo list not found\n /lists/{listId}/items:\n post:\n operationId: CreateItem\n summary: Creates a new Todo item within a list\n tags:\n - Items\n requestBody:\n $ref: \"#/components/requestBodies/TodoItem\"\n parameters:\n - $ref: \"#/components/parameters/listId\"\n responses:\n 201:\n $ref: \"#/components/responses/TodoItem\"\n 404:\n description: Todo list not found\n get:\n operationId: GetItemsByListId\n summary: Gets Todo items within the specified list\n tags:\n - Items\n parameters:\n - $ref: \"#/components/parameters/listId\"\n - $ref: \"#/components/parameters/top\"\n - $ref: \"#/components/parameters/skip\"\n responses:\n 200:\n $ref: \"#/components/responses/TodoItemArray\"\n 404:\n description: Todo list not found\n /lists/{listId}/items/{itemId}:\n get:\n operationId: GetItemById\n summary: Gets a Todo item by unique identifier\n tags:\n - Items\n parameters:\n - $ref: \"#/components/parameters/listId\"\n - $ref: \"#/components/parameters/itemId\"\n responses:\n 200:\n $ref: \"#/components/responses/TodoItem\"\n 404:\n description: Todo list or item not found\n put:\n operationId: UpdateItemById\n summary: Updates a Todo item by unique identifier\n tags:\n - Items\n requestBody:\n $ref: \"#/components/requestBodies/TodoItem\"\n parameters:\n - $ref: \"#/components/parameters/listId\"\n - $ref: \"#/components/parameters/itemId\"\n responses:\n 200:\n $ref: \"#/components/responses/TodoItem\"\n 400:\n description: Todo item is invalid\n 404:\n description: Todo list or item not found\n delete:\n operationId: DeleteItemById\n summary: Deletes a Todo item by unique identifier\n tags:\n - Items\n parameters:\n - $ref: \"#/components/parameters/listId\"\n - $ref: \"#/components/parameters/itemId\"\n responses:\n 204:\n description: Todo item deleted successfully\n 404:\n description: Todo list or item not found\n /lists/{listId}/items/state/{state}:\n get:\n operationId: GetItemsByListIdAndState\n summary: Gets a list of Todo items of a specific state\n tags:\n - Items\n parameters:\n - $ref: \"#/components/parameters/listId\"\n - $ref: \"#/components/parameters/state\"\n - $ref: \"#/components/parameters/top\"\n - $ref: \"#/components/parameters/skip\"\n responses:\n 200:\n $ref: \"#/components/responses/TodoItemArray\"\n 404:\n description: Todo list or item not found\n put:\n operationId: UpdateItemsStateByListId\n summary: Changes the state of the specified list items\n tags:\n - Items\n requestBody:\n description: unique identifiers of the Todo items to update\n content:\n application/json:\n schema:\n type: array\n items:\n description: The Todo item unique identifier\n type: string\n parameters:\n - $ref: \"#/components/parameters/listId\"\n - $ref: \"#/components/parameters/state\"\n responses:\n 204:\n description: Todo items updated\n 400:\n description: Update request is invalid\n", - "apiPolicyContent": "[replace(variables('$fxv#0'), '{origin}', parameters('webFrontendUrl'))]", - "appNameForBicep": "[if(not(empty(parameters('apiAppName'))), parameters('apiAppName'), 'placeholderName')]" - }, - "resources": [ - { - "type": "Microsoft.ApiManagement/service/apis", - "apiVersion": "2021-12-01-preview", - "name": "[format('{0}/{1}', parameters('name'), parameters('apiName'))]", - "properties": { - "description": "[parameters('apiDescription')]", - "displayName": "[parameters('apiDisplayName')]", - "path": "[parameters('apiPath')]", - "protocols": [ - "https" - ], - "subscriptionRequired": false, - "type": "http", - "format": "openapi", - "serviceUrl": "[parameters('apiBackendUrl')]", - "value": "[variables('$fxv#1')]" - } - }, - { - "type": "Microsoft.ApiManagement/service/apis/policies", - "apiVersion": "2021-12-01-preview", - "name": "[format('{0}/{1}/{2}', parameters('name'), parameters('apiName'), 'policy')]", - "properties": { - "format": "rawxml", - "value": "[variables('apiPolicyContent')]" - }, - "dependsOn": [ - "[resourceId('Microsoft.ApiManagement/service/apis', parameters('name'), parameters('apiName'))]" - ] - }, - { - "type": "Microsoft.ApiManagement/service/apis/diagnostics", - "apiVersion": "2021-12-01-preview", - "name": "[format('{0}/{1}/{2}', parameters('name'), parameters('apiName'), 'applicationinsights')]", - "properties": { - "alwaysLog": "allErrors", - "backend": { - "request": { - "body": { - "bytes": 1024 - } - }, - "response": { - "body": { - "bytes": 1024 - } - } - }, - "frontend": { - "request": { - "body": { - "bytes": 1024 - } - }, - "response": { - "body": { - "bytes": 1024 - } - } - }, - "httpCorrelationProtocol": "W3C", - "logClientIp": true, - "loggerId": "[resourceId('Microsoft.ApiManagement/service/loggers', parameters('name'), 'app-insights-logger')]", - "metrics": true, - "sampling": { - "percentage": 100, - "samplingType": "fixed" - }, - "verbosity": "verbose" - }, - "dependsOn": [ - "[resourceId('Microsoft.ApiManagement/service/apis', parameters('name'), parameters('apiName'))]" - ] - }, - { - "condition": "[not(empty(parameters('apiAppName')))]", - "type": "Microsoft.Web/sites/config", - "apiVersion": "2022-03-01", - "name": "[format('{0}/web', variables('appNameForBicep'))]", - "kind": "string", - "properties": { - "apiManagementConfig": { - "id": "[format('{0}/apis/{1}', resourceId('Microsoft.ApiManagement/service', parameters('name')), parameters('apiName'))]" - } - } - } - ], - "outputs": { - "SERVICE_API_URI": { - "type": "string", - "value": "[format('{0}/{1}', reference(resourceId('Microsoft.ApiManagement/service', parameters('name')), '2021-08-01').gatewayUrl, parameters('apiPath'))]" - } - } - } - }, - "dependsOn": [ - "[resourceId('Microsoft.Resources/deployments', 'api')]", - "[resourceId('Microsoft.Resources/deployments', 'apim-deployment')]", - "[resourceId('Microsoft.Resources/deployments', 'web')]" - ] } ], "outputs": { - "AZURE_COSMOS_CONNECTION_STRING_KEY": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos'), '2022-09-01').outputs.connectionStringKey.value]" - }, - "AZURE_COSMOS_DATABASE_NAME": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'cosmos'), '2022-09-01').outputs.databaseName.value]" - }, "API_CORS_ACA_URL": { "type": "string", "value": "[format('https://{0}.{1}', variables('apiContainerAppNameOrDefault'), reference(resourceId('Microsoft.Resources/deployments', 'container-apps'), '2022-09-01').outputs.defaultDomain.value)]" @@ -4623,22 +1901,6 @@ "type": "string", "value": "[reference(resourceId('Microsoft.Resources/deployments', 'container-apps'), '2022-09-01').outputs.environmentName.value]" }, - "AZURE_CONTAINER_REGISTRY_ENDPOINT": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'container-apps'), '2022-09-01').outputs.registryLoginServer.value]" - }, - "AZURE_CONTAINER_REGISTRY_NAME": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'container-apps'), '2022-09-01').outputs.registryName.value]" - }, - "AZURE_KEY_VAULT_ENDPOINT": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'keyvault'), '2022-09-01').outputs.endpoint.value]" - }, - "AZURE_KEY_VAULT_NAME": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'keyvault'), '2022-09-01').outputs.name.value]" - }, "AZURE_LOCATION": { "type": "string", "value": "[parameters('location')]" @@ -4647,33 +1909,9 @@ "type": "string", "value": "[tenant().tenantId]" }, - "REACT_APP_API_BASE_URL": { - "type": "string", - "value": "[if(parameters('useAPIM'), reference(resourceId('Microsoft.Resources/deployments', 'apim-api-deployment'), '2022-09-01').outputs.SERVICE_API_URI.value, reference(resourceId('Microsoft.Resources/deployments', 'api'), '2022-09-01').outputs.SERVICE_API_URI.value)]" - }, "REACT_APP_APPLICATIONINSIGHTS_CONNECTION_STRING": { "type": "string", "value": "[reference(resourceId('Microsoft.Resources/deployments', 'monitoring'), '2022-09-01').outputs.applicationInsightsConnectionString.value]" - }, - "REACT_APP_WEB_BASE_URL": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'web'), '2022-09-01').outputs.SERVICE_WEB_URI.value]" - }, - "SERVICE_API_NAME": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'api'), '2022-09-01').outputs.SERVICE_API_NAME.value]" - }, - "SERVICE_WEB_NAME": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Resources/deployments', 'web'), '2022-09-01').outputs.SERVICE_WEB_NAME.value]" - }, - "USE_APIM": { - "type": "bool", - "value": "[parameters('useAPIM')]" - }, - "SERVICE_API_ENDPOINTS": { - "type": "array", - "value": "[if(parameters('useAPIM'), createArray(reference(resourceId('Microsoft.Resources/deployments', 'apim-api-deployment'), '2022-09-01').outputs.SERVICE_API_URI.value, reference(resourceId('Microsoft.Resources/deployments', 'api'), '2022-09-01').outputs.SERVICE_API_URI.value), createArray())]" } } } \ No newline at end of file