From b4866266b57b043d2a708574ffb1f503c72a3a3e Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Sun, 14 Dec 2025 09:04:04 +0000
Subject: [PATCH 1/2] Initial plan
From f3d62402df2c3e817faf149f9d87d4c07901dc77 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Sun, 14 Dec 2025 09:15:46 +0000
Subject: [PATCH 2/2] Add one-click deploy support with Azure infrastructure
Co-authored-by: paulyuk <1968137+paulyuk@users.noreply.github.com>
---
DEPLOYMENT.md | 177 +
README.md | 39 +-
azure.yaml | 26 +
infra/abbreviations.json | 135 +
...ost-capability-host-role-assignments.bicep | 108 +
.../standard-ai-project-capability-host.bicep | 43 +
...standard-ai-project-role-assignments.bicep | 251 +
infra/agent/standard-ai-project.bicep | 138 +
.../agent/standard-dependent-resources.bicep | 203 +
infra/app/api.bicep | 109 +
infra/app/rbac.bicep | 110 +
infra/app/storage-PrivateEndpoint.bicep | 181 +
infra/app/vnet.bicep | 48 +
infra/deploybutton/README.md | 27 +
infra/deploybutton/azuredeploy.json | 16936 ++++++++++++++++
.../deploybutton/azuredeploy.parameters.json | 12 +
infra/main.bicep | 397 +
infra/main.parameters.json | 12 +
infra/scripts/addclientip.ps1 | 42 +
infra/scripts/addclientip.sh | 56 +
infra/scripts/createlocalsettings.ps1 | 30 +
infra/scripts/createlocalsettings.sh | 40 +
infra/scripts/setuplocalenvironment.ps1 | 3 +
infra/scripts/setuplocalenvironment.sh | 4 +
24 files changed, 19121 insertions(+), 6 deletions(-)
create mode 100644 DEPLOYMENT.md
create mode 100644 azure.yaml
create mode 100644 infra/abbreviations.json
create mode 100644 infra/agent/post-capability-host-role-assignments.bicep
create mode 100644 infra/agent/standard-ai-project-capability-host.bicep
create mode 100644 infra/agent/standard-ai-project-role-assignments.bicep
create mode 100644 infra/agent/standard-ai-project.bicep
create mode 100644 infra/agent/standard-dependent-resources.bicep
create mode 100644 infra/app/api.bicep
create mode 100644 infra/app/rbac.bicep
create mode 100644 infra/app/storage-PrivateEndpoint.bicep
create mode 100644 infra/app/vnet.bicep
create mode 100644 infra/deploybutton/README.md
create mode 100644 infra/deploybutton/azuredeploy.json
create mode 100644 infra/deploybutton/azuredeploy.parameters.json
create mode 100644 infra/main.bicep
create mode 100644 infra/main.parameters.json
create mode 100644 infra/scripts/addclientip.ps1
create mode 100755 infra/scripts/addclientip.sh
create mode 100644 infra/scripts/createlocalsettings.ps1
create mode 100755 infra/scripts/createlocalsettings.sh
create mode 100644 infra/scripts/setuplocalenvironment.ps1
create mode 100755 infra/scripts/setuplocalenvironment.sh
diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md
new file mode 100644
index 0000000..3090a97
--- /dev/null
+++ b/DEPLOYMENT.md
@@ -0,0 +1,177 @@
+# Deployment Guide
+
+This document explains the deployment options for the Simple Agent Framework.
+
+## Deployment Options
+
+### Option 1: Azure Developer CLI (azd) - Recommended
+
+This is the easiest way to deploy the application with all required resources.
+
+```bash
+# Install azd if you haven't already
+# See: https://learn.microsoft.com/azure/developer/azure-developer-cli/install-azd
+
+# Clone the repository
+git clone https://github.com/paulyuk/simple-agent-af-python.git
+cd simple-agent-af-python
+
+# Login to Azure
+azd auth login
+
+# Deploy everything
+azd up
+```
+
+**What it does:**
+- Provisions all Azure resources using the Bicep templates in `/infra`
+- Deploys the Python application code
+- Configures all necessary environment variables
+- Sets up role assignments and managed identities
+- Runs post-provision scripts to set up local development environment
+
+**Resources created:**
+- Azure Functions app (Flex Consumption plan)
+- Azure AI Services with GPT-4.1-mini model deployment
+- Storage Account (for functions and AI workspace)
+- Application Insights and Log Analytics
+- All necessary managed identities and role assignments
+- Optional: Azure AI Search (disabled by default, enable with `enableAzureSearch=true`)
+- Optional: Cosmos DB for agent thread storage (disabled by default, enable with `enableCosmosDb=true`)
+
+### Option 2: Deploy to Azure Button (One-Click Deployment)
+
+Use the "Deploy to Azure" button for quick deployments without installing additional tools.
+
+[](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fpaulyuk%2Fsimple-agent-af-python%2Fmain%2Finfra%2Fdeploybutton%2Fazuredeploy.json)
+
+See [infra/deploybutton/README.md](infra/deploybutton/README.md) for more details.
+
+**Note:** The ARM template is auto-generated from the Bicep files when changes are pushed to the main branch.
+
+### Option 3: Manual Bicep Deployment
+
+If you prefer to deploy using Azure CLI directly:
+
+```bash
+# Login to Azure
+az login
+
+# Set your subscription
+az account set --subscription
+
+# Create a resource group
+az group create --name rg-simple-agent --location eastus
+
+# Deploy the Bicep template
+az deployment sub create \
+ --location eastus \
+ --template-file infra/main.bicep \
+ --parameters environmentName=simple-agent location=eastus
+```
+
+## Configuration
+
+### Required Parameters
+
+- **environmentName**: A unique name for your environment (used to generate resource names)
+- **location**: The Azure region where resources will be deployed
+
+### Optional Parameters
+
+All other parameters have secure defaults, but you can override them:
+
+- **modelName**: Default is "gpt-4.1-mini"
+- **modelVersion**: Default is "2024-07-18"
+- **modelSkuName**: Default is "GlobalStandard"
+- **modelCapacity**: Default is 50
+- **enableAzureSearch**: Default is `false` (set to `true` to enable Azure AI Search for vector store)
+- **enableCosmosDb**: Default is `false` (set to `true` to enable Cosmos DB for agent thread storage)
+
+See [infra/main.bicep](infra/main.bicep) for the full list of parameters.
+
+## After Deployment
+
+### For Local Development
+
+After deploying with `azd up`:
+
+1. The post-provision script automatically creates a `local.settings.json` file
+2. Run the application locally:
+ ```bash
+ python main.py
+ ```
+
+### Get Configuration Values
+
+To get the deployed configuration:
+
+```bash
+# Using azd
+azd env get-values
+
+# Or using Azure CLI
+az functionapp config appsettings list \
+ --name \
+ --resource-group
+```
+
+## Updating the Deployment
+
+To update an existing deployment:
+
+```bash
+# Using azd
+azd up
+
+# Or using Azure CLI
+az deployment sub create \
+ --location eastus \
+ --template-file infra/main.bicep \
+ --parameters @infra/main.parameters.json
+```
+
+## Cleaning Up
+
+To delete all resources:
+
+```bash
+# Using azd
+azd down
+
+# Or using Azure CLI
+az group delete --name --yes
+```
+
+## Troubleshooting
+
+### Common Issues
+
+1. **Insufficient permissions**: Ensure you have Owner or Contributor + User Access Administrator roles
+2. **Resource name conflicts**: Use a unique environmentName to avoid naming conflicts
+3. **Region availability**: Some regions may not support all required services (Flex Consumption, AI services)
+
+### Logs and Monitoring
+
+- Application Insights: Monitor your function app performance and logs
+- Log Analytics: Query logs across all resources
+- Function App logs: `az functionapp logs tail --name --resource-group `
+
+## Architecture
+
+The deployment creates the following architecture:
+
+```
+Azure Subscription
+└── Resource Group
+ ├── Azure Functions (Flex Consumption with Python runtime)
+ ├── Azure AI Services (with GPT-4o-mini)
+ ├── Azure AI Search
+ ├── Cosmos DB
+ ├── Storage Account
+ ├── Application Insights
+ ├── Log Analytics Workspace
+ └── Managed Identities
+```
+
+All resources are connected using managed identities and role-based access control (RBAC) for secure, passwordless authentication.
diff --git a/README.md b/README.md
index 39a7bd3..bb0df6f 100644
--- a/README.md
+++ b/README.md
@@ -8,8 +8,35 @@ This application demonstrates how to create a simple AI agent using Azure AI and
+## Deploy to Azure
+
+### Quick Start Options
+
+1. **One-Click Deploy**: [](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fpaulyuk%2Fsimple-agent-af-python%2Fmain%2Finfra%2Fdeploybutton%2Fazuredeploy.json)
+
+2. **Azure Developer CLI** (Recommended):
+ ```bash
+ azd auth login
+ azd up
+ ```
+
+For detailed deployment instructions, see [DEPLOYMENT.md](DEPLOYMENT.md).
+
+### What Gets Deployed
+
+- Azure Functions app with Python 3.11 runtime (Flex Consumption plan)
+- Azure AI services with GPT-4.1-mini model
+- Storage, monitoring, and all necessary role assignments
+- Optional: Azure AI Search (for vector store capabilities, disabled by default)
+- Optional: Cosmos DB (for agent thread storage, disabled by default)
+
## Prerequisites
+### For Azure Deployment
+- [Azure Developer CLI (azd)](https://learn.microsoft.com/azure/developer/azure-developer-cli/install-azd)
+- Azure subscription
+
+### For Local Development
- Python 3.10+
- Azure AI project with a deployed model
- Azure CLI for authentication
@@ -29,7 +56,9 @@ Set the following environment variables:
**Note**: This project uses the Azure AI Agent Framework to connect to Azure AI projects.
-## Setup
+## Local Development Usage
+
+After deploying to Azure or setting up your own Azure OpenAI resources:
1. Clone the repository
2. Create a virtual environment (recommended):
@@ -49,7 +78,7 @@ pip install -U agent-framework --pre
pip install -r requirements.txt
```
-4. Set the required environment variables:
+4. Set the required environment variables (or use `azd env get-values` after deployment):
```bash
# On Windows PowerShell
@@ -61,15 +90,13 @@ export AZURE_OPENAI_ENDPOINT="https://agent-ai-.openai.azure.com/"
export AZURE_OPENAI_DEPLOYMENT_NAME="chat"
```
-## Usage
-
-Run the application:
+5. Run the application:
```bash
python main.py
```
-Enter a message like `what are the laws?`
+6. Enter a message like `what are the laws?`
The application will start an interactive conversation loop where you can ask questions. Type 'exit' or 'quit' to end the session.
diff --git a/azure.yaml b/azure.yaml
new file mode 100644
index 0000000..e35d82f
--- /dev/null
+++ b/azure.yaml
@@ -0,0 +1,26 @@
+# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json
+
+name: simple-agent-framework-functions-python
+metadata:
+ template: simple-agent-framework-functions-python@2.0.0
+services:
+ api:
+ project: ./
+ host: function
+ language: python
+hooks:
+ postprovision:
+ posix:
+ shell: sh
+ run: ./infra/scripts/setuplocalenvironment.sh
+ interactive: true
+ continueOnError: false
+ windows:
+ shell: pwsh
+ run: ./infra/scripts/setuplocalenvironment.ps1
+ interactive: true
+ continueOnError: false
+ postdeploy:
+ shell: sh
+ run: echo "Deployment completed successfully"
+ continueOnError: false
\ No newline at end of file
diff --git a/infra/abbreviations.json b/infra/abbreviations.json
new file mode 100644
index 0000000..a4fc9df
--- /dev/null
+++ b/infra/abbreviations.json
@@ -0,0 +1,135 @@
+{
+ "analysisServicesServers": "as",
+ "apiManagementService": "apim-",
+ "appConfigurationConfigurationStores": "appcs-",
+ "appManagedEnvironments": "cae-",
+ "appContainerApps": "ca-",
+ "authorizationPolicyDefinitions": "policy-",
+ "automationAutomationAccounts": "aa-",
+ "blueprintBlueprints": "bp-",
+ "blueprintBlueprintsArtifacts": "bpa-",
+ "cacheRedis": "redis-",
+ "cdnProfiles": "cdnp-",
+ "cdnProfilesEndpoints": "cdne-",
+ "cognitiveServicesAccounts": "cog-",
+ "cognitiveServicesFormRecognizer": "cog-fr-",
+ "cognitiveServicesTextAnalytics": "cog-ta-",
+ "computeAvailabilitySets": "avail-",
+ "computeCloudServices": "cld-",
+ "computeDiskEncryptionSets": "des",
+ "computeDisks": "disk",
+ "computeDisksOs": "osdisk",
+ "computeGalleries": "gal",
+ "computeSnapshots": "snap-",
+ "computeVirtualMachines": "vm",
+ "computeVirtualMachineScaleSets": "vmss-",
+ "containerInstanceContainerGroups": "ci",
+ "containerRegistryRegistries": "cr",
+ "containerServiceManagedClusters": "aks-",
+ "databricksWorkspaces": "dbw-",
+ "dataFactoryFactories": "adf-",
+ "dataLakeAnalyticsAccounts": "dla",
+ "dataLakeStoreAccounts": "dls",
+ "dataMigrationServices": "dms-",
+ "dBforMySQLServers": "mysql-",
+ "dBforPostgreSQLServers": "psql-",
+ "devicesIotHubs": "iot-",
+ "devicesProvisioningServices": "provs-",
+ "devicesProvisioningServicesCertificates": "pcert-",
+ "documentDBDatabaseAccounts": "cosmos-",
+ "eventGridDomains": "evgd-",
+ "eventGridDomainsTopics": "evgt-",
+ "eventGridEventSubscriptions": "evgs-",
+ "eventHubNamespaces": "evhns-",
+ "eventHubNamespacesEventHubs": "evh-",
+ "hdInsightClustersHadoop": "hadoop-",
+ "hdInsightClustersHbase": "hbase-",
+ "hdInsightClustersKafka": "kafka-",
+ "hdInsightClustersMl": "mls-",
+ "hdInsightClustersSpark": "spark-",
+ "hdInsightClustersStorm": "storm-",
+ "hybridComputeMachines": "arcs-",
+ "insightsActionGroups": "ag-",
+ "insightsComponents": "appi-",
+ "keyVaultVaults": "kv-",
+ "kubernetesConnectedClusters": "arck",
+ "kustoClusters": "dec",
+ "kustoClustersDatabases": "dedb",
+ "logicIntegrationAccounts": "ia-",
+ "logicWorkflows": "logic-",
+ "machineLearningServicesWorkspaces": "mlw-",
+ "managedIdentityUserAssignedIdentities": "id-",
+ "managementManagementGroups": "mg-",
+ "migrateAssessmentProjects": "migr-",
+ "networkApplicationGateways": "agw-",
+ "networkApplicationSecurityGroups": "asg-",
+ "networkAzureFirewalls": "afw-",
+ "networkBastionHosts": "bas-",
+ "networkConnections": "con-",
+ "networkDnsZones": "dnsz-",
+ "networkExpressRouteCircuits": "erc-",
+ "networkFirewallPolicies": "afwp-",
+ "networkFirewallPoliciesWebApplication": "waf",
+ "networkFirewallPoliciesRuleGroups": "wafrg",
+ "networkFrontDoors": "fd-",
+ "networkFrontdoorWebApplicationFirewallPolicies": "fdfp-",
+ "networkLoadBalancersExternal": "lbe-",
+ "networkLoadBalancersInternal": "lbi-",
+ "networkLoadBalancersInboundNatRules": "rule-",
+ "networkLocalNetworkGateways": "lgw-",
+ "networkNatGateways": "ng-",
+ "networkNetworkInterfaces": "nic-",
+ "networkNetworkSecurityGroups": "nsg-",
+ "networkNetworkSecurityGroupsSecurityRules": "nsgsr-",
+ "networkNetworkWatchers": "nw-",
+ "networkPrivateDnsZones": "pdnsz-",
+ "networkPrivateLinkServices": "pl-",
+ "networkPublicIPAddresses": "pip-",
+ "networkPublicIPPrefixes": "ippre-",
+ "networkRouteFilters": "rf-",
+ "networkRouteTables": "rt-",
+ "networkRouteTablesRoutes": "udr-",
+ "networkTrafficManagerProfiles": "traf-",
+ "networkVirtualNetworkGateways": "vgw-",
+ "networkVirtualNetworks": "vnet-",
+ "networkVirtualNetworksSubnets": "snet-",
+ "networkVirtualNetworksVirtualNetworkPeerings": "peer-",
+ "networkVirtualWans": "vwan-",
+ "networkVpnGateways": "vpng-",
+ "networkVpnGatewaysVpnConnections": "vcn-",
+ "networkVpnGatewaysVpnSites": "vst-",
+ "notificationHubsNamespaces": "ntfns-",
+ "notificationHubsNamespacesNotificationHubs": "ntf-",
+ "operationalInsightsWorkspaces": "log-",
+ "portalDashboards": "dash-",
+ "powerBIDedicatedCapacities": "pbi-",
+ "purviewAccounts": "pview-",
+ "recoveryServicesVaults": "rsv-",
+ "resourcesResourceGroups": "rg-",
+ "searchSearchServices": "srch-",
+ "serviceBusNamespaces": "sb-",
+ "serviceBusNamespacesQueues": "sbq-",
+ "serviceBusNamespacesTopics": "sbt-",
+ "serviceEndPointPolicies": "se-",
+ "serviceFabricClusters": "sf-",
+ "signalRServiceSignalR": "sigr",
+ "sqlManagedInstances": "sqlmi-",
+ "sqlServers": "sql-",
+ "sqlServersDataWarehouse": "sqldw-",
+ "sqlServersDatabases": "sqldb-",
+ "sqlServersDatabasesStretch": "sqlstrdb-",
+ "storageStorageAccounts": "st",
+ "storageStorageAccountsVm": "stvm",
+ "storSimpleManagers": "ssimp",
+ "streamAnalyticsCluster": "asa-",
+ "synapseWorkspaces": "syn",
+ "synapseWorkspacesAnalyticsWorkspaces": "synw",
+ "synapseWorkspacesSqlPoolsDedicated": "syndp",
+ "synapseWorkspacesSqlPoolsSpark": "synsp",
+ "timeSeriesInsightsEnvironments": "tsi-",
+ "webServerFarms": "plan-",
+ "webSitesAppService": "app-",
+ "webSitesAppServiceEnvironment": "ase-",
+ "webSitesFunctions": "func-",
+ "webStaticSites": "stapp-"
+}
\ No newline at end of file
diff --git a/infra/agent/post-capability-host-role-assignments.bicep b/infra/agent/post-capability-host-role-assignments.bicep
new file mode 100644
index 0000000..c431e69
--- /dev/null
+++ b/infra/agent/post-capability-host-role-assignments.bicep
@@ -0,0 +1,108 @@
+// These must be created post-capability host addition because otherwise
+// the containers will not yet exist.
+
+param aiProjectPrincipalId string
+param aiProjectPrincipalType string = 'ServicePrincipal' // Workaround for https://learn.microsoft.com/en-us/azure/role-based-access-control/role-assignments-template#new-service-principal
+param aiProjectWorkspaceId string
+
+param aiStorageAccountName string
+param cosmosDbAccountName string
+
+param enableCosmosDb bool = false
+
+// Assignments for Storage Account containers
+// ------------------------------------------------------------------
+
+resource storage 'Microsoft.Storage/storageAccounts@2022-05-01' existing = {
+ name: aiStorageAccountName
+}
+
+// Assign AI Project Storage Blob Data Owner Role for the dependent resource storage account.
+// Limits ownership to containers specific to the Project Workspace.
+
+var storageBlobDataOwnerRoleDefinitionId = 'b7e6dc6d-f1e8-4753-8033-0f276bb0955b'
+var conditionStr = '((!(ActionMatches{\'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/tags/read\'}) AND !(ActionMatches{\'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/filter/action\'}) AND !(ActionMatches{\'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/tags/write\'}) ) OR (@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:name] StringStartsWithIgnoreCase \'${aiProjectWorkspaceId}\' AND @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:name] StringLikeIgnoreCase \'*-azureml-agent\'))'
+
+resource storageBlobDataOwnerAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
+ scope: storage
+ name: guid(storage.id, aiProjectPrincipalId, storageBlobDataOwnerRoleDefinitionId, aiProjectWorkspaceId)
+ properties: {
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', storageBlobDataOwnerRoleDefinitionId)
+ principalId: aiProjectPrincipalId
+ principalType: aiProjectPrincipalType
+ conditionVersion: '2.0'
+ condition: conditionStr
+ }
+}
+
+// Assignments for CosmosDB containers
+// ------------------------------------------------------------------
+
+var userThreadName = '${aiProjectWorkspaceId}-thread-message-store'
+var systemThreadName = '${aiProjectWorkspaceId}-system-thread-message-store'
+var entityStoreName = '${aiProjectWorkspaceId}-agent-entity-store'
+
+resource cosmosAccount 'Microsoft.DocumentDB/databaseAccounts@2024-12-01-preview' existing = if (enableCosmosDb) {
+ name: cosmosDbAccountName
+}
+
+// Reference existing database
+resource database 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@2024-12-01-preview' existing = if (enableCosmosDb) {
+ parent: cosmosAccount
+ name: 'enterprise_memory'
+}
+
+resource containerUserMessageStore 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2024-12-01-preview' existing = if (enableCosmosDb) {
+ parent: database
+ name: userThreadName
+}
+
+resource containerSystemMessageStore 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2024-12-01-preview' existing = if (enableCosmosDb) {
+ parent: database
+ name: systemThreadName
+}
+
+resource containerEntityStore 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2024-12-01-preview' existing = if (enableCosmosDb) {
+ parent: database
+ name: entityStoreName
+}
+
+var roleDefinitionId = enableCosmosDb ? resourceId(
+ 'Microsoft.DocumentDB/databaseAccounts/sqlRoleDefinitions',
+ cosmosDbAccountName,
+ '00000000-0000-0000-0000-000000000002'
+) : ''
+
+var scopeSystemContainer = enableCosmosDb ? '${cosmosAccount.id}/dbs/enterprise_memory/colls/${systemThreadName}' : ''
+var scopeUserContainer = enableCosmosDb ? '${cosmosAccount.id}/dbs/enterprise_memory/colls/${userThreadName}' : ''
+var scopeEntityContainer = enableCosmosDb ? '${cosmosAccount.id}/dbs/enterprise_memory/colls/${entityStoreName}' : ''
+
+resource containerRoleAssignmentUserContainer 'Microsoft.DocumentDB/databaseAccounts/sqlRoleAssignments@2022-05-15' = if (enableCosmosDb) {
+ parent: cosmosAccount
+ name: guid(aiProjectWorkspaceId, containerUserMessageStore.id, roleDefinitionId, aiProjectPrincipalId)
+ properties: {
+ principalId: aiProjectPrincipalId
+ roleDefinitionId: roleDefinitionId
+ scope: scopeUserContainer
+ }
+}
+
+resource containerRoleAssignmentSystemContainer 'Microsoft.DocumentDB/databaseAccounts/sqlRoleAssignments@2022-05-15' = if (enableCosmosDb) {
+ parent: cosmosAccount
+ name: guid(aiProjectWorkspaceId, containerSystemMessageStore.id, roleDefinitionId, aiProjectPrincipalId)
+ properties: {
+ principalId: aiProjectPrincipalId
+ roleDefinitionId: roleDefinitionId
+ scope: scopeSystemContainer
+ }
+}
+
+resource containerRoleAssignmentEntityContainer 'Microsoft.DocumentDB/databaseAccounts/sqlRoleAssignments@2022-05-15' = if (enableCosmosDb) {
+ parent: cosmosAccount
+ name: guid(aiProjectWorkspaceId, containerEntityStore.id, roleDefinitionId, aiProjectPrincipalId)
+ properties: {
+ principalId: aiProjectPrincipalId
+ roleDefinitionId: roleDefinitionId
+ scope: scopeEntityContainer
+ }
+}
diff --git a/infra/agent/standard-ai-project-capability-host.bicep b/infra/agent/standard-ai-project-capability-host.bicep
new file mode 100644
index 0000000..91d1589
--- /dev/null
+++ b/infra/agent/standard-ai-project-capability-host.bicep
@@ -0,0 +1,43 @@
+param cosmosDbConnection string
+param azureStorageConnection string
+param aiSearchConnection string
+param projectName string
+param aiServicesAccountName string
+param projectCapHost string
+param accountCapHost string
+
+param enableAzureSearch bool = false
+param enableCosmosDb bool = false
+
+resource account 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' existing = {
+ name: aiServicesAccountName
+}
+
+resource project 'Microsoft.CognitiveServices/accounts/projects@2025-04-01-preview' existing = {
+ name: projectName
+ parent: account
+}
+
+resource accountCapabilityHost 'Microsoft.CognitiveServices/accounts/capabilityHosts@2025-04-01-preview' = {
+ name: accountCapHost
+ parent: account
+ properties: {
+ capabilityHostKind: 'Agents'
+ }
+}
+
+resource projectCapabilityHost 'Microsoft.CognitiveServices/accounts/projects/capabilityHosts@2025-04-01-preview' = {
+ name: projectCapHost
+ parent: project
+ properties: union(
+ {
+ capabilityHostKind: 'Agents'
+ storageConnections: ['${azureStorageConnection}']
+ },
+ enableAzureSearch ? { vectorStoreConnections: ['${aiSearchConnection}'] } : {},
+ enableCosmosDb ? { threadStorageConnections: ['${cosmosDbConnection}'] } : {}
+ )
+ dependsOn: [
+ accountCapabilityHost
+ ]
+}
diff --git a/infra/agent/standard-ai-project-role-assignments.bicep b/infra/agent/standard-ai-project-role-assignments.bicep
new file mode 100644
index 0000000..0164e9d
--- /dev/null
+++ b/infra/agent/standard-ai-project-role-assignments.bicep
@@ -0,0 +1,251 @@
+param aiProjectPrincipalId string
+param aiProjectPrincipalType string = 'ServicePrincipal' // Workaround for https://learn.microsoft.com/en-us/azure/role-based-access-control/role-assignments-template#new-service-principal
+param userPrincipalId string = ''
+param allowUserIdentityPrincipal bool = false // Flag to enable user identity role assignments
+
+param aiServicesName string
+param aiSearchName string
+param aiCosmosDbName string
+param aiStorageAccountName string
+
+param integrationStorageAccountName string
+
+// Parameters for function app managed identity
+param functionAppManagedIdentityPrincipalId string = ''
+param allowFunctionAppIdentityPrincipal bool = true // Flag to enable function app identity role assignments
+
+// Parameters for optional resources
+param enableAzureSearch bool = false
+param enableCosmosDb bool = false
+
+// Assignments for AI Services
+// ------------------------------------------------------------------
+
+resource aiServices 'Microsoft.CognitiveServices/accounts@2024-06-01-preview' existing = {
+ name: aiServicesName
+}
+
+// Assign AI Project the Cognitive Services Contributor Role on the AI Services resource
+
+var cognitiveServicesContributorRoleDefinitionId = '25fbc0a9-bd7c-42a3-aa1a-3b75d497ee68'
+
+resource cognitiveServicesContributorAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01'= {
+ scope: aiServices
+ name: guid(aiServices.id, cognitiveServicesContributorRoleDefinitionId, aiProjectPrincipalId)
+ properties: {
+ principalId: aiProjectPrincipalId
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', cognitiveServicesContributorRoleDefinitionId)
+ principalType: aiProjectPrincipalType
+ }
+}
+
+// Assign AI Project the Cognitive Services OpenAI User Role on the AI Services resource
+
+var cognitiveServicesOpenAIUserRoleDefinitionId = '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd'
+
+resource cognitiveServicesOpenAIUserRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
+ scope: aiServices
+ name: guid(aiProjectPrincipalId, cognitiveServicesOpenAIUserRoleDefinitionId, aiServices.id)
+ properties: {
+ principalId: aiProjectPrincipalId
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', cognitiveServicesOpenAIUserRoleDefinitionId)
+ principalType: aiProjectPrincipalType
+ }
+}
+
+// Assign AI Project the Cognitive Services User Role on the AI Services resource
+
+var cognitiveServicesUserRoleDefinitionId = 'a97b65f3-24c7-4388-baec-2e87135dc908'
+
+resource cognitiveServicesUserRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
+ scope: aiServices
+ name: guid(aiProjectPrincipalId, cognitiveServicesUserRoleDefinitionId, aiServices.id)
+ properties: {
+ principalId: aiProjectPrincipalId
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', cognitiveServicesUserRoleDefinitionId)
+ principalType: aiProjectPrincipalType
+ }
+}
+
+// Assign AI Project the Cognitive Services Contributor Role on the User Identity Principal on the AI Services resource
+
+resource cognitiveServicesContributorAssignmentUser 'Microsoft.Authorization/roleAssignments@2022-04-01'= if (allowUserIdentityPrincipal && !empty(userPrincipalId)) {
+ scope: aiServices
+ name: guid(aiServices.id, cognitiveServicesContributorRoleDefinitionId, userPrincipalId)
+ properties: {
+ principalId: userPrincipalId
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', cognitiveServicesContributorRoleDefinitionId)
+ principalType: 'User'
+ }
+}
+
+// Assign AI Project the Cognitive Services OpenAI User Role on the User Identity Principal on the AI Services resource
+
+resource cognitiveServicesOpenAIUserRoleAssignmentUser 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (allowUserIdentityPrincipal && !empty(userPrincipalId)){
+ scope: aiServices
+ name: guid(userPrincipalId, cognitiveServicesOpenAIUserRoleDefinitionId, aiServices.id)
+ properties: {
+ principalId: userPrincipalId
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', cognitiveServicesOpenAIUserRoleDefinitionId)
+ principalType: 'User'
+ }
+}
+
+// Assign AI Project the Cognitive Services User Role on the User Identity Principal on the AI Services resource
+
+resource cognitiveServicesUserRoleAssignmentUser 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (allowUserIdentityPrincipal && !empty(userPrincipalId)){
+ scope: aiServices
+ name: guid(userPrincipalId, cognitiveServicesUserRoleDefinitionId, aiServices.id)
+ properties: {
+ principalId: userPrincipalId
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', cognitiveServicesUserRoleDefinitionId)
+ principalType: 'User'
+ }
+}
+
+// Assignments for AI Search Service
+// ------------------------------------------------------------------
+
+resource aiSearchService 'Microsoft.Search/searchServices@2024-06-01-preview' existing = if (enableAzureSearch) {
+ name: aiSearchName
+}
+
+// Assign AI Project the Search Index Data Contributor Role on the AI Search Service resource
+
+var searchIndexDataContributorRoleDefinitionId = '8ebe5a00-799e-43f5-93ac-243d3dce84a7'
+
+resource searchIndexDataContributorAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (enableAzureSearch) {
+ scope: aiSearchService
+ name: guid(aiProjectPrincipalId, searchIndexDataContributorRoleDefinitionId, aiSearchService.id)
+ properties: {
+ principalId: aiProjectPrincipalId
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', searchIndexDataContributorRoleDefinitionId)
+ principalType: aiProjectPrincipalType
+ }
+}
+
+// Assign AI Project the Search Index Data Contributor Role on the AI Search Service resource
+
+var searchServiceContributorRoleDefinitionId = '7ca78c08-252a-4471-8644-bb5ff32d4ba0'
+
+resource searchServiceContributorRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (enableAzureSearch) {
+ scope: aiSearchService
+ name: guid(aiProjectPrincipalId, searchServiceContributorRoleDefinitionId, aiSearchService.id)
+ properties: {
+ principalId: aiProjectPrincipalId
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', searchServiceContributorRoleDefinitionId)
+ principalType: aiProjectPrincipalType
+ }
+}
+
+// Assignments for Storage Account
+// ------------------------------------------------------------------
+
+resource aiStorageAccount 'Microsoft.Storage/storageAccounts@2024-01-01' existing = {
+ name: aiStorageAccountName
+}
+
+// Assign AI Project the Storage Blob Data Contributor Role on the Storage Account resource
+
+var storageBlobDataContributorRoleDefinitionId = 'ba92f5b4-2d11-453d-a403-e96b0029c9fe'
+
+resource storageBlobDataContributorRoleAssignmentProject 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
+ scope: aiStorageAccount
+ name: guid(aiProjectPrincipalId, storageBlobDataContributorRoleDefinitionId, aiStorageAccount.id)
+ properties: {
+ principalId: aiProjectPrincipalId
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', storageBlobDataContributorRoleDefinitionId)
+ principalType: aiProjectPrincipalType
+ }
+}
+
+// Assignments for Cosmos DB
+// ------------------------------------------------------------------
+
+resource cosmosDbAccount 'Microsoft.DocumentDB/databaseAccounts@2024-12-01-preview' existing = if (enableCosmosDb) {
+ name: aiCosmosDbName
+}
+
+// Assign AI Project the Cosmos DB Operator Role on the Cosmos DB Account resource
+
+var cosmosDbOperatorRoleDefinitionId = '230815da-be43-4aae-9cb4-875f7bd000aa'
+
+resource cosmosDbOperatorRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (enableCosmosDb) {
+ scope: cosmosDbAccount
+ name: guid(aiProjectPrincipalId, cosmosDbOperatorRoleDefinitionId, cosmosDbAccount.id)
+ properties: {
+ principalId: aiProjectPrincipalId
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', cosmosDbOperatorRoleDefinitionId)
+ principalType: aiProjectPrincipalType
+ }
+}
+
+// Assignments for Storage Account
+// ------------------------------------------------------------------
+
+resource integrationStorageAccount 'Microsoft.Storage/storageAccounts@2024-01-01' existing = {
+ name: integrationStorageAccountName
+}
+
+// Assign AI Project Storage Queue Data Contributor Role on the integration Storage Account resource
+// between the agent and azure function
+
+var storageQueueDataContributorRoleDefinitionId = '974c5e8b-45b9-4653-ba55-5f855dd0fb88'
+
+resource storageQueueDataContributorRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
+ name: guid(integrationStorageAccount.id, aiProjectPrincipalId, storageQueueDataContributorRoleDefinitionId)
+ scope: integrationStorageAccount
+ properties: {
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', storageQueueDataContributorRoleDefinitionId)
+ principalId: aiProjectPrincipalId
+ principalType: aiProjectPrincipalType
+ }
+}
+
+// assignments for User Identity Principal
+
+resource storageQueueDataContributorRoleAssignmentUser 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (allowUserIdentityPrincipal && !empty(userPrincipalId)) {
+ name: guid(integrationStorageAccount.id, userPrincipalId, storageQueueDataContributorRoleDefinitionId)
+ scope: integrationStorageAccount
+ properties: {
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', storageQueueDataContributorRoleDefinitionId)
+ principalId: userPrincipalId
+ principalType: 'User'
+ }
+}
+
+// Assign Function App Managed Identity the Cognitive Services Contributor Role on the AI Services resource
+
+resource cognitiveServicesContributorAssignmentFunctionApp 'Microsoft.Authorization/roleAssignments@2022-04-01'= if (allowFunctionAppIdentityPrincipal && !empty(functionAppManagedIdentityPrincipalId)) {
+ scope: aiServices
+ name: guid(aiServices.id, cognitiveServicesContributorRoleDefinitionId, functionAppManagedIdentityPrincipalId)
+ properties: {
+ principalId: functionAppManagedIdentityPrincipalId
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', cognitiveServicesContributorRoleDefinitionId)
+ principalType: 'ServicePrincipal'
+ }
+}
+
+// Assign Function App Managed Identity the Cognitive Services OpenAI User Role on the AI Services resource
+
+resource cognitiveServicesOpenAIUserRoleAssignmentFunctionApp 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (allowFunctionAppIdentityPrincipal && !empty(functionAppManagedIdentityPrincipalId)) {
+ scope: aiServices
+ name: guid(functionAppManagedIdentityPrincipalId, cognitiveServicesOpenAIUserRoleDefinitionId, aiServices.id)
+ properties: {
+ principalId: functionAppManagedIdentityPrincipalId
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', cognitiveServicesOpenAIUserRoleDefinitionId)
+ principalType: 'ServicePrincipal'
+ }
+}
+
+// Assign Function App Managed Identity the Cognitive Services User Role on the AI Services resource
+
+resource cognitiveServicesUserRoleAssignmentFunctionApp 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (allowFunctionAppIdentityPrincipal && !empty(functionAppManagedIdentityPrincipalId)) {
+ scope: aiServices
+ name: guid(functionAppManagedIdentityPrincipalId, cognitiveServicesUserRoleDefinitionId, aiServices.id)
+ properties: {
+ principalId: functionAppManagedIdentityPrincipalId
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', cognitiveServicesUserRoleDefinitionId)
+ principalType: 'ServicePrincipal'
+ }
+}
diff --git a/infra/agent/standard-ai-project.bicep b/infra/agent/standard-ai-project.bicep
new file mode 100644
index 0000000..9d58b7a
--- /dev/null
+++ b/infra/agent/standard-ai-project.bicep
@@ -0,0 +1,138 @@
+// Creates an Azure AI resource with proxied endpoints for the Azure AI services provider
+
+@description('Azure region of the deployment')
+param location string
+
+@description('Tags to add to the resources')
+param tags object
+
+@description('AI Services Foundry account under which the project will be created')
+param aiServicesAccountName string
+
+@description('AI Project name')
+param aiProjectName string
+
+@description('AI Project display name')
+param aiProjectFriendlyName string = aiProjectName
+
+@description('AI Project description')
+param aiProjectDescription string
+
+@description('Enable Azure AI Search for vector store and search capabilities')
+param enableAzureSearch bool = false
+
+@description('Enable Cosmos DB for agent thread storage')
+param enableCosmosDb bool = false
+
+@description('Cosmos DB Account for agent thread storage')
+param cosmosDbAccountName string
+param cosmosDbAccountSubscriptionId string
+param cosmosDbAccountResourceGroupName string
+
+@description('Storage Account for agent artifacts')
+param storageAccountName string
+param storageAccountSubscriptionId string
+param storageAccountResourceGroupName string
+
+@description('AI Search Service for vector store and search')
+param aiSearchName string
+param aiSearchSubscriptionId string
+param aiSearchResourceGroupName string
+
+resource cosmosDbAccount 'Microsoft.DocumentDB/databaseAccounts@2024-11-15' existing = if (enableCosmosDb) {
+ name: cosmosDbAccountName
+ scope: resourceGroup(cosmosDbAccountSubscriptionId, cosmosDbAccountResourceGroupName)
+}
+
+resource storageAccount 'Microsoft.Storage/storageAccounts@2024-01-01' existing = {
+ name: storageAccountName
+ scope: resourceGroup(storageAccountSubscriptionId, storageAccountResourceGroupName)
+}
+
+resource aiSearchService 'Microsoft.Search/searchServices@2024-06-01-preview' existing = if (enableAzureSearch) {
+ name: aiSearchName
+ scope: resourceGroup(aiSearchSubscriptionId, aiSearchResourceGroupName)
+}
+
+resource aiServicesAccount 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' existing = {
+ name: aiServicesAccountName
+}
+
+resource aiProject 'Microsoft.CognitiveServices/accounts/projects@2025-04-01-preview' = {
+ parent: aiServicesAccount
+ name: aiProjectName
+ location: location
+ tags: tags
+ identity: {
+ type: 'SystemAssigned'
+ }
+ properties: {
+ description: aiProjectDescription
+ displayName: aiProjectFriendlyName
+ }
+
+ resource project_connection_cosmosdb_account 'connections@2025-04-01-preview' = if (enableCosmosDb) {
+ name: cosmosDbAccountName
+ properties: {
+ category: 'CosmosDB'
+ target: cosmosDbAccount.properties.documentEndpoint
+ authType: 'AAD'
+ metadata: {
+ ApiType: 'Azure'
+ ResourceId: cosmosDbAccount.id
+ location: cosmosDbAccount.location
+ }
+ }
+ }
+
+ resource project_connection_azure_storage 'connections@2025-04-01-preview' = {
+ name: storageAccountName
+ properties: {
+ category: 'AzureStorageAccount'
+ target: storageAccount.properties.primaryEndpoints.blob
+ authType: 'AAD'
+ metadata: {
+ ApiType: 'Azure'
+ ResourceId: storageAccount.id
+ location: storageAccount.location
+ }
+ }
+ }
+
+ resource project_connection_azureai_search 'connections@2025-04-01-preview' = if (enableAzureSearch) {
+ name: aiSearchName
+ properties: {
+ category: 'CognitiveSearch'
+ target: 'https://${aiSearchName}.search.windows.net'
+ authType: 'AAD'
+ metadata: {
+ ApiType: 'Azure'
+ ResourceId: aiSearchService.id
+ location: aiSearchService.location
+ }
+ }
+ }
+}
+
+// Outputs
+
+output aiProjectName string = aiProject.name
+output aiProjectResourceId string = aiProject.id
+output aiProjectPrincipalId string = aiProject.identity.principalId
+
+output aiSearchConnection string = aiSearchName
+output azureStorageConnection string = storageAccountName
+output cosmosDbConnection string = cosmosDbAccountName
+
+// This is used for storage naming conventions and is needed to help
+// create the right fine-grained role assignments. The naming
+// convention also uses dashes injected into the value, so we're
+// handling that here.
+// This will likely change or be made available via a different property.
+#disable-next-line BCP053
+var internalId = aiProject.properties.internalId
+output projectWorkspaceId string = '${substring(internalId, 0, 8)}-${substring(internalId, 8, 4)}-${substring(internalId, 12, 4)}-${substring(internalId, 16, 4)}-${substring(internalId, 20, 12)}'
+
+// This endpoint is also built by convention at this time but will
+// hopefully be available as a different property at some point.
+output projectEndpoint string = 'https://${aiServicesAccountName}.services.ai.azure.com/api/projects/${aiProjectName}'
diff --git a/infra/agent/standard-dependent-resources.bicep b/infra/agent/standard-dependent-resources.bicep
new file mode 100644
index 0000000..4819333
--- /dev/null
+++ b/infra/agent/standard-dependent-resources.bicep
@@ -0,0 +1,203 @@
+// Creates Azure dependent resources for Azure AI studio
+
+@description('Azure region of the deployment')
+param location string = resourceGroup().location
+
+@description('Tags to add to the resources')
+param tags object = {}
+
+@description('AI services name')
+param aiServicesName string
+
+@description('The name of the AI Search resource')
+param aiSearchName string
+
+@description('Enable Azure AI Search resource creation')
+param enableAzureSearch bool = false
+
+@description('The name of the Cosmos DB account')
+param cosmosDbName string
+
+@description('Enable Cosmos DB resource creation')
+param enableCosmosDb bool = false
+
+@description('Name of the storage account')
+param storageName string
+
+@description('Model name for deployment')
+param modelName string
+
+@description('Model format for deployment')
+param modelFormat string
+
+@description('Model version for deployment')
+param modelVersion string
+
+@description('Model deployment SKU name')
+param modelSkuName string
+
+@description('Model deployment capacity')
+param modelCapacity int
+
+@description('Name for the model deployment in Azure AI Services')
+param modelDeploymentName string = 'chat'
+
+@description('Model/AI Resource deployment location')
+param modelLocation string
+
+@description('The AI Service Account full ARM Resource ID. This is an optional field, and if not provided, the resource will be created.')
+param aiServiceAccountResourceId string
+
+@description('The AI Search Service full ARM Resource ID. This is an optional field, and if not provided, the resource will be created.')
+param aiSearchServiceResourceId string
+
+@description('The AI Storage Account full ARM Resource ID. This is an optional field, and if not provided, the resource will be created.')
+param aiStorageAccountResourceId string
+
+@description('The AI Cosmos DB Account full ARM Resource ID. This is an optional field, and if not provided, the resource will be created.')
+param aiCosmosDbAccountResourceId string
+
+var aiServiceExists = aiServiceAccountResourceId != ''
+var skipAzureSearchCreation = aiSearchServiceResourceId != '' || !enableAzureSearch
+var aiStorageExists = aiStorageAccountResourceId != ''
+var skipCosmosDbCreation = aiCosmosDbAccountResourceId != '' || !enableCosmosDb
+
+// Create an AI Service account and model deployment if it doesn't already exist
+
+
+
+resource aiServices 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' = if(!aiServiceExists) {
+ name: aiServicesName
+ location: modelLocation
+ sku: {
+ name: 'S0'
+ }
+ kind: 'AIServices'
+ identity: {
+ type: 'SystemAssigned'
+ }
+ properties: {
+ allowProjectManagement: true
+ customSubDomainName: toLower('${(aiServicesName)}')
+ networkAcls: {
+ defaultAction: 'Allow'
+ virtualNetworkRules: []
+ ipRules: []
+ }
+ publicNetworkAccess: 'Enabled'
+ // API-key based auth is not supported for the Agent service and policy requires it to be disabled
+ disableLocalAuth: true
+ }
+}
+resource modelDeployment 'Microsoft.CognitiveServices/accounts/deployments@2025-04-01-preview'= if(!aiServiceExists){
+ parent: aiServices
+ name: modelDeploymentName
+ sku : {
+ capacity: modelCapacity
+ name: modelSkuName
+ }
+ properties: {
+ model:{
+ name: modelName
+ format: modelFormat
+ version: modelVersion
+ }
+ }
+}
+
+// Create an AI Search Service if it doesn't already exist
+resource aiSearch 'Microsoft.Search/searchServices@2024-06-01-preview' = if(!skipAzureSearchCreation) {
+ name: aiSearchName
+ location: location
+ tags: tags
+ identity: {
+ type: 'SystemAssigned'
+ }
+ properties: {
+ disableLocalAuth: true
+ encryptionWithCmk: {
+ enforcement: 'Unspecified'
+ }
+ hostingMode: 'default'
+ partitionCount: 1
+ publicNetworkAccess: 'enabled'
+ replicaCount: 1
+ semanticSearch: 'disabled'
+ }
+ sku: {
+ name: 'standard'
+ }
+}
+
+// Create a Storage account if it doesn't already exist
+
+param sku string = 'Standard_LRS'
+
+resource storage 'Microsoft.Storage/storageAccounts@2022-05-01' = if(!aiStorageExists) {
+ name: storageName
+ location: location
+ kind: 'StorageV2'
+ sku: {
+ name: sku
+ }
+ properties: {
+ minimumTlsVersion: 'TLS1_2'
+ allowBlobPublicAccess: false
+ publicNetworkAccess: 'Enabled'
+ networkAcls: {
+ bypass: 'AzureServices'
+ defaultAction: 'Allow'
+ virtualNetworkRules: []
+ }
+ allowSharedKeyAccess: false
+ }
+}
+
+// Create a Cosmos DB Account if it doesn't already exist
+
+var canaryRegions = ['eastus2euap', 'centraluseuap']
+var cosmosDbRegion = contains(canaryRegions, location) ? 'eastus2' : location
+resource cosmosDbAccount 'Microsoft.DocumentDB/databaseAccounts@2024-11-15' = if(!skipCosmosDbCreation) {
+ name: cosmosDbName
+ location: cosmosDbRegion
+ kind: 'GlobalDocumentDB'
+ properties: {
+ consistencyPolicy: {
+ defaultConsistencyLevel: 'Session'
+ }
+ disableLocalAuth: true
+ enableAutomaticFailover: false
+ enableMultipleWriteLocations: false
+ enableFreeTier: false
+ locations: [
+ {
+ locationName: location
+ failoverPriority: 0
+ isZoneRedundant: false
+ }
+ ]
+ databaseAccountOfferType: 'Standard'
+ }
+}
+
+// Outputs
+
+output aiServicesName string = aiServicesName
+output aiservicesID string = aiServices.id
+output aiServiceAccountResourceGroupName string = resourceGroup().name
+output aiServiceAccountSubscriptionId string = subscription().subscriptionId
+
+output aiSearchName string = aiSearchName
+output aisearchID string = !skipAzureSearchCreation ? aiSearch.id : aiSearchServiceResourceId
+output aiSearchServiceResourceGroupName string = !skipAzureSearchCreation ? resourceGroup().name : ''
+output aiSearchServiceSubscriptionId string = !skipAzureSearchCreation ? subscription().subscriptionId : ''
+
+output storageAccountName string = storageName
+output storageId string = !aiStorageExists ? storage.id : aiStorageAccountResourceId
+output storageAccountResourceGroupName string = !aiStorageExists ? resourceGroup().name : ''
+output storageAccountSubscriptionId string = !aiStorageExists ? subscription().subscriptionId : ''
+
+output cosmosDbAccountName string = cosmosDbName
+output cosmosDbAccountId string = !skipCosmosDbCreation ? cosmosDbAccount.id : aiCosmosDbAccountResourceId
+output cosmosDbAccountResourceGroupName string = !skipCosmosDbCreation ? resourceGroup().name : ''
+output cosmosDbAccountSubscriptionId string = !skipCosmosDbCreation ? subscription().subscriptionId : ''
diff --git a/infra/app/api.bicep b/infra/app/api.bicep
new file mode 100644
index 0000000..ea1d1b2
--- /dev/null
+++ b/infra/app/api.bicep
@@ -0,0 +1,109 @@
+param name string
+@description('Primary location for all resources & Flex Consumption Function App')
+param location string = resourceGroup().location
+param tags object = {}
+param applicationInsightsName string = ''
+param appServicePlanId string
+param appSettings object = {}
+param runtimeName string
+param runtimeVersion string
+param serviceName string = 'api'
+param storageAccountName string
+param deploymentStorageContainerName string
+param virtualNetworkSubnetId string = ''
+param instanceMemoryMB int = 2048
+param maximumInstanceCount int = 100
+param identityId string = ''
+param identityClientId string = ''
+param enableBlob bool = true
+param enableQueue bool = false
+param enableTable bool = false
+param enableFile bool = false
+
+@allowed(['SystemAssigned', 'UserAssigned'])
+param identityType string = 'UserAssigned'
+
+var applicationInsightsIdentity = 'ClientId=${identityClientId};Authorization=AAD'
+var kind = 'functionapp'
+
+// Create base application settings
+var baseAppSettings = {
+ // Only include required credential settings unconditionally
+ AzureWebJobsStorage__credential: 'managedidentity'
+ AzureWebJobsStorage__clientId: identityClientId
+
+ // Application Insights settings are always included
+ APPLICATIONINSIGHTS_AUTHENTICATION_STRING: applicationInsightsIdentity
+ APPLICATIONINSIGHTS_CONNECTION_STRING: applicationInsights.properties.ConnectionString
+}
+
+// Dynamically build storage endpoint settings based on feature flags
+var blobSettings = enableBlob ? { AzureWebJobsStorage__blobServiceUri: stg.properties.primaryEndpoints.blob } : {}
+var queueSettings = enableQueue ? { AzureWebJobsStorage__queueServiceUri: stg.properties.primaryEndpoints.queue } : {}
+var tableSettings = enableTable ? { AzureWebJobsStorage__tableServiceUri: stg.properties.primaryEndpoints.table } : {}
+var fileSettings = enableFile ? { AzureWebJobsStorage__fileServiceUri: stg.properties.primaryEndpoints.file } : {}
+
+// Merge all app settings
+var allAppSettings = union(
+ appSettings,
+ blobSettings,
+ queueSettings,
+ tableSettings,
+ fileSettings,
+ baseAppSettings
+)
+
+resource stg 'Microsoft.Storage/storageAccounts@2022-09-01' existing = {
+ name: storageAccountName
+}
+
+resource applicationInsights 'Microsoft.Insights/components@2020-02-02' existing = {
+ name: applicationInsightsName
+}
+
+// Create a Flex Consumption Function App to host the API
+module api 'br/public:avm/res/web/site:0.15.1' = {
+ name: '${serviceName}-flex-consumption'
+ params: {
+ kind: kind
+ name: name
+ location: location
+ tags: union(tags, { 'azd-service-name': serviceName })
+ serverFarmResourceId: appServicePlanId
+ managedIdentities: {
+ systemAssigned: identityType == 'SystemAssigned'
+ userAssignedResourceIds: [
+ '${identityId}'
+ ]
+ }
+ functionAppConfig: {
+ deployment: {
+ storage: {
+ type: 'blobContainer'
+ value: '${stg.properties.primaryEndpoints.blob}${deploymentStorageContainerName}'
+ authentication: {
+ type: identityType == 'SystemAssigned' ? 'SystemAssignedIdentity' : 'UserAssignedIdentity'
+ userAssignedIdentityResourceId: identityType == 'UserAssigned' ? identityId : ''
+ }
+ }
+ }
+ scaleAndConcurrency: {
+ instanceMemoryMB: instanceMemoryMB
+ maximumInstanceCount: maximumInstanceCount
+ }
+ runtime: {
+ name: runtimeName
+ version: runtimeVersion
+ }
+ }
+ siteConfig: {
+ alwaysOn: false
+ }
+ virtualNetworkSubnetId: !empty(virtualNetworkSubnetId) ? virtualNetworkSubnetId : null
+ appSettingsKeyValuePairs: allAppSettings
+ }
+}
+
+output SERVICE_API_NAME string = api.outputs.name
+// Ensure output is always string, handle potential null from module output if SystemAssigned is not used
+output SERVICE_API_IDENTITY_PRINCIPAL_ID string = identityType == 'SystemAssigned' ? api.outputs.?systemAssignedMIPrincipalId ?? '' : ''
diff --git a/infra/app/rbac.bicep b/infra/app/rbac.bicep
new file mode 100644
index 0000000..6a2dde7
--- /dev/null
+++ b/infra/app/rbac.bicep
@@ -0,0 +1,110 @@
+param storageAccountName string
+param appInsightsName string
+param managedIdentityPrincipalId string // Principal ID for the Managed Identity
+param userIdentityPrincipalId string = '' // Principal ID for the User Identity
+param allowUserIdentityPrincipal bool = false // Flag to enable user identity role assignments
+param enableBlob bool = true
+param enableQueue bool = false
+param enableTable bool = false
+
+// Define Role Definition IDs internally
+var storageRoleDefinitionId = 'b7e6dc6d-f1e8-4753-8033-0f276bb0955b' //Storage Blob Data Owner role
+var queueRoleDefinitionId = '974c5e8b-45b9-4653-ba55-5f855dd0fb88' // Storage Queue Data Contributor role
+var tableRoleDefinitionId = '0a9a7e1f-b9d0-4cc4-a60d-0319b160aaa3' // Storage Table Data Contributor role
+var monitoringRoleDefinitionId = '3913510d-42f4-4e42-8a64-420c390055eb' // Monitoring Metrics Publisher role ID
+
+resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' existing = {
+ name: storageAccountName
+}
+
+resource applicationInsights 'Microsoft.Insights/components@2020-02-02' existing = {
+ name: appInsightsName
+}
+
+// Role assignment for Storage Account (Blob) - Managed Identity
+resource storageRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (enableBlob) {
+ name: guid(storageAccount.id, managedIdentityPrincipalId, storageRoleDefinitionId) // Use managed identity ID
+ scope: storageAccount
+ properties: {
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', storageRoleDefinitionId)
+ principalId: managedIdentityPrincipalId // Use managed identity ID
+ principalType: 'ServicePrincipal' // Managed Identity is a Service Principal
+ }
+}
+
+// Role assignment for Storage Account (Blob) - User Identity
+resource storageRoleAssignment_User 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (enableBlob && allowUserIdentityPrincipal && !empty(userIdentityPrincipalId)) {
+ name: guid(storageAccount.id, userIdentityPrincipalId, storageRoleDefinitionId)
+ scope: storageAccount
+ properties: {
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', storageRoleDefinitionId)
+ principalId: userIdentityPrincipalId // Use user identity ID
+ principalType: 'User' // User Identity is a User Principal
+ }
+}
+
+// Role assignment for Storage Account (Queue) - Managed Identity
+resource queueRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (enableQueue) {
+ name: guid(storageAccount.id, managedIdentityPrincipalId, queueRoleDefinitionId) // Use managed identity ID
+ scope: storageAccount
+ properties: {
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', queueRoleDefinitionId)
+ principalId: managedIdentityPrincipalId // Use managed identity ID
+ principalType: 'ServicePrincipal' // Managed Identity is a Service Principal
+ }
+}
+
+// Role assignment for Storage Account (Queue) - User Identity
+resource queueRoleAssignment_User 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (enableQueue && allowUserIdentityPrincipal && !empty(userIdentityPrincipalId)) {
+ name: guid(storageAccount.id, userIdentityPrincipalId, queueRoleDefinitionId)
+ scope: storageAccount
+ properties: {
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', queueRoleDefinitionId)
+ principalId: userIdentityPrincipalId // Use user identity ID
+ principalType: 'User' // User Identity is a User Principal
+ }
+}
+
+// Role assignment for Storage Account (Table) - Managed Identity
+resource tableRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (enableTable) {
+ name: guid(storageAccount.id, managedIdentityPrincipalId, tableRoleDefinitionId) // Use managed identity ID
+ scope: storageAccount
+ properties: {
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', tableRoleDefinitionId)
+ principalId: managedIdentityPrincipalId // Use managed identity ID
+ principalType: 'ServicePrincipal' // Managed Identity is a Service Principal
+ }
+}
+
+// Role assignment for Storage Account (Table) - User Identity
+resource tableRoleAssignment_User 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (enableTable && allowUserIdentityPrincipal && !empty(userIdentityPrincipalId)) {
+ name: guid(storageAccount.id, userIdentityPrincipalId, tableRoleDefinitionId)
+ scope: storageAccount
+ properties: {
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', tableRoleDefinitionId)
+ principalId: userIdentityPrincipalId // Use user identity ID
+ principalType: 'User' // User Identity is a User Principal
+ }
+}
+
+// Role assignment for Application Insights - Managed Identity
+resource appInsightsRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
+ name: guid(applicationInsights.id, managedIdentityPrincipalId, monitoringRoleDefinitionId) // Use managed identity ID
+ scope: applicationInsights
+ properties: {
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', monitoringRoleDefinitionId)
+ principalId: managedIdentityPrincipalId // Use managed identity ID
+ principalType: 'ServicePrincipal' // Managed Identity is a Service Principal
+ }
+}
+
+// Role assignment for Application Insights - User Identity
+resource appInsightsRoleAssignment_User 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (allowUserIdentityPrincipal && !empty(userIdentityPrincipalId)) {
+ name: guid(applicationInsights.id, userIdentityPrincipalId, monitoringRoleDefinitionId)
+ scope: applicationInsights
+ properties: {
+ roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', monitoringRoleDefinitionId)
+ principalId: userIdentityPrincipalId // Use user identity ID
+ principalType: 'User' // User Identity is a User Principal
+ }
+}
diff --git a/infra/app/storage-PrivateEndpoint.bicep b/infra/app/storage-PrivateEndpoint.bicep
new file mode 100644
index 0000000..8ded984
--- /dev/null
+++ b/infra/app/storage-PrivateEndpoint.bicep
@@ -0,0 +1,181 @@
+param virtualNetworkName string
+param subnetName string
+@description('Specifies the storage account resource name')
+param resourceName string
+param location string = resourceGroup().location
+param tags object = {}
+param enableBlob bool = true
+param enableQueue bool = false
+param enableTable bool = false
+
+resource vnet 'Microsoft.Network/virtualNetworks@2021-08-01' existing = {
+ name: virtualNetworkName
+}
+
+resource storageAccount 'Microsoft.Storage/storageAccounts@2021-09-01' existing = {
+ name: resourceName
+}
+
+// Storage DNS zone names
+var blobPrivateDNSZoneName = 'privatelink.blob.${environment().suffixes.storage}'
+var queuePrivateDNSZoneName = 'privatelink.queue.${environment().suffixes.storage}'
+var tablePrivateDNSZoneName = 'privatelink.table.${environment().suffixes.storage}'
+
+// AVM module for Blob Private Endpoint with private DNS zone
+module blobPrivateEndpoint 'br/public:avm/res/network/private-endpoint:0.11.0' = if (enableBlob) {
+ name: 'blob-private-endpoint-deployment'
+ params: {
+ name: 'blob-private-endpoint'
+ location: location
+ tags: tags
+ subnetResourceId: '${vnet.id}/subnets/${subnetName}'
+ privateLinkServiceConnections: [
+ {
+ name: 'blobPrivateLinkConnection'
+ properties: {
+ privateLinkServiceId: storageAccount.id
+ groupIds: [
+ 'blob'
+ ]
+ }
+ }
+ ]
+ customDnsConfigs: []
+ // Creates private DNS zone and links
+ privateDnsZoneGroup: {
+ name: 'blobPrivateDnsZoneGroup'
+ privateDnsZoneGroupConfigs: [
+ {
+ name: 'storageBlobARecord'
+ privateDnsZoneResourceId: privateDnsZoneBlobDeployment.outputs.resourceId
+ }
+ ]
+ }
+ }
+ dependsOn: [
+ privateDnsZoneBlobDeployment
+ ]
+}
+
+// AVM module for Queue Private Endpoint with private DNS zone
+module queuePrivateEndpoint 'br/public:avm/res/network/private-endpoint:0.11.0' = if (enableQueue) {
+ name: 'queue-private-endpoint-deployment'
+ params: {
+ name: 'queue-private-endpoint'
+ location: location
+ tags: tags
+ subnetResourceId: '${vnet.id}/subnets/${subnetName}'
+ privateLinkServiceConnections: [
+ {
+ name: 'queuePrivateLinkConnection'
+ properties: {
+ privateLinkServiceId: storageAccount.id
+ groupIds: [
+ 'queue'
+ ]
+ }
+ }
+ ]
+ customDnsConfigs: []
+ // Creates private DNS zone and links
+ privateDnsZoneGroup: {
+ name: 'queuePrivateDnsZoneGroup'
+ privateDnsZoneGroupConfigs: [
+ {
+ name: 'storageQueueARecord'
+ privateDnsZoneResourceId: enableQueue ? privateDnsZoneQueueDeployment.outputs.resourceId : ''
+ }
+ ]
+ }
+ }
+}
+
+// AVM module for Table Private Endpoint with private DNS zone
+module tablePrivateEndpoint 'br/public:avm/res/network/private-endpoint:0.11.0' = if (enableTable) {
+ name: 'table-private-endpoint-deployment'
+ params: {
+ name: 'table-private-endpoint'
+ location: location
+ tags: tags
+ subnetResourceId: '${vnet.id}/subnets/${subnetName}'
+ privateLinkServiceConnections: [
+ {
+ name: 'tablePrivateLinkConnection'
+ properties: {
+ privateLinkServiceId: storageAccount.id
+ groupIds: [
+ 'table'
+ ]
+ }
+ }
+ ]
+ customDnsConfigs: []
+ // Creates private DNS zone and links
+ privateDnsZoneGroup: {
+ name: 'tablePrivateDnsZoneGroup'
+ privateDnsZoneGroupConfigs: [
+ {
+ name: 'storageTableARecord'
+ privateDnsZoneResourceId: enableTable ? privateDnsZoneTableDeployment.outputs.resourceId : ''
+ }
+ ]
+ }
+ }
+}
+
+// AVM module for Blob Private DNS Zone
+module privateDnsZoneBlobDeployment 'br/public:avm/res/network/private-dns-zone:0.7.1' = if (enableBlob) {
+ name: 'blob-private-dns-zone-deployment'
+ params: {
+ name: blobPrivateDNSZoneName
+ location: 'global'
+ tags: tags
+ virtualNetworkLinks: [
+ {
+ name: '${resourceName}-blob-link-${take(toLower(uniqueString(resourceName, virtualNetworkName)), 4)}'
+ virtualNetworkResourceId: vnet.id
+ registrationEnabled: false
+ location: 'global'
+ tags: tags
+ }
+ ]
+ }
+}
+
+// AVM module for Queue Private DNS Zone
+module privateDnsZoneQueueDeployment 'br/public:avm/res/network/private-dns-zone:0.7.1' = if (enableQueue) {
+ name: 'queue-private-dns-zone-deployment'
+ params: {
+ name: queuePrivateDNSZoneName
+ location: 'global'
+ tags: tags
+ virtualNetworkLinks: [
+ {
+ name: '${resourceName}-queue-link-${take(toLower(uniqueString(resourceName, virtualNetworkName)), 4)}'
+ virtualNetworkResourceId: vnet.id
+ registrationEnabled: false
+ location: 'global'
+ tags: tags
+ }
+ ]
+ }
+}
+
+// AVM module for Table Private DNS Zone
+module privateDnsZoneTableDeployment 'br/public:avm/res/network/private-dns-zone:0.7.1' = if (enableTable) {
+ name: 'table-private-dns-zone-deployment'
+ params: {
+ name: tablePrivateDNSZoneName
+ location: 'global'
+ tags: tags
+ virtualNetworkLinks: [
+ {
+ name: '${resourceName}-table-link-${take(toLower(uniqueString(resourceName, virtualNetworkName)), 4)}'
+ virtualNetworkResourceId: vnet.id
+ registrationEnabled: false
+ location: 'global'
+ tags: tags
+ }
+ ]
+ }
+}
diff --git a/infra/app/vnet.bicep b/infra/app/vnet.bicep
new file mode 100644
index 0000000..6b75848
--- /dev/null
+++ b/infra/app/vnet.bicep
@@ -0,0 +1,48 @@
+@description('Specifies the name of the virtual network.')
+param vNetName string
+
+@description('Specifies the location.')
+param location string = resourceGroup().location
+
+@description('Specifies the name of the subnet for the Service Bus private endpoint.')
+param peSubnetName string = 'private-endpoints-subnet'
+
+@description('Specifies the name of the subnet for Function App virtual network integration.')
+param appSubnetName string = 'app'
+
+param tags object = {}
+
+// Migrated to use AVM module instead of direct resource declaration
+module virtualNetwork 'br/public:avm/res/network/virtual-network:0.6.1' = {
+ name: 'vnet-deployment'
+ params: {
+ // Required parameters
+ name: vNetName
+ addressPrefixes: [
+ '10.0.0.0/16'
+ ]
+ // Non-required parameters
+ location: location
+ tags: tags
+ subnets: [
+ {
+ name: peSubnetName
+ addressPrefix: '10.0.1.0/24'
+ privateEndpointNetworkPolicies: 'Disabled'
+ privateLinkServiceNetworkPolicies: 'Enabled'
+ }
+ {
+ name: appSubnetName
+ addressPrefix: '10.0.2.0/24'
+ privateEndpointNetworkPolicies: 'Disabled'
+ privateLinkServiceNetworkPolicies: 'Enabled'
+ delegation: 'Microsoft.App/environments'
+ }
+ ]
+ }
+}
+
+output peSubnetName string = peSubnetName
+output peSubnetID string = '${virtualNetwork.outputs.resourceId}/subnets/${peSubnetName}'
+output appSubnetName string = appSubnetName
+output appSubnetID string = '${virtualNetwork.outputs.resourceId}/subnets/${appSubnetName}'
diff --git a/infra/deploybutton/README.md b/infra/deploybutton/README.md
new file mode 100644
index 0000000..db1ff94
--- /dev/null
+++ b/infra/deploybutton/README.md
@@ -0,0 +1,27 @@
+# Deploy to Azure Button
+
+This folder contains the compiled ARM template for one-click deployment to Azure.
+
+[](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fpaulyuk%2Fsimple-agent-af-python%2Fmain%2Finfra%2Fdeploybutton%2Fazuredeploy.json)
+
+## Parameters
+
+When deploying, you will be asked to provide:
+
+- **environmentName**: A unique name for your environment (used to generate resource names)
+- **location**: The Azure region where resources will be deployed
+
+All other parameters use secure defaults optimized for the Simple Agent Framework:
+- Model: GPT-4o-mini (2024-07-18)
+- Model SKU: GlobalStandard
+- Model Capacity: 50
+
+## What Gets Deployed
+
+- Azure Functions app (Flex Consumption plan with Python runtime)
+- Azure AI Services with GPT-4o-mini deployment
+- Azure AI Search
+- Cosmos DB (for agent state)
+- Storage Account
+- Application Insights and Log Analytics
+- All necessary role assignments and managed identities
diff --git a/infra/deploybutton/azuredeploy.json b/infra/deploybutton/azuredeploy.json
new file mode 100644
index 0000000..55bcd51
--- /dev/null
+++ b/infra/deploybutton/azuredeploy.json
@@ -0,0 +1,16936 @@
+{
+ "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.39.26.7824",
+ "templateHash": "2525516136336865751"
+ }
+ },
+ "parameters": {
+ "environmentName": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 64,
+ "metadata": {
+ "description": "Name of the the environment which is used to generate a short unique hash used in all resources."
+ }
+ },
+ "location": {
+ "type": "string",
+ "defaultValue": "eastus2",
+ "metadata": {
+ "azd": {
+ "type": "location"
+ },
+ "description": "Primary location for all resources & Flex Consumption Function App"
+ },
+ "minLength": 1
+ },
+ "vnetEnabled": {
+ "type": "bool",
+ "defaultValue": false
+ },
+ "apiServiceName": {
+ "type": "string",
+ "defaultValue": ""
+ },
+ "apiUserAssignedIdentityName": {
+ "type": "string",
+ "defaultValue": ""
+ },
+ "applicationInsightsName": {
+ "type": "string",
+ "defaultValue": ""
+ },
+ "appServicePlanName": {
+ "type": "string",
+ "defaultValue": ""
+ },
+ "logAnalyticsName": {
+ "type": "string",
+ "defaultValue": ""
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "defaultValue": ""
+ },
+ "storageAccountName": {
+ "type": "string",
+ "defaultValue": ""
+ },
+ "principalId": {
+ "type": "string",
+ "defaultValue": "",
+ "metadata": {
+ "description": "Id of the user identity to be used for testing and debugging. This is not required in production. Leave empty if not needed."
+ }
+ },
+ "aiProjectName": {
+ "type": "string",
+ "defaultValue": "simple-agent",
+ "metadata": {
+ "description": "Name for the AI project resources."
+ }
+ },
+ "aiProjectFriendlyName": {
+ "type": "string",
+ "defaultValue": "Simple AI Agent Project",
+ "metadata": {
+ "description": "Friendly name for your Azure AI resource"
+ }
+ },
+ "aiProjectDescription": {
+ "type": "string",
+ "defaultValue": "This is a simple AI agent project for Azure Functions.",
+ "metadata": {
+ "description": "Description of your Azure AI resource displayed in AI studio"
+ }
+ },
+ "enableAzureSearch": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Enable Azure AI Search for vector store and search capabilities"
+ }
+ },
+ "aiSearchName": {
+ "type": "string",
+ "defaultValue": "agent-ai-search",
+ "metadata": {
+ "description": "Name of the Azure AI Search account"
+ }
+ },
+ "enableCosmosDb": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Enable Cosmos DB for agent thread storage"
+ }
+ },
+ "accountCapabilityHostName": {
+ "type": "string",
+ "defaultValue": "caphostacc",
+ "metadata": {
+ "description": "Name for capabilityHost."
+ }
+ },
+ "projectCapabilityHostName": {
+ "type": "string",
+ "defaultValue": "caphostproj",
+ "metadata": {
+ "description": "Name for capabilityHost."
+ }
+ },
+ "aiServicesName": {
+ "type": "string",
+ "defaultValue": "agent-ai-services",
+ "metadata": {
+ "description": "Name of the Azure AI Services account"
+ }
+ },
+ "modelName": {
+ "type": "string",
+ "defaultValue": "gpt-4.1-mini",
+ "metadata": {
+ "description": "Model name for deployment"
+ }
+ },
+ "modelFormat": {
+ "type": "string",
+ "defaultValue": "OpenAI",
+ "metadata": {
+ "description": "Model format for deployment"
+ }
+ },
+ "modelVersion": {
+ "type": "string",
+ "defaultValue": "2025-04-14",
+ "metadata": {
+ "description": "Model version for deployment"
+ }
+ },
+ "modelSkuName": {
+ "type": "string",
+ "defaultValue": "GlobalStandard",
+ "metadata": {
+ "description": "Model deployment SKU name"
+ }
+ },
+ "modelCapacity": {
+ "type": "int",
+ "defaultValue": 50,
+ "metadata": {
+ "description": "Model deployment capacity"
+ }
+ },
+ "modelDeploymentName": {
+ "type": "string",
+ "defaultValue": "chat",
+ "metadata": {
+ "description": "Name for the model deployment in Azure AI Services"
+ }
+ },
+ "cosmosDbName": {
+ "type": "string",
+ "defaultValue": "agent-ai-cosmos",
+ "metadata": {
+ "description": "Name of the Cosmos DB account for agent thread storage"
+ }
+ },
+ "aiServiceAccountResourceId": {
+ "type": "string",
+ "defaultValue": "",
+ "metadata": {
+ "description": "The AI Service Account full ARM Resource ID. This is an optional field, and if not provided, the resource will be created."
+ }
+ },
+ "aiSearchServiceResourceId": {
+ "type": "string",
+ "defaultValue": "",
+ "metadata": {
+ "description": "The Ai Search Service full ARM Resource ID. This is an optional field, and if not provided, the resource will be created."
+ }
+ },
+ "aiStorageAccountResourceId": {
+ "type": "string",
+ "defaultValue": "",
+ "metadata": {
+ "description": "The Ai Storage Account full ARM Resource ID. This is an optional field, and if not provided, the resource will be created."
+ }
+ },
+ "aiCosmosDbAccountResourceId": {
+ "type": "string",
+ "defaultValue": "",
+ "metadata": {
+ "description": "The Cosmos DB Account full ARM Resource ID. This is an optional field, and if not provided, the resource will be created."
+ }
+ }
+ },
+ "variables": {
+ "$fxv#0": {
+ "analysisServicesServers": "as",
+ "apiManagementService": "apim-",
+ "appConfigurationConfigurationStores": "appcs-",
+ "appManagedEnvironments": "cae-",
+ "appContainerApps": "ca-",
+ "authorizationPolicyDefinitions": "policy-",
+ "automationAutomationAccounts": "aa-",
+ "blueprintBlueprints": "bp-",
+ "blueprintBlueprintsArtifacts": "bpa-",
+ "cacheRedis": "redis-",
+ "cdnProfiles": "cdnp-",
+ "cdnProfilesEndpoints": "cdne-",
+ "cognitiveServicesAccounts": "cog-",
+ "cognitiveServicesFormRecognizer": "cog-fr-",
+ "cognitiveServicesTextAnalytics": "cog-ta-",
+ "computeAvailabilitySets": "avail-",
+ "computeCloudServices": "cld-",
+ "computeDiskEncryptionSets": "des",
+ "computeDisks": "disk",
+ "computeDisksOs": "osdisk",
+ "computeGalleries": "gal",
+ "computeSnapshots": "snap-",
+ "computeVirtualMachines": "vm",
+ "computeVirtualMachineScaleSets": "vmss-",
+ "containerInstanceContainerGroups": "ci",
+ "containerRegistryRegistries": "cr",
+ "containerServiceManagedClusters": "aks-",
+ "databricksWorkspaces": "dbw-",
+ "dataFactoryFactories": "adf-",
+ "dataLakeAnalyticsAccounts": "dla",
+ "dataLakeStoreAccounts": "dls",
+ "dataMigrationServices": "dms-",
+ "dBforMySQLServers": "mysql-",
+ "dBforPostgreSQLServers": "psql-",
+ "devicesIotHubs": "iot-",
+ "devicesProvisioningServices": "provs-",
+ "devicesProvisioningServicesCertificates": "pcert-",
+ "documentDBDatabaseAccounts": "cosmos-",
+ "eventGridDomains": "evgd-",
+ "eventGridDomainsTopics": "evgt-",
+ "eventGridEventSubscriptions": "evgs-",
+ "eventHubNamespaces": "evhns-",
+ "eventHubNamespacesEventHubs": "evh-",
+ "hdInsightClustersHadoop": "hadoop-",
+ "hdInsightClustersHbase": "hbase-",
+ "hdInsightClustersKafka": "kafka-",
+ "hdInsightClustersMl": "mls-",
+ "hdInsightClustersSpark": "spark-",
+ "hdInsightClustersStorm": "storm-",
+ "hybridComputeMachines": "arcs-",
+ "insightsActionGroups": "ag-",
+ "insightsComponents": "appi-",
+ "keyVaultVaults": "kv-",
+ "kubernetesConnectedClusters": "arck",
+ "kustoClusters": "dec",
+ "kustoClustersDatabases": "dedb",
+ "logicIntegrationAccounts": "ia-",
+ "logicWorkflows": "logic-",
+ "machineLearningServicesWorkspaces": "mlw-",
+ "managedIdentityUserAssignedIdentities": "id-",
+ "managementManagementGroups": "mg-",
+ "migrateAssessmentProjects": "migr-",
+ "networkApplicationGateways": "agw-",
+ "networkApplicationSecurityGroups": "asg-",
+ "networkAzureFirewalls": "afw-",
+ "networkBastionHosts": "bas-",
+ "networkConnections": "con-",
+ "networkDnsZones": "dnsz-",
+ "networkExpressRouteCircuits": "erc-",
+ "networkFirewallPolicies": "afwp-",
+ "networkFirewallPoliciesWebApplication": "waf",
+ "networkFirewallPoliciesRuleGroups": "wafrg",
+ "networkFrontDoors": "fd-",
+ "networkFrontdoorWebApplicationFirewallPolicies": "fdfp-",
+ "networkLoadBalancersExternal": "lbe-",
+ "networkLoadBalancersInternal": "lbi-",
+ "networkLoadBalancersInboundNatRules": "rule-",
+ "networkLocalNetworkGateways": "lgw-",
+ "networkNatGateways": "ng-",
+ "networkNetworkInterfaces": "nic-",
+ "networkNetworkSecurityGroups": "nsg-",
+ "networkNetworkSecurityGroupsSecurityRules": "nsgsr-",
+ "networkNetworkWatchers": "nw-",
+ "networkPrivateDnsZones": "pdnsz-",
+ "networkPrivateLinkServices": "pl-",
+ "networkPublicIPAddresses": "pip-",
+ "networkPublicIPPrefixes": "ippre-",
+ "networkRouteFilters": "rf-",
+ "networkRouteTables": "rt-",
+ "networkRouteTablesRoutes": "udr-",
+ "networkTrafficManagerProfiles": "traf-",
+ "networkVirtualNetworkGateways": "vgw-",
+ "networkVirtualNetworks": "vnet-",
+ "networkVirtualNetworksSubnets": "snet-",
+ "networkVirtualNetworksVirtualNetworkPeerings": "peer-",
+ "networkVirtualWans": "vwan-",
+ "networkVpnGateways": "vpng-",
+ "networkVpnGatewaysVpnConnections": "vcn-",
+ "networkVpnGatewaysVpnSites": "vst-",
+ "notificationHubsNamespaces": "ntfns-",
+ "notificationHubsNamespacesNotificationHubs": "ntf-",
+ "operationalInsightsWorkspaces": "log-",
+ "portalDashboards": "dash-",
+ "powerBIDedicatedCapacities": "pbi-",
+ "purviewAccounts": "pview-",
+ "recoveryServicesVaults": "rsv-",
+ "resourcesResourceGroups": "rg-",
+ "searchSearchServices": "srch-",
+ "serviceBusNamespaces": "sb-",
+ "serviceBusNamespacesQueues": "sbq-",
+ "serviceBusNamespacesTopics": "sbt-",
+ "serviceEndPointPolicies": "se-",
+ "serviceFabricClusters": "sf-",
+ "signalRServiceSignalR": "sigr",
+ "sqlManagedInstances": "sqlmi-",
+ "sqlServers": "sql-",
+ "sqlServersDataWarehouse": "sqldw-",
+ "sqlServersDatabases": "sqldb-",
+ "sqlServersDatabasesStretch": "sqlstrdb-",
+ "storageStorageAccounts": "st",
+ "storageStorageAccountsVm": "stvm",
+ "storSimpleManagers": "ssimp",
+ "streamAnalyticsCluster": "asa-",
+ "synapseWorkspaces": "syn",
+ "synapseWorkspacesAnalyticsWorkspaces": "synw",
+ "synapseWorkspacesSqlPoolsDedicated": "syndp",
+ "synapseWorkspacesSqlPoolsSpark": "synsp",
+ "timeSeriesInsightsEnvironments": "tsi-",
+ "webServerFarms": "plan-",
+ "webSitesAppService": "app-",
+ "webSitesAppServiceEnvironment": "ase-",
+ "webSitesFunctions": "func-",
+ "webStaticSites": "stapp-"
+ },
+ "abbrs": "[variables('$fxv#0')]",
+ "resourceToken": "[toLower(uniqueString(subscription().id, parameters('environmentName'), parameters('location')))]",
+ "tags": {
+ "azd-env-name": "[parameters('environmentName')]"
+ },
+ "functionAppName": "[if(not(empty(parameters('apiServiceName'))), parameters('apiServiceName'), format('{0}api-{1}', variables('abbrs').webSitesFunctions, variables('resourceToken')))]",
+ "deploymentStorageContainerName": "[format('app-package-{0}-{1}', take(variables('functionAppName'), 32), take(toLower(uniqueString(variables('functionAppName'), variables('resourceToken'))), 7))]",
+ "projectName": "[toLower(format('{0}', parameters('aiProjectName')))]",
+ "uniqueSuffix": "[toLower(uniqueString(subscription().id, parameters('environmentName'), parameters('location')))]",
+ "storageEndpointConfig": {
+ "enableBlob": true,
+ "enableQueue": true,
+ "enableTable": false,
+ "enableFiles": false,
+ "allowUserIdentityPrincipal": "[not(empty(parameters('principalId')))]"
+ }
+ },
+ "resources": [
+ {
+ "type": "Microsoft.Resources/resourceGroups",
+ "apiVersion": "2021-04-01",
+ "name": "[if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))]",
+ "location": "[parameters('location')]",
+ "tags": "[variables('tags')]"
+ },
+ {
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2025-04-01",
+ "name": "apiUserAssignedIdentity",
+ "resourceGroup": "[if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "location": {
+ "value": "[parameters('location')]"
+ },
+ "tags": {
+ "value": "[variables('tags')]"
+ },
+ "name": "[if(not(empty(parameters('apiUserAssignedIdentityName'))), createObject('value', parameters('apiUserAssignedIdentityName')), createObject('value', format('{0}api-{1}', variables('abbrs').managedIdentityUserAssignedIdentities, variables('resourceToken'))))]"
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.34.44.8038",
+ "templateHash": "16707109626832623586"
+ },
+ "name": "User Assigned Identities",
+ "description": "This module deploys a User Assigned Identity."
+ },
+ "definitions": {
+ "federatedIdentityCredentialType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the federated identity credential."
+ }
+ },
+ "audiences": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "metadata": {
+ "description": "Required. The list of audiences that can appear in the issued token."
+ }
+ },
+ "issuer": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The URL of the issuer to be trusted."
+ }
+ },
+ "subject": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The identifier of the external identity."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true,
+ "description": "The type for the federated identity credential."
+ }
+ },
+ "lockType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the name of lock."
+ }
+ },
+ "kind": {
+ "type": "string",
+ "allowedValues": [
+ "CanNotDelete",
+ "None",
+ "ReadOnly"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the type of lock."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a lock.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ },
+ "roleAssignmentType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name (as GUID) of the role assignment. If not provided, a GUID will be generated."
+ }
+ },
+ "roleDefinitionIdOrName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The role to assign. You can provide either the display name of the role definition, the role definition GUID, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'."
+ }
+ },
+ "principalId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The principal ID of the principal (user/group/identity) to assign the role to."
+ }
+ },
+ "principalType": {
+ "type": "string",
+ "allowedValues": [
+ "Device",
+ "ForeignGroup",
+ "Group",
+ "ServicePrincipal",
+ "User"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The principal type of the assigned principal ID."
+ }
+ },
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The description of the role assignment."
+ }
+ },
+ "condition": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase \"foo_storage_container\"."
+ }
+ },
+ "conditionVersion": {
+ "type": "string",
+ "allowedValues": [
+ "2.0"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Version of the condition."
+ }
+ },
+ "delegatedManagedIdentityResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The Resource Id of the delegated managed identity resource."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a role assignment.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ }
+ },
+ "parameters": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of the User Assigned Identity."
+ }
+ },
+ "location": {
+ "type": "string",
+ "defaultValue": "[resourceGroup().location]",
+ "metadata": {
+ "description": "Optional. Location for all resources."
+ }
+ },
+ "federatedIdentityCredentials": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/federatedIdentityCredentialType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The federated identity credentials list to indicate which token from the external IdP should be trusted by your application. Federated identity credentials are supported on applications only. A maximum of 20 federated identity credentials can be added per application object."
+ }
+ },
+ "lock": {
+ "$ref": "#/definitions/lockType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The lock settings of the service."
+ }
+ },
+ "roleAssignments": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/roleAssignmentType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Array of role assignments to create."
+ }
+ },
+ "tags": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Tags of the resource."
+ }
+ },
+ "enableTelemetry": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. Enable/Disable usage telemetry for module."
+ }
+ }
+ },
+ "variables": {
+ "copy": [
+ {
+ "name": "formattedRoleAssignments",
+ "count": "[length(coalesce(parameters('roleAssignments'), createArray()))]",
+ "input": "[union(coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')], createObject('roleDefinitionId', coalesce(tryGet(variables('builtInRoleNames'), coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName), if(contains(coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/'), coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName)))))]"
+ }
+ ],
+ "builtInRoleNames": {
+ "Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
+ "Managed Identity Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'e40ec5ca-96e0-45a2-b4ff-59039f2c2b59')]",
+ "Managed Identity Operator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'f1a07417-d97a-45cb-824c-7a7467783830')]",
+ "Owner": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]",
+ "Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'acdd72a7-3385-48ef-bd42-f606fba81ae7')]",
+ "Role Based Access Control Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'f58310d9-a9f6-439a-9e8d-f62e7b41a168')]",
+ "User Access Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '18d7d88d-d35e-4fb5-a5c3-7773c20a72d9')]"
+ }
+ },
+ "resources": {
+ "avmTelemetry": {
+ "condition": "[parameters('enableTelemetry')]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2024-03-01",
+ "name": "[format('46d3xbcp.res.managedidentity-userassignedidentity.{0}.{1}', replace('0.4.1', '.', '-'), substring(uniqueString(deployment().name, parameters('location')), 0, 4))]",
+ "properties": {
+ "mode": "Incremental",
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "resources": [],
+ "outputs": {
+ "telemetry": {
+ "type": "String",
+ "value": "For more information, see https://aka.ms/avm/TelemetryInfo"
+ }
+ }
+ }
+ }
+ },
+ "userAssignedIdentity": {
+ "type": "Microsoft.ManagedIdentity/userAssignedIdentities",
+ "apiVersion": "2024-11-30",
+ "name": "[parameters('name')]",
+ "location": "[parameters('location')]",
+ "tags": "[parameters('tags')]"
+ },
+ "userAssignedIdentity_lock": {
+ "condition": "[and(not(empty(coalesce(parameters('lock'), createObject()))), not(equals(tryGet(parameters('lock'), 'kind'), 'None')))]",
+ "type": "Microsoft.Authorization/locks",
+ "apiVersion": "2020-05-01",
+ "scope": "[format('Microsoft.ManagedIdentity/userAssignedIdentities/{0}', parameters('name'))]",
+ "name": "[coalesce(tryGet(parameters('lock'), 'name'), format('lock-{0}', parameters('name')))]",
+ "properties": {
+ "level": "[coalesce(tryGet(parameters('lock'), 'kind'), '')]",
+ "notes": "[if(equals(tryGet(parameters('lock'), 'kind'), 'CanNotDelete'), 'Cannot delete resource or child resources.', 'Cannot delete or modify the resource or child resources.')]"
+ },
+ "dependsOn": [
+ "userAssignedIdentity"
+ ]
+ },
+ "userAssignedIdentity_roleAssignments": {
+ "copy": {
+ "name": "userAssignedIdentity_roleAssignments",
+ "count": "[length(coalesce(variables('formattedRoleAssignments'), createArray()))]"
+ },
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.ManagedIdentity/userAssignedIdentities/{0}', parameters('name'))]",
+ "name": "[coalesce(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'name'), guid(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('name')), coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].principalId, coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].roleDefinitionId))]",
+ "properties": {
+ "roleDefinitionId": "[coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].roleDefinitionId]",
+ "principalId": "[coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].principalId]",
+ "description": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'description')]",
+ "principalType": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'principalType')]",
+ "condition": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'condition')]",
+ "conditionVersion": "[if(not(empty(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'condition'))), coalesce(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'conditionVersion'), '2.0'), null())]",
+ "delegatedManagedIdentityResourceId": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'delegatedManagedIdentityResourceId')]"
+ },
+ "dependsOn": [
+ "userAssignedIdentity"
+ ]
+ },
+ "userAssignedIdentity_federatedIdentityCredentials": {
+ "copy": {
+ "name": "userAssignedIdentity_federatedIdentityCredentials",
+ "count": "[length(coalesce(parameters('federatedIdentityCredentials'), createArray()))]",
+ "mode": "serial",
+ "batchSize": 1
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-UserMSI-FederatedIdentityCred-{1}', uniqueString(deployment().name, parameters('location')), copyIndex())]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "name": {
+ "value": "[coalesce(parameters('federatedIdentityCredentials'), createArray())[copyIndex()].name]"
+ },
+ "userAssignedIdentityName": {
+ "value": "[parameters('name')]"
+ },
+ "audiences": {
+ "value": "[coalesce(parameters('federatedIdentityCredentials'), createArray())[copyIndex()].audiences]"
+ },
+ "issuer": {
+ "value": "[coalesce(parameters('federatedIdentityCredentials'), createArray())[copyIndex()].issuer]"
+ },
+ "subject": {
+ "value": "[coalesce(parameters('federatedIdentityCredentials'), createArray())[copyIndex()].subject]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.34.44.8038",
+ "templateHash": "13656021764446440473"
+ },
+ "name": "User Assigned Identity Federated Identity Credential",
+ "description": "This module deploys a User Assigned Identity Federated Identity Credential."
+ },
+ "parameters": {
+ "userAssignedIdentityName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent user assigned identity. Required if the template is used in a standalone deployment."
+ }
+ },
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the secret."
+ }
+ },
+ "audiences": {
+ "type": "array",
+ "metadata": {
+ "description": "Required. The list of audiences that can appear in the issued token. Should be set to api://AzureADTokenExchange for Azure AD. It says what Microsoft identity platform should accept in the aud claim in the incoming token. This value represents Azure AD in your external identity provider and has no fixed value across identity providers - you might need to create a new application registration in your IdP to serve as the audience of this token."
+ }
+ },
+ "issuer": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The URL of the issuer to be trusted. Must match the issuer claim of the external token being exchanged."
+ }
+ },
+ "subject": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The identifier of the external software workload within the external identity provider. Like the audience value, it has no fixed format, as each IdP uses their own - sometimes a GUID, sometimes a colon delimited identifier, sometimes arbitrary strings. The value here must match the sub claim within the token presented to Azure AD."
+ }
+ }
+ },
+ "resources": [
+ {
+ "type": "Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials",
+ "apiVersion": "2024-11-30",
+ "name": "[format('{0}/{1}', parameters('userAssignedIdentityName'), parameters('name'))]",
+ "properties": {
+ "audiences": "[parameters('audiences')]",
+ "issuer": "[parameters('issuer')]",
+ "subject": "[parameters('subject')]"
+ }
+ }
+ ],
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the federated identity credential."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the federated identity credential."
+ },
+ "value": "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials', parameters('userAssignedIdentityName'), parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the resource group the federated identity credential was created in."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "userAssignedIdentity"
+ ]
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the user assigned identity."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the user assigned identity."
+ },
+ "value": "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('name'))]"
+ },
+ "principalId": {
+ "type": "string",
+ "metadata": {
+ "description": "The principal ID (object ID) of the user assigned identity."
+ },
+ "value": "[reference('userAssignedIdentity').principalId]"
+ },
+ "clientId": {
+ "type": "string",
+ "metadata": {
+ "description": "The client ID (application ID) of the user assigned identity."
+ },
+ "value": "[reference('userAssignedIdentity').clientId]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group the user assigned identity was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ },
+ "location": {
+ "type": "string",
+ "metadata": {
+ "description": "The location the resource was deployed into."
+ },
+ "value": "[reference('userAssignedIdentity', '2024-11-30', 'full').location]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "[subscriptionResourceId('Microsoft.Resources/resourceGroups', if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName'))))]"
+ ]
+ },
+ {
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2025-04-01",
+ "name": "appserviceplan",
+ "resourceGroup": "[if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "name": "[if(not(empty(parameters('appServicePlanName'))), createObject('value', parameters('appServicePlanName')), createObject('value', format('{0}{1}', variables('abbrs').webServerFarms, variables('resourceToken'))))]",
+ "sku": {
+ "value": {
+ "name": "FC1",
+ "tier": "FlexConsumption"
+ }
+ },
+ "reserved": {
+ "value": true
+ },
+ "location": {
+ "value": "[parameters('location')]"
+ },
+ "tags": {
+ "value": "[variables('tags')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.25.53.49325",
+ "templateHash": "14640671403143559618"
+ },
+ "name": "App Service Plan",
+ "description": "This module deploys an App Service Plan.",
+ "owner": "Azure/module-maintainers"
+ },
+ "definitions": {
+ "lockType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the name of lock."
+ }
+ },
+ "kind": {
+ "type": "string",
+ "allowedValues": [
+ "CanNotDelete",
+ "None",
+ "ReadOnly"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the type of lock."
+ }
+ }
+ },
+ "nullable": true
+ },
+ "roleAssignmentType": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "roleDefinitionIdOrName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The role to assign. You can provide either the display name of the role definition, the role definition GUID, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'."
+ }
+ },
+ "principalId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The principal ID of the principal (user/group/identity) to assign the role to."
+ }
+ },
+ "principalType": {
+ "type": "string",
+ "allowedValues": [
+ "Device",
+ "ForeignGroup",
+ "Group",
+ "ServicePrincipal",
+ "User"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The principal type of the assigned principal ID."
+ }
+ },
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The description of the role assignment."
+ }
+ },
+ "condition": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase \"foo_storage_container\"."
+ }
+ },
+ "conditionVersion": {
+ "type": "string",
+ "allowedValues": [
+ "2.0"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Version of the condition."
+ }
+ },
+ "delegatedManagedIdentityResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The Resource Id of the delegated managed identity resource."
+ }
+ }
+ }
+ },
+ "nullable": true
+ },
+ "diagnosticSettingType": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of diagnostic setting."
+ }
+ },
+ "metricCategories": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "category": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of a Diagnostic Metric category for a resource type this setting is applied to. Set to `AllMetrics` to collect all metrics."
+ }
+ },
+ "enabled": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable or disable the category explicitly. Default is `true`."
+ }
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of metrics that will be streamed. \"allMetrics\" includes all possible metrics for the resource. Set to `[]` to disable metric collection."
+ }
+ },
+ "logAnalyticsDestinationType": {
+ "type": "string",
+ "allowedValues": [
+ "AzureDiagnostics",
+ "Dedicated"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type."
+ }
+ },
+ "workspaceResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic log analytics workspace. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "storageAccountResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic storage account. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "eventHubAuthorizationRuleResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to."
+ }
+ },
+ "eventHubName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of the diagnostic event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "marketplacePartnerResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The full ARM resource ID of the Marketplace resource to which you would like to send Diagnostic Logs."
+ }
+ }
+ }
+ },
+ "nullable": true
+ }
+ },
+ "parameters": {
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 60,
+ "metadata": {
+ "description": "Required. Name of the app service plan."
+ }
+ },
+ "sku": {
+ "type": "object",
+ "metadata": {
+ "example": " {\n name: 'P1v3'\n tier: 'Premium'\n size: 'P1v3'\n family: 'P'\n capacity: 3\n }\n ",
+ "description": "Required. Defines the name, tier, size, family and capacity of the App Service Plan."
+ }
+ },
+ "location": {
+ "type": "string",
+ "defaultValue": "[resourceGroup().location]",
+ "metadata": {
+ "description": "Optional. Location for all resources."
+ }
+ },
+ "kind": {
+ "type": "string",
+ "defaultValue": "App",
+ "allowedValues": [
+ "App",
+ "Elastic",
+ "FunctionApp",
+ "Windows",
+ "Linux"
+ ],
+ "metadata": {
+ "description": "Optional. Kind of server OS."
+ }
+ },
+ "reserved": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Conditional. Defaults to false when creating Windows/app App Service Plan. Required if creating a Linux App Service Plan and must be set to true."
+ }
+ },
+ "appServiceEnvironmentId": {
+ "type": "string",
+ "defaultValue": "",
+ "metadata": {
+ "description": "Optional. The Resource ID of the App Service Environment to use for the App Service Plan."
+ }
+ },
+ "workerTierName": {
+ "type": "string",
+ "defaultValue": "",
+ "metadata": {
+ "description": "Optional. Target worker tier assigned to the App Service plan."
+ }
+ },
+ "perSiteScaling": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. If true, apps assigned to this App Service plan can be scaled independently. If false, apps assigned to this App Service plan will scale to all instances of the plan."
+ }
+ },
+ "maximumElasticWorkerCount": {
+ "type": "int",
+ "defaultValue": 1,
+ "metadata": {
+ "description": "Optional. Maximum number of total workers allowed for this ElasticScaleEnabled App Service Plan."
+ }
+ },
+ "targetWorkerCount": {
+ "type": "int",
+ "defaultValue": 0,
+ "metadata": {
+ "description": "Optional. Scaling worker count."
+ }
+ },
+ "targetWorkerSize": {
+ "type": "int",
+ "defaultValue": 0,
+ "allowedValues": [
+ 0,
+ 1,
+ 2
+ ],
+ "metadata": {
+ "description": "Optional. The instance size of the hosting plan (small, medium, or large)."
+ }
+ },
+ "zoneRedundant": {
+ "type": "bool",
+ "defaultValue": "[if(or(equals(parameters('sku').tier, 'Premium'), equals(parameters('sku').tier, 'ElasticPremium')), true(), false())]",
+ "metadata": {
+ "description": "Optional. Zone Redundancy can only be used on Premium or ElasticPremium SKU Tiers within ZRS Supported regions (https://learn.microsoft.com/en-us/azure/storage/common/redundancy-regions-zrs)."
+ }
+ },
+ "lock": {
+ "$ref": "#/definitions/lockType",
+ "metadata": {
+ "description": "Optional. The lock settings of the service."
+ }
+ },
+ "roleAssignments": {
+ "$ref": "#/definitions/roleAssignmentType",
+ "metadata": {
+ "description": "Optional. Array of role assignments to create."
+ }
+ },
+ "tags": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Tags of the resource."
+ }
+ },
+ "enableTelemetry": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. Enable/Disable usage telemetry for module."
+ }
+ },
+ "diagnosticSettings": {
+ "$ref": "#/definitions/diagnosticSettingType",
+ "metadata": {
+ "description": "Optional. The diagnostic settings of the service."
+ }
+ }
+ },
+ "variables": {
+ "builtInRoleNames": {
+ "Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
+ "Owner": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]",
+ "Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'acdd72a7-3385-48ef-bd42-f606fba81ae7')]",
+ "Role Based Access Control Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'f58310d9-a9f6-439a-9e8d-f62e7b41a168')]",
+ "User Access Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '18d7d88d-d35e-4fb5-a5c3-7773c20a72d9')]",
+ "Web Plan Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '2cc479cb-7b4d-49a8-b449-8c00fd0f0a4b')]",
+ "Website Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'de139f84-1756-47ae-9be6-808fbbe84772')]"
+ }
+ },
+ "resources": {
+ "avmTelemetry": {
+ "condition": "[parameters('enableTelemetry')]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2023-07-01",
+ "name": "[format('46d3xbcp.res.web-serverfarm.{0}.{1}', replace('0.1.1', '.', '-'), substring(uniqueString(deployment().name, parameters('location')), 0, 4))]",
+ "properties": {
+ "mode": "Incremental",
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "resources": [],
+ "outputs": {
+ "telemetry": {
+ "type": "String",
+ "value": "For more information, see https://aka.ms/avm/TelemetryInfo"
+ }
+ }
+ }
+ }
+ },
+ "appServicePlan": {
+ "type": "Microsoft.Web/serverfarms",
+ "apiVersion": "2022-09-01",
+ "name": "[parameters('name')]",
+ "kind": "[parameters('kind')]",
+ "location": "[parameters('location')]",
+ "tags": "[parameters('tags')]",
+ "sku": "[parameters('sku')]",
+ "properties": {
+ "workerTierName": "[parameters('workerTierName')]",
+ "hostingEnvironmentProfile": "[if(not(empty(parameters('appServiceEnvironmentId'))), createObject('id', parameters('appServiceEnvironmentId')), null())]",
+ "perSiteScaling": "[parameters('perSiteScaling')]",
+ "maximumElasticWorkerCount": "[parameters('maximumElasticWorkerCount')]",
+ "reserved": "[parameters('reserved')]",
+ "targetWorkerCount": "[parameters('targetWorkerCount')]",
+ "targetWorkerSizeId": "[parameters('targetWorkerSize')]",
+ "zoneRedundant": "[parameters('zoneRedundant')]"
+ }
+ },
+ "appServicePlan_diagnosticSettings": {
+ "copy": {
+ "name": "appServicePlan_diagnosticSettings",
+ "count": "[length(coalesce(parameters('diagnosticSettings'), createArray()))]"
+ },
+ "type": "Microsoft.Insights/diagnosticSettings",
+ "apiVersion": "2021-05-01-preview",
+ "scope": "[format('Microsoft.Web/serverfarms/{0}', parameters('name'))]",
+ "name": "[coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'name'), format('{0}-diagnosticSettings', parameters('name')))]",
+ "properties": {
+ "copy": [
+ {
+ "name": "metrics",
+ "count": "[length(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics'))))]",
+ "input": {
+ "category": "[coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics')))[copyIndex('metrics')].category]",
+ "enabled": "[coalesce(tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics')))[copyIndex('metrics')], 'enabled'), true())]",
+ "timeGrain": null
+ }
+ }
+ ],
+ "storageAccountId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'storageAccountResourceId')]",
+ "workspaceId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'workspaceResourceId')]",
+ "eventHubAuthorizationRuleId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'eventHubAuthorizationRuleResourceId')]",
+ "eventHubName": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'eventHubName')]",
+ "marketplacePartnerId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'marketplacePartnerResourceId')]",
+ "logAnalyticsDestinationType": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logAnalyticsDestinationType')]"
+ },
+ "dependsOn": [
+ "appServicePlan"
+ ]
+ },
+ "appServicePlan_lock": {
+ "condition": "[and(not(empty(coalesce(parameters('lock'), createObject()))), not(equals(tryGet(parameters('lock'), 'kind'), 'None')))]",
+ "type": "Microsoft.Authorization/locks",
+ "apiVersion": "2020-05-01",
+ "scope": "[format('Microsoft.Web/serverfarms/{0}', parameters('name'))]",
+ "name": "[coalesce(tryGet(parameters('lock'), 'name'), format('lock-{0}', parameters('name')))]",
+ "properties": {
+ "level": "[coalesce(tryGet(parameters('lock'), 'kind'), '')]",
+ "notes": "[if(equals(tryGet(parameters('lock'), 'kind'), 'CanNotDelete'), 'Cannot delete resource or child resources.', 'Cannot delete or modify the resource or child resources.')]"
+ },
+ "dependsOn": [
+ "appServicePlan"
+ ]
+ },
+ "appServicePlan_roleAssignments": {
+ "copy": {
+ "name": "appServicePlan_roleAssignments",
+ "count": "[length(coalesce(parameters('roleAssignments'), createArray()))]"
+ },
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Web/serverfarms/{0}', parameters('name'))]",
+ "name": "[guid(resourceId('Microsoft.Web/serverfarms', parameters('name')), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].principalId, coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName)]",
+ "properties": {
+ "roleDefinitionId": "[if(contains(variables('builtInRoleNames'), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName), variables('builtInRoleNames')[coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName], if(contains(coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/'), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName)))]",
+ "principalId": "[coalesce(parameters('roleAssignments'), createArray())[copyIndex()].principalId]",
+ "description": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'description')]",
+ "principalType": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'principalType')]",
+ "condition": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'condition')]",
+ "conditionVersion": "[if(not(empty(tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'condition'))), coalesce(tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'conditionVersion'), '2.0'), null())]",
+ "delegatedManagedIdentityResourceId": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'delegatedManagedIdentityResourceId')]"
+ },
+ "dependsOn": [
+ "appServicePlan"
+ ]
+ }
+ },
+ "outputs": {
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group the app service plan was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ },
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the app service plan."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the app service plan."
+ },
+ "value": "[resourceId('Microsoft.Web/serverfarms', parameters('name'))]"
+ },
+ "location": {
+ "type": "string",
+ "metadata": {
+ "description": "The location the resource was deployed into."
+ },
+ "value": "[reference('appServicePlan', '2022-09-01', 'full').location]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "[subscriptionResourceId('Microsoft.Resources/resourceGroups', if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName'))))]"
+ ]
+ },
+ {
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2025-04-01",
+ "name": "[format('{0}-loganalytics', uniqueString(deployment().name, parameters('location')))]",
+ "resourceGroup": "[if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "name": "[if(not(empty(parameters('logAnalyticsName'))), createObject('value', parameters('logAnalyticsName')), createObject('value', format('{0}{1}', variables('abbrs').operationalInsightsWorkspaces, variables('resourceToken'))))]",
+ "location": {
+ "value": "[parameters('location')]"
+ },
+ "tags": {
+ "value": "[variables('tags')]"
+ },
+ "dataRetention": {
+ "value": 30
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "4588928420314680274"
+ },
+ "name": "Log Analytics Workspaces",
+ "description": "This module deploys a Log Analytics Workspace."
+ },
+ "definitions": {
+ "diagnosticSettingType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of diagnostic setting."
+ }
+ },
+ "logCategoriesAndGroups": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "category": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of a Diagnostic Log category for a resource type this setting is applied to. Set the specific logs to collect here."
+ }
+ },
+ "categoryGroup": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of a Diagnostic Log category group for a resource type this setting is applied to. Set to `allLogs` to collect all logs."
+ }
+ },
+ "enabled": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable or disable the category explicitly. Default is `true`."
+ }
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of logs that will be streamed. \"allLogs\" includes all possible logs for the resource. Set to `[]` to disable log collection."
+ }
+ },
+ "metricCategories": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "category": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of a Diagnostic Metric category for a resource type this setting is applied to. Set to `AllMetrics` to collect all metrics."
+ }
+ },
+ "enabled": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable or disable the category explicitly. Default is `true`."
+ }
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of metrics that will be streamed. \"allMetrics\" includes all possible metrics for the resource. Set to `[]` to disable metric collection."
+ }
+ },
+ "logAnalyticsDestinationType": {
+ "type": "string",
+ "allowedValues": [
+ "AzureDiagnostics",
+ "Dedicated"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type."
+ }
+ },
+ "useThisWorkspace": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Instead of using an external reference, use the deployed instance as the target for its diagnostic settings. If set to `true`, the `workspaceResourceId` property is ignored."
+ }
+ },
+ "workspaceResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic log analytics workspace. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "storageAccountResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic storage account. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "eventHubAuthorizationRuleResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to."
+ }
+ },
+ "eventHubName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of the diagnostic event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "marketplacePartnerResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The full ARM resource ID of the Marketplace resource to which you would like to send Diagnostic Logs."
+ }
+ }
+ }
+ },
+ "gallerySolutionType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of the solution.\nFor solutions authored by Microsoft, the name must be in the pattern: `SolutionType(WorkspaceName)`, for example: `AntiMalware(contoso-Logs)`.\nFor solutions authored by third parties, the name should be in the pattern: `SolutionType[WorkspaceName]`, for example `MySolution[contoso-Logs]`.\nThe solution type is case-sensitive."
+ }
+ },
+ "plan": {
+ "$ref": "#/definitions/solutionPlanType",
+ "metadata": {
+ "description": "Required. Plan for solution object supported by the OperationsManagement resource provider."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true,
+ "description": "Properties of the gallery solutions to be created in the log analytics workspace."
+ }
+ },
+ "storageInsightsConfigType": {
+ "type": "object",
+ "properties": {
+ "storageAccountResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Resource ID of the storage account to be linked."
+ }
+ },
+ "containers": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The names of the blob containers that the workspace should read."
+ }
+ },
+ "tables": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. List of tables to be read by the workspace."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true,
+ "description": "Properties of the storage insights configuration."
+ }
+ },
+ "linkedServiceType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of the linked service."
+ }
+ },
+ "resourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The resource id of the resource that will be linked to the workspace. This should be used for linking resources which require read access."
+ }
+ },
+ "writeAccessResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The resource id of the resource that will be linked to the workspace. This should be used for linking resources which require write access."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true,
+ "description": "Properties of the linked service."
+ }
+ },
+ "linkedStorageAccountType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of the link."
+ }
+ },
+ "storageAccountIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "minLength": 1,
+ "metadata": {
+ "description": "Required. Linked storage accounts resources Ids."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true,
+ "description": "Properties of the linked storage account."
+ }
+ },
+ "savedSearchType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of the saved search."
+ }
+ },
+ "etag": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The ETag of the saved search. To override an existing saved search, use \"*\" or specify the current Etag."
+ }
+ },
+ "category": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The category of the saved search. This helps the user to find a saved search faster."
+ }
+ },
+ "displayName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Display name for the search."
+ }
+ },
+ "functionAlias": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The function alias if query serves as a function."
+ }
+ },
+ "functionParameters": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The optional function parameters if query serves as a function. Value should be in the following format: 'param-name1:type1 = default_value1, param-name2:type2 = default_value2'. For more examples and proper syntax please refer to /azure/kusto/query/functions/user-defined-functions."
+ }
+ },
+ "query": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The query expression for the saved search."
+ }
+ },
+ "tags": {
+ "type": "array",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The tags attached to the saved search."
+ }
+ },
+ "version": {
+ "type": "int",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The version number of the query language. The current version is 2 and is the default."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true,
+ "description": "Properties of the saved search."
+ }
+ },
+ "dataExportType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of the data export."
+ }
+ },
+ "destination": {
+ "$ref": "#/definitions/destinationType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The destination of the data export."
+ }
+ },
+ "enable": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable or disable the data export."
+ }
+ },
+ "tableNames": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "metadata": {
+ "description": "Required. The list of table names to export."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true,
+ "description": "Properties of the data export."
+ }
+ },
+ "dataSourceType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of the data source."
+ }
+ },
+ "kind": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The kind of data source."
+ }
+ },
+ "linkedResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The resource id of the resource that will be linked to the workspace."
+ }
+ },
+ "eventLogName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of the event log to configure when kind is WindowsEvent."
+ }
+ },
+ "eventTypes": {
+ "type": "array",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The event types to configure when kind is WindowsEvent."
+ }
+ },
+ "objectName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of the object to configure when kind is WindowsPerformanceCounter or LinuxPerformanceObject."
+ }
+ },
+ "instanceName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of the instance to configure when kind is WindowsPerformanceCounter or LinuxPerformanceObject."
+ }
+ },
+ "intervalSeconds": {
+ "type": "int",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Interval in seconds to configure when kind is WindowsPerformanceCounter or LinuxPerformanceObject."
+ }
+ },
+ "performanceCounters": {
+ "type": "array",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. List of counters to configure when the kind is LinuxPerformanceObject."
+ }
+ },
+ "counterName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Counter name to configure when kind is WindowsPerformanceCounter."
+ }
+ },
+ "state": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. State to configure when kind is IISLogs or LinuxSyslogCollection or LinuxPerformanceCollection."
+ }
+ },
+ "syslogName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. System log to configure when kind is LinuxSyslog."
+ }
+ },
+ "syslogSeverities": {
+ "type": "array",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Severities to configure when kind is LinuxSyslog."
+ }
+ },
+ "tags": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Tags to configure in the resource."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true,
+ "description": "Properties of the data source."
+ }
+ },
+ "tableType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the table."
+ }
+ },
+ "plan": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The plan for the table."
+ }
+ },
+ "restoredLogs": {
+ "$ref": "#/definitions/restoredLogsType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The restored logs for the table."
+ }
+ },
+ "schema": {
+ "$ref": "#/definitions/schemaType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The schema for the table."
+ }
+ },
+ "searchResults": {
+ "$ref": "#/definitions/searchResultsType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The search results for the table."
+ }
+ },
+ "retentionInDays": {
+ "type": "int",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The retention in days for the table."
+ }
+ },
+ "totalRetentionInDays": {
+ "type": "int",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The total retention in days for the table."
+ }
+ },
+ "roleAssignments": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/roleAssignmentType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The role assignments for the table."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true,
+ "description": "Properties of the custom table."
+ }
+ },
+ "workspaceFeaturesType": {
+ "type": "object",
+ "properties": {
+ "disableLocalAuth": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Disable Non-EntraID based Auth. Default is true."
+ }
+ },
+ "enableDataExport": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Flag that indicate if data should be exported."
+ }
+ },
+ "enableLogAccessUsingOnlyResourcePermissions": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable log access using only resource permissions. Default is false."
+ }
+ },
+ "immediatePurgeDataOn30Days": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Flag that describes if we want to remove the data after 30 days."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true,
+ "description": "Features of the workspace."
+ }
+ },
+ "_1.columnType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The column name."
+ }
+ },
+ "type": {
+ "type": "string",
+ "allowedValues": [
+ "boolean",
+ "dateTime",
+ "dynamic",
+ "guid",
+ "int",
+ "long",
+ "real",
+ "string"
+ ],
+ "metadata": {
+ "description": "Required. The column type."
+ }
+ },
+ "dataTypeHint": {
+ "type": "string",
+ "allowedValues": [
+ "armPath",
+ "guid",
+ "ip",
+ "uri"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The column data type logical hint."
+ }
+ },
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The column description."
+ }
+ },
+ "displayName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Column display name."
+ }
+ }
+ },
+ "metadata": {
+ "description": "The parameters of the table column.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "table/main.bicep"
+ }
+ }
+ },
+ "destinationType": {
+ "type": "object",
+ "properties": {
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The destination resource ID."
+ }
+ },
+ "metaData": {
+ "type": "object",
+ "properties": {
+ "eventHubName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Allows to define an Event Hub name. Not applicable when destination is Storage Account."
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The destination metadata."
+ }
+ }
+ },
+ "metadata": {
+ "description": "The data export destination properties.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "data-export/main.bicep"
+ }
+ }
+ },
+ "lockType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the name of lock."
+ }
+ },
+ "kind": {
+ "type": "string",
+ "allowedValues": [
+ "CanNotDelete",
+ "None",
+ "ReadOnly"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the type of lock."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a lock.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.2.1"
+ }
+ }
+ },
+ "managedIdentityAllType": {
+ "type": "object",
+ "properties": {
+ "systemAssigned": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enables system assigned managed identity on the resource."
+ }
+ },
+ "userAssignedResourceIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The resource ID(s) to assign to the resource. Required if a user assigned identity is used for encryption."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a managed identity configuration. To be used if both a system-assigned & user-assigned identities are supported by the resource provider.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.2.1"
+ }
+ }
+ },
+ "restoredLogsType": {
+ "type": "object",
+ "properties": {
+ "sourceTable": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The table to restore data from."
+ }
+ },
+ "startRestoreTime": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The timestamp to start the restore from (UTC)."
+ }
+ },
+ "endRestoreTime": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The timestamp to end the restore by (UTC)."
+ }
+ }
+ },
+ "metadata": {
+ "description": "The parameters of the restore operation that initiated the table.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "table/main.bicep"
+ }
+ }
+ },
+ "roleAssignmentType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name (as GUID) of the role assignment. If not provided, a GUID will be generated."
+ }
+ },
+ "roleDefinitionIdOrName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The role to assign. You can provide either the display name of the role definition, the role definition GUID, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'."
+ }
+ },
+ "principalId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The principal ID of the principal (user/group/identity) to assign the role to."
+ }
+ },
+ "principalType": {
+ "type": "string",
+ "allowedValues": [
+ "Device",
+ "ForeignGroup",
+ "Group",
+ "ServicePrincipal",
+ "User"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The principal type of the assigned principal ID."
+ }
+ },
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The description of the role assignment."
+ }
+ },
+ "condition": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase \"foo_storage_container\"."
+ }
+ },
+ "conditionVersion": {
+ "type": "string",
+ "allowedValues": [
+ "2.0"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Version of the condition."
+ }
+ },
+ "delegatedManagedIdentityResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The Resource Id of the delegated managed identity resource."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a role assignment.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.2.1"
+ }
+ }
+ },
+ "schemaType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The table name."
+ }
+ },
+ "columns": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/_1.columnType"
+ },
+ "metadata": {
+ "description": "Required. A list of table custom columns."
+ }
+ },
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The table description."
+ }
+ },
+ "displayName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The table display name."
+ }
+ }
+ },
+ "metadata": {
+ "description": "The table schema.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "table/main.bicep"
+ }
+ }
+ },
+ "searchResultsType": {
+ "type": "object",
+ "properties": {
+ "query": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The search job query."
+ }
+ },
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The search description."
+ }
+ },
+ "limit": {
+ "type": "int",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Limit the search job to return up to specified number of rows."
+ }
+ },
+ "startSearchTime": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The timestamp to start the search from (UTC)."
+ }
+ },
+ "endSearchTime": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The timestamp to end the search by (UTC)."
+ }
+ }
+ },
+ "metadata": {
+ "description": "The parameters of the search job that initiated the table.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "table/main.bicep"
+ }
+ }
+ },
+ "solutionPlanType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of the solution to be created.\nFor solutions authored by Microsoft, the name must be in the pattern: `SolutionType(WorkspaceName)`, for example: `AntiMalware(contoso-Logs)`.\nFor solutions authored by third parties, it can be anything.\nThe solution type is case-sensitive.\nIf not provided, the value of the `name` parameter will be used."
+ }
+ },
+ "product": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The product name of the deployed solution.\nFor Microsoft published gallery solution it should be `OMSGallery/{solutionType}`, for example `OMSGallery/AntiMalware`.\nFor a third party solution, it can be anything.\nThis is case sensitive."
+ }
+ },
+ "publisher": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The publisher name of the deployed solution. For Microsoft published gallery solution, it is `Microsoft`, which is the default value."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/res/operations-management/solution:0.3.0"
+ }
+ }
+ }
+ },
+ "parameters": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of the Log Analytics workspace."
+ }
+ },
+ "location": {
+ "type": "string",
+ "defaultValue": "[resourceGroup().location]",
+ "metadata": {
+ "description": "Optional. Location for all resources."
+ }
+ },
+ "skuName": {
+ "type": "string",
+ "defaultValue": "PerGB2018",
+ "allowedValues": [
+ "CapacityReservation",
+ "Free",
+ "LACluster",
+ "PerGB2018",
+ "PerNode",
+ "Premium",
+ "Standalone",
+ "Standard"
+ ],
+ "metadata": {
+ "description": "Optional. The name of the SKU."
+ }
+ },
+ "skuCapacityReservationLevel": {
+ "type": "int",
+ "defaultValue": 100,
+ "minValue": 100,
+ "maxValue": 5000,
+ "metadata": {
+ "description": "Optional. The capacity reservation level in GB for this workspace, when CapacityReservation sku is selected. Must be in increments of 100 between 100 and 5000."
+ }
+ },
+ "storageInsightsConfigs": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/storageInsightsConfigType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. List of storage accounts to be read by the workspace."
+ }
+ },
+ "linkedServices": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linkedServiceType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. List of services to be linked."
+ }
+ },
+ "linkedStorageAccounts": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/linkedStorageAccountType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Conditional. List of Storage Accounts to be linked. Required if 'forceCmkForQuery' is set to 'true' and 'savedSearches' is not empty."
+ }
+ },
+ "savedSearches": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/savedSearchType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Kusto Query Language searches to save."
+ }
+ },
+ "dataExports": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/dataExportType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. LAW data export instances to be deployed."
+ }
+ },
+ "dataSources": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/dataSourceType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. LAW data sources to configure."
+ }
+ },
+ "tables": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/tableType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. LAW custom tables to be deployed."
+ }
+ },
+ "gallerySolutions": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/gallerySolutionType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. List of gallerySolutions to be created in the log analytics workspace."
+ }
+ },
+ "onboardWorkspaceToSentinel": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. Onboard the Log Analytics Workspace to Sentinel. Requires 'SecurityInsights' solution to be in gallerySolutions."
+ }
+ },
+ "dataRetention": {
+ "type": "int",
+ "defaultValue": 365,
+ "minValue": 0,
+ "maxValue": 730,
+ "metadata": {
+ "description": "Optional. Number of days data will be retained for."
+ }
+ },
+ "dailyQuotaGb": {
+ "type": "int",
+ "defaultValue": -1,
+ "minValue": -1,
+ "metadata": {
+ "description": "Optional. The workspace daily quota for ingestion."
+ }
+ },
+ "publicNetworkAccessForIngestion": {
+ "type": "string",
+ "defaultValue": "Enabled",
+ "allowedValues": [
+ "Enabled",
+ "Disabled"
+ ],
+ "metadata": {
+ "description": "Optional. The network access type for accessing Log Analytics ingestion."
+ }
+ },
+ "publicNetworkAccessForQuery": {
+ "type": "string",
+ "defaultValue": "Enabled",
+ "allowedValues": [
+ "Enabled",
+ "Disabled"
+ ],
+ "metadata": {
+ "description": "Optional. The network access type for accessing Log Analytics query."
+ }
+ },
+ "managedIdentities": {
+ "$ref": "#/definitions/managedIdentityAllType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The managed identity definition for this resource. Only one type of identity is supported: system-assigned or user-assigned, but not both."
+ }
+ },
+ "features": {
+ "$ref": "#/definitions/workspaceFeaturesType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The workspace features."
+ }
+ },
+ "diagnosticSettings": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/diagnosticSettingType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The diagnostic settings of the service."
+ }
+ },
+ "forceCmkForQuery": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. Indicates whether customer managed storage is mandatory for query management."
+ }
+ },
+ "lock": {
+ "$ref": "#/definitions/lockType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The lock settings of the service."
+ }
+ },
+ "roleAssignments": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/roleAssignmentType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Array of role assignments to create."
+ }
+ },
+ "tags": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Tags of the resource."
+ }
+ },
+ "enableTelemetry": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. Enable/Disable usage telemetry for module."
+ }
+ }
+ },
+ "variables": {
+ "copy": [
+ {
+ "name": "formattedRoleAssignments",
+ "count": "[length(coalesce(parameters('roleAssignments'), createArray()))]",
+ "input": "[union(coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')], createObject('roleDefinitionId', coalesce(tryGet(variables('builtInRoleNames'), coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName), if(contains(coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/'), coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName)))))]"
+ }
+ ],
+ "enableReferencedModulesTelemetry": false,
+ "formattedUserAssignedIdentities": "[reduce(map(coalesce(tryGet(parameters('managedIdentities'), 'userAssignedResourceIds'), createArray()), lambda('id', createObject(format('{0}', lambdaVariables('id')), createObject()))), createObject(), lambda('cur', 'next', union(lambdaVariables('cur'), lambdaVariables('next'))))]",
+ "identity": "[if(not(empty(parameters('managedIdentities'))), createObject('type', if(coalesce(tryGet(parameters('managedIdentities'), 'systemAssigned'), false()), 'SystemAssigned', if(not(empty(coalesce(tryGet(parameters('managedIdentities'), 'userAssignedResourceIds'), createObject()))), 'UserAssigned', 'None')), 'userAssignedIdentities', if(not(empty(variables('formattedUserAssignedIdentities'))), variables('formattedUserAssignedIdentities'), null())), null())]",
+ "builtInRoleNames": {
+ "Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
+ "Log Analytics Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '92aaf0da-9dab-42b6-94a3-d43ce8d16293')]",
+ "Log Analytics Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '73c42c96-874c-492b-b04d-ab87d138a893')]",
+ "Monitoring Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '749f88d5-cbae-40b8-bcfc-e573ddc772fa')]",
+ "Monitoring Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '43d0d8ad-25c7-4714-9337-8ba259a9fe05')]",
+ "Owner": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]",
+ "Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'acdd72a7-3385-48ef-bd42-f606fba81ae7')]",
+ "Role Based Access Control Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'f58310d9-a9f6-439a-9e8d-f62e7b41a168')]",
+ "Security Admin": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'fb1c8493-542b-48eb-b624-b4c8fea62acd')]",
+ "Security Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '39bc4728-0917-49c7-9d2c-d95423bc2eb4')]",
+ "User Access Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '18d7d88d-d35e-4fb5-a5c3-7773c20a72d9')]"
+ }
+ },
+ "resources": {
+ "avmTelemetry": {
+ "condition": "[parameters('enableTelemetry')]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2024-03-01",
+ "name": "[format('46d3xbcp.res.operationalinsights-workspace.{0}.{1}', replace('0.11.1', '.', '-'), substring(uniqueString(deployment().name, parameters('location')), 0, 4))]",
+ "properties": {
+ "mode": "Incremental",
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "resources": [],
+ "outputs": {
+ "telemetry": {
+ "type": "String",
+ "value": "For more information, see https://aka.ms/avm/TelemetryInfo"
+ }
+ }
+ }
+ }
+ },
+ "logAnalyticsWorkspace": {
+ "type": "Microsoft.OperationalInsights/workspaces",
+ "apiVersion": "2023-09-01",
+ "name": "[parameters('name')]",
+ "location": "[parameters('location')]",
+ "tags": "[parameters('tags')]",
+ "properties": {
+ "features": {
+ "searchVersion": 1,
+ "enableLogAccessUsingOnlyResourcePermissions": "[coalesce(tryGet(parameters('features'), 'enableLogAccessUsingOnlyResourcePermissions'), false())]",
+ "disableLocalAuth": "[coalesce(tryGet(parameters('features'), 'disableLocalAuth'), true())]",
+ "enableDataExport": "[tryGet(parameters('features'), 'enableDataExport')]",
+ "immediatePurgeDataOn30Days": "[tryGet(parameters('features'), 'immediatePurgeDataOn30Days')]"
+ },
+ "sku": {
+ "name": "[parameters('skuName')]",
+ "capacityReservationLevel": "[if(equals(parameters('skuName'), 'CapacityReservation'), parameters('skuCapacityReservationLevel'), null())]"
+ },
+ "retentionInDays": "[parameters('dataRetention')]",
+ "workspaceCapping": {
+ "dailyQuotaGb": "[parameters('dailyQuotaGb')]"
+ },
+ "publicNetworkAccessForIngestion": "[parameters('publicNetworkAccessForIngestion')]",
+ "publicNetworkAccessForQuery": "[parameters('publicNetworkAccessForQuery')]",
+ "forceCmkForQuery": "[parameters('forceCmkForQuery')]"
+ },
+ "identity": "[variables('identity')]"
+ },
+ "logAnalyticsWorkspace_diagnosticSettings": {
+ "copy": {
+ "name": "logAnalyticsWorkspace_diagnosticSettings",
+ "count": "[length(coalesce(parameters('diagnosticSettings'), createArray()))]"
+ },
+ "type": "Microsoft.Insights/diagnosticSettings",
+ "apiVersion": "2021-05-01-preview",
+ "scope": "[format('Microsoft.OperationalInsights/workspaces/{0}', parameters('name'))]",
+ "name": "[coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'name'), format('{0}-diagnosticSettings', parameters('name')))]",
+ "properties": {
+ "copy": [
+ {
+ "name": "metrics",
+ "count": "[length(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics'))))]",
+ "input": {
+ "category": "[coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics')))[copyIndex('metrics')].category]",
+ "enabled": "[coalesce(tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics')))[copyIndex('metrics')], 'enabled'), true())]",
+ "timeGrain": null
+ }
+ },
+ {
+ "name": "logs",
+ "count": "[length(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs'))))]",
+ "input": {
+ "categoryGroup": "[tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'categoryGroup')]",
+ "category": "[tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'category')]",
+ "enabled": "[coalesce(tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'enabled'), true())]"
+ }
+ }
+ ],
+ "storageAccountId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'storageAccountResourceId')]",
+ "workspaceId": "[if(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'useThisWorkspace'), false()), resourceId('Microsoft.OperationalInsights/workspaces', parameters('name')), tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'workspaceResourceId'))]",
+ "eventHubAuthorizationRuleId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'eventHubAuthorizationRuleResourceId')]",
+ "eventHubName": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'eventHubName')]",
+ "marketplacePartnerId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'marketplacePartnerResourceId')]",
+ "logAnalyticsDestinationType": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logAnalyticsDestinationType')]"
+ },
+ "dependsOn": [
+ "logAnalyticsWorkspace"
+ ]
+ },
+ "logAnalyticsWorkspace_sentinelOnboarding": {
+ "condition": "[and(not(empty(filter(coalesce(parameters('gallerySolutions'), createArray()), lambda('item', startsWith(lambdaVariables('item').name, 'SecurityInsights'))))), parameters('onboardWorkspaceToSentinel'))]",
+ "type": "Microsoft.SecurityInsights/onboardingStates",
+ "apiVersion": "2024-03-01",
+ "scope": "[format('Microsoft.OperationalInsights/workspaces/{0}', parameters('name'))]",
+ "name": "default",
+ "properties": {},
+ "dependsOn": [
+ "logAnalyticsWorkspace"
+ ]
+ },
+ "logAnalyticsWorkspace_lock": {
+ "condition": "[and(not(empty(coalesce(parameters('lock'), createObject()))), not(equals(tryGet(parameters('lock'), 'kind'), 'None')))]",
+ "type": "Microsoft.Authorization/locks",
+ "apiVersion": "2020-05-01",
+ "scope": "[format('Microsoft.OperationalInsights/workspaces/{0}', parameters('name'))]",
+ "name": "[coalesce(tryGet(parameters('lock'), 'name'), format('lock-{0}', parameters('name')))]",
+ "properties": {
+ "level": "[coalesce(tryGet(parameters('lock'), 'kind'), '')]",
+ "notes": "[if(equals(tryGet(parameters('lock'), 'kind'), 'CanNotDelete'), 'Cannot delete resource or child resources.', 'Cannot delete or modify the resource or child resources.')]"
+ },
+ "dependsOn": [
+ "logAnalyticsWorkspace"
+ ]
+ },
+ "logAnalyticsWorkspace_roleAssignments": {
+ "copy": {
+ "name": "logAnalyticsWorkspace_roleAssignments",
+ "count": "[length(coalesce(variables('formattedRoleAssignments'), createArray()))]"
+ },
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.OperationalInsights/workspaces/{0}', parameters('name'))]",
+ "name": "[coalesce(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'name'), guid(resourceId('Microsoft.OperationalInsights/workspaces', parameters('name')), coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].principalId, coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].roleDefinitionId))]",
+ "properties": {
+ "roleDefinitionId": "[coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].roleDefinitionId]",
+ "principalId": "[coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].principalId]",
+ "description": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'description')]",
+ "principalType": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'principalType')]",
+ "condition": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'condition')]",
+ "conditionVersion": "[if(not(empty(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'condition'))), coalesce(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'conditionVersion'), '2.0'), null())]",
+ "delegatedManagedIdentityResourceId": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'delegatedManagedIdentityResourceId')]"
+ },
+ "dependsOn": [
+ "logAnalyticsWorkspace"
+ ]
+ },
+ "logAnalyticsWorkspace_storageInsightConfigs": {
+ "copy": {
+ "name": "logAnalyticsWorkspace_storageInsightConfigs",
+ "count": "[length(coalesce(parameters('storageInsightsConfigs'), createArray()))]"
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-LAW-StorageInsightsConfig-{1}', uniqueString(deployment().name, parameters('location')), copyIndex())]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "logAnalyticsWorkspaceName": {
+ "value": "[parameters('name')]"
+ },
+ "containers": {
+ "value": "[tryGet(coalesce(parameters('storageInsightsConfigs'), createArray())[copyIndex()], 'containers')]"
+ },
+ "tables": {
+ "value": "[tryGet(coalesce(parameters('storageInsightsConfigs'), createArray())[copyIndex()], 'tables')]"
+ },
+ "storageAccountResourceId": {
+ "value": "[coalesce(parameters('storageInsightsConfigs'), createArray())[copyIndex()].storageAccountResourceId]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "14024094214852981332"
+ },
+ "name": "Log Analytics Workspace Storage Insight Configs",
+ "description": "This module deploys a Log Analytics Workspace Storage Insight Config."
+ },
+ "parameters": {
+ "logAnalyticsWorkspaceName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent Log Analytics workspace. Required if the template is used in a standalone deployment."
+ }
+ },
+ "name": {
+ "type": "string",
+ "defaultValue": "[format('{0}-stinsconfig', last(split(parameters('storageAccountResourceId'), '/')))]",
+ "metadata": {
+ "description": "Optional. The name of the storage insights config."
+ }
+ },
+ "storageAccountResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The Azure Resource Manager ID of the storage account resource."
+ }
+ },
+ "containers": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The names of the blob containers that the workspace should read."
+ }
+ },
+ "tables": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The names of the Azure tables that the workspace should read."
+ }
+ },
+ "tags": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Tags to configure in the resource."
+ }
+ }
+ },
+ "resources": {
+ "storageAccount": {
+ "existing": true,
+ "type": "Microsoft.Storage/storageAccounts",
+ "apiVersion": "2022-09-01",
+ "name": "[last(split(parameters('storageAccountResourceId'), '/'))]"
+ },
+ "workspace": {
+ "existing": true,
+ "type": "Microsoft.OperationalInsights/workspaces",
+ "apiVersion": "2023-09-01",
+ "name": "[parameters('logAnalyticsWorkspaceName')]"
+ },
+ "storageinsightconfig": {
+ "type": "Microsoft.OperationalInsights/workspaces/storageInsightConfigs",
+ "apiVersion": "2023-09-01",
+ "name": "[format('{0}/{1}', parameters('logAnalyticsWorkspaceName'), parameters('name'))]",
+ "tags": "[parameters('tags')]",
+ "properties": {
+ "containers": "[parameters('containers')]",
+ "tables": "[parameters('tables')]",
+ "storageAccount": {
+ "id": "[parameters('storageAccountResourceId')]",
+ "key": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', last(split(parameters('storageAccountResourceId'), '/'))), '2022-09-01').keys[0].value]"
+ }
+ }
+ }
+ },
+ "outputs": {
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the deployed storage insights configuration."
+ },
+ "value": "[resourceId('Microsoft.OperationalInsights/workspaces/storageInsightConfigs', parameters('logAnalyticsWorkspaceName'), parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group where the storage insight configuration is deployed."
+ },
+ "value": "[resourceGroup().name]"
+ },
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the storage insights configuration."
+ },
+ "value": "[parameters('name')]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "logAnalyticsWorkspace"
+ ]
+ },
+ "logAnalyticsWorkspace_linkedServices": {
+ "copy": {
+ "name": "logAnalyticsWorkspace_linkedServices",
+ "count": "[length(coalesce(parameters('linkedServices'), createArray()))]"
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-LAW-LinkedService-{1}', uniqueString(deployment().name, parameters('location')), copyIndex())]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "logAnalyticsWorkspaceName": {
+ "value": "[parameters('name')]"
+ },
+ "name": {
+ "value": "[coalesce(parameters('linkedServices'), createArray())[copyIndex()].name]"
+ },
+ "resourceId": {
+ "value": "[tryGet(coalesce(parameters('linkedServices'), createArray())[copyIndex()], 'resourceId')]"
+ },
+ "writeAccessResourceId": {
+ "value": "[tryGet(coalesce(parameters('linkedServices'), createArray())[copyIndex()], 'writeAccessResourceId')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "15202444687633091947"
+ },
+ "name": "Log Analytics Workspace Linked Services",
+ "description": "This module deploys a Log Analytics Workspace Linked Service."
+ },
+ "parameters": {
+ "logAnalyticsWorkspaceName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent Log Analytics workspace. Required if the template is used in a standalone deployment."
+ }
+ },
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of the link."
+ }
+ },
+ "resourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The resource ID of the resource that will be linked to the workspace. This should be used for linking resources which require read access."
+ }
+ },
+ "writeAccessResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The resource ID of the resource that will be linked to the workspace. This should be used for linking resources which require write access."
+ }
+ },
+ "tags": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Tags to configure in the resource."
+ }
+ }
+ },
+ "resources": {
+ "workspace": {
+ "existing": true,
+ "type": "Microsoft.OperationalInsights/workspaces",
+ "apiVersion": "2023-09-01",
+ "name": "[parameters('logAnalyticsWorkspaceName')]"
+ },
+ "linkedService": {
+ "type": "Microsoft.OperationalInsights/workspaces/linkedServices",
+ "apiVersion": "2023-09-01",
+ "name": "[format('{0}/{1}', parameters('logAnalyticsWorkspaceName'), parameters('name'))]",
+ "tags": "[parameters('tags')]",
+ "properties": {
+ "resourceId": "[parameters('resourceId')]",
+ "writeAccessResourceId": "[parameters('writeAccessResourceId')]"
+ }
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the deployed linked service."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the deployed linked service."
+ },
+ "value": "[resourceId('Microsoft.OperationalInsights/workspaces/linkedServices', parameters('logAnalyticsWorkspaceName'), parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group where the linked service is deployed."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "logAnalyticsWorkspace"
+ ]
+ },
+ "logAnalyticsWorkspace_linkedStorageAccounts": {
+ "copy": {
+ "name": "logAnalyticsWorkspace_linkedStorageAccounts",
+ "count": "[length(coalesce(parameters('linkedStorageAccounts'), createArray()))]"
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-LAW-LinkedStorageAccount-{1}', uniqueString(deployment().name, parameters('location')), copyIndex())]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "logAnalyticsWorkspaceName": {
+ "value": "[parameters('name')]"
+ },
+ "name": {
+ "value": "[coalesce(parameters('linkedStorageAccounts'), createArray())[copyIndex()].name]"
+ },
+ "storageAccountIds": {
+ "value": "[coalesce(parameters('linkedStorageAccounts'), createArray())[copyIndex()].storageAccountIds]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "1489251440210164837"
+ },
+ "name": "Log Analytics Workspace Linked Storage Accounts",
+ "description": "This module deploys a Log Analytics Workspace Linked Storage Account."
+ },
+ "parameters": {
+ "logAnalyticsWorkspaceName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent Log Analytics workspace. Required if the template is used in a standalone deployment."
+ }
+ },
+ "name": {
+ "type": "string",
+ "allowedValues": [
+ "Query",
+ "Alerts",
+ "CustomLogs",
+ "AzureWatson"
+ ],
+ "metadata": {
+ "description": "Required. Name of the link."
+ }
+ },
+ "storageAccountIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "minLength": 1,
+ "metadata": {
+ "description": "Required. Linked storage accounts resources Ids."
+ }
+ }
+ },
+ "resources": {
+ "workspace": {
+ "existing": true,
+ "type": "Microsoft.OperationalInsights/workspaces",
+ "apiVersion": "2023-09-01",
+ "name": "[parameters('logAnalyticsWorkspaceName')]"
+ },
+ "linkedStorageAccount": {
+ "type": "Microsoft.OperationalInsights/workspaces/linkedStorageAccounts",
+ "apiVersion": "2023-09-01",
+ "name": "[format('{0}/{1}', parameters('logAnalyticsWorkspaceName'), parameters('name'))]",
+ "properties": {
+ "storageAccountIds": "[parameters('storageAccountIds')]"
+ }
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the deployed linked storage account."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the deployed linked storage account."
+ },
+ "value": "[resourceId('Microsoft.OperationalInsights/workspaces/linkedStorageAccounts', parameters('logAnalyticsWorkspaceName'), parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group where the linked storage account is deployed."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "logAnalyticsWorkspace"
+ ]
+ },
+ "logAnalyticsWorkspace_savedSearches": {
+ "copy": {
+ "name": "logAnalyticsWorkspace_savedSearches",
+ "count": "[length(coalesce(parameters('savedSearches'), createArray()))]"
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-LAW-SavedSearch-{1}', uniqueString(deployment().name, parameters('location')), copyIndex())]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "logAnalyticsWorkspaceName": {
+ "value": "[parameters('name')]"
+ },
+ "name": {
+ "value": "[format('{0}{1}', coalesce(parameters('savedSearches'), createArray())[copyIndex()].name, uniqueString(deployment().name))]"
+ },
+ "etag": {
+ "value": "[tryGet(coalesce(parameters('savedSearches'), createArray())[copyIndex()], 'etag')]"
+ },
+ "displayName": {
+ "value": "[coalesce(parameters('savedSearches'), createArray())[copyIndex()].displayName]"
+ },
+ "category": {
+ "value": "[coalesce(parameters('savedSearches'), createArray())[copyIndex()].category]"
+ },
+ "query": {
+ "value": "[coalesce(parameters('savedSearches'), createArray())[copyIndex()].query]"
+ },
+ "functionAlias": {
+ "value": "[tryGet(coalesce(parameters('savedSearches'), createArray())[copyIndex()], 'functionAlias')]"
+ },
+ "functionParameters": {
+ "value": "[tryGet(coalesce(parameters('savedSearches'), createArray())[copyIndex()], 'functionParameters')]"
+ },
+ "tags": {
+ "value": "[tryGet(coalesce(parameters('savedSearches'), createArray())[copyIndex()], 'tags')]"
+ },
+ "version": {
+ "value": "[tryGet(coalesce(parameters('savedSearches'), createArray())[copyIndex()], 'version')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "14407663387414945082"
+ },
+ "name": "Log Analytics Workspace Saved Searches",
+ "description": "This module deploys a Log Analytics Workspace Saved Search."
+ },
+ "parameters": {
+ "logAnalyticsWorkspaceName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent Log Analytics workspace. Required if the template is used in a standalone deployment."
+ }
+ },
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of the saved search."
+ }
+ },
+ "displayName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Display name for the search."
+ }
+ },
+ "category": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Query category."
+ }
+ },
+ "query": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Kusto Query to be stored."
+ }
+ },
+ "tags": {
+ "type": "array",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Tags to configure in the resource."
+ }
+ },
+ "functionAlias": {
+ "type": "string",
+ "defaultValue": "",
+ "metadata": {
+ "description": "Optional. The function alias if query serves as a function."
+ }
+ },
+ "functionParameters": {
+ "type": "string",
+ "defaultValue": "",
+ "metadata": {
+ "description": "Optional. The optional function parameters if query serves as a function. Value should be in the following format: \"param-name1:type1 = default_value1, param-name2:type2 = default_value2\". For more examples and proper syntax please refer to /azure/kusto/query/functions/user-defined-functions."
+ }
+ },
+ "version": {
+ "type": "int",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The version number of the query language."
+ }
+ },
+ "etag": {
+ "type": "string",
+ "defaultValue": "*",
+ "metadata": {
+ "description": "Optional. The ETag of the saved search. To override an existing saved search, use \"*\" or specify the current Etag."
+ }
+ }
+ },
+ "resources": {
+ "workspace": {
+ "existing": true,
+ "type": "Microsoft.OperationalInsights/workspaces",
+ "apiVersion": "2023-09-01",
+ "name": "[parameters('logAnalyticsWorkspaceName')]"
+ },
+ "savedSearch": {
+ "type": "Microsoft.OperationalInsights/workspaces/savedSearches",
+ "apiVersion": "2023-09-01",
+ "name": "[format('{0}/{1}', parameters('logAnalyticsWorkspaceName'), parameters('name'))]",
+ "properties": {
+ "etag": "[parameters('etag')]",
+ "tags": "[coalesce(parameters('tags'), createArray())]",
+ "displayName": "[parameters('displayName')]",
+ "category": "[parameters('category')]",
+ "query": "[parameters('query')]",
+ "functionAlias": "[parameters('functionAlias')]",
+ "functionParameters": "[parameters('functionParameters')]",
+ "version": "[parameters('version')]"
+ }
+ }
+ },
+ "outputs": {
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the deployed saved search."
+ },
+ "value": "[resourceId('Microsoft.OperationalInsights/workspaces/savedSearches', parameters('logAnalyticsWorkspaceName'), parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group where the saved search is deployed."
+ },
+ "value": "[resourceGroup().name]"
+ },
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the deployed saved search."
+ },
+ "value": "[parameters('name')]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "logAnalyticsWorkspace",
+ "logAnalyticsWorkspace_linkedStorageAccounts"
+ ]
+ },
+ "logAnalyticsWorkspace_dataExports": {
+ "copy": {
+ "name": "logAnalyticsWorkspace_dataExports",
+ "count": "[length(coalesce(parameters('dataExports'), createArray()))]"
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-LAW-DataExport-{1}', uniqueString(deployment().name, parameters('location')), copyIndex())]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "workspaceName": {
+ "value": "[parameters('name')]"
+ },
+ "name": {
+ "value": "[coalesce(parameters('dataExports'), createArray())[copyIndex()].name]"
+ },
+ "destination": {
+ "value": "[tryGet(coalesce(parameters('dataExports'), createArray())[copyIndex()], 'destination')]"
+ },
+ "enable": {
+ "value": "[tryGet(coalesce(parameters('dataExports'), createArray())[copyIndex()], 'enable')]"
+ },
+ "tableNames": {
+ "value": "[tryGet(coalesce(parameters('dataExports'), createArray())[copyIndex()], 'tableNames')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "15082251740316718256"
+ },
+ "name": "Log Analytics Workspace Data Exports",
+ "description": "This module deploys a Log Analytics Workspace Data Export."
+ },
+ "definitions": {
+ "destinationType": {
+ "type": "object",
+ "properties": {
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The destination resource ID."
+ }
+ },
+ "metaData": {
+ "type": "object",
+ "properties": {
+ "eventHubName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Allows to define an Event Hub name. Not applicable when destination is Storage Account."
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The destination metadata."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true,
+ "description": "The data export destination properties."
+ }
+ }
+ },
+ "parameters": {
+ "name": {
+ "type": "string",
+ "minLength": 4,
+ "maxLength": 63,
+ "metadata": {
+ "description": "Required. The data export rule name."
+ }
+ },
+ "workspaceName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent workspaces. Required if the template is used in a standalone deployment."
+ }
+ },
+ "destination": {
+ "$ref": "#/definitions/destinationType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Destination properties."
+ }
+ },
+ "enable": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. Active when enabled."
+ }
+ },
+ "tableNames": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "minLength": 1,
+ "metadata": {
+ "description": "Required. An array of tables to export, for example: ['Heartbeat', 'SecurityEvent']."
+ }
+ }
+ },
+ "resources": {
+ "workspace": {
+ "existing": true,
+ "type": "Microsoft.OperationalInsights/workspaces",
+ "apiVersion": "2023-09-01",
+ "name": "[parameters('workspaceName')]"
+ },
+ "dataExport": {
+ "type": "Microsoft.OperationalInsights/workspaces/dataExports",
+ "apiVersion": "2023-09-01",
+ "name": "[format('{0}/{1}', parameters('workspaceName'), parameters('name'))]",
+ "properties": {
+ "destination": "[parameters('destination')]",
+ "enable": "[parameters('enable')]",
+ "tableNames": "[parameters('tableNames')]"
+ }
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the data export."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the data export."
+ },
+ "value": "[resourceId('Microsoft.OperationalInsights/workspaces/dataExports', parameters('workspaceName'), parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the resource group the data export was created in."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "logAnalyticsWorkspace"
+ ]
+ },
+ "logAnalyticsWorkspace_dataSources": {
+ "copy": {
+ "name": "logAnalyticsWorkspace_dataSources",
+ "count": "[length(coalesce(parameters('dataSources'), createArray()))]"
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-LAW-DataSource-{1}', uniqueString(deployment().name, parameters('location')), copyIndex())]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "logAnalyticsWorkspaceName": {
+ "value": "[parameters('name')]"
+ },
+ "name": {
+ "value": "[coalesce(parameters('dataSources'), createArray())[copyIndex()].name]"
+ },
+ "kind": {
+ "value": "[coalesce(parameters('dataSources'), createArray())[copyIndex()].kind]"
+ },
+ "linkedResourceId": {
+ "value": "[tryGet(coalesce(parameters('dataSources'), createArray())[copyIndex()], 'linkedResourceId')]"
+ },
+ "eventLogName": {
+ "value": "[tryGet(coalesce(parameters('dataSources'), createArray())[copyIndex()], 'eventLogName')]"
+ },
+ "eventTypes": {
+ "value": "[tryGet(coalesce(parameters('dataSources'), createArray())[copyIndex()], 'eventTypes')]"
+ },
+ "objectName": {
+ "value": "[tryGet(coalesce(parameters('dataSources'), createArray())[copyIndex()], 'objectName')]"
+ },
+ "instanceName": {
+ "value": "[tryGet(coalesce(parameters('dataSources'), createArray())[copyIndex()], 'instanceName')]"
+ },
+ "intervalSeconds": {
+ "value": "[tryGet(coalesce(parameters('dataSources'), createArray())[copyIndex()], 'intervalSeconds')]"
+ },
+ "counterName": {
+ "value": "[tryGet(coalesce(parameters('dataSources'), createArray())[copyIndex()], 'counterName')]"
+ },
+ "state": {
+ "value": "[tryGet(coalesce(parameters('dataSources'), createArray())[copyIndex()], 'state')]"
+ },
+ "syslogName": {
+ "value": "[tryGet(coalesce(parameters('dataSources'), createArray())[copyIndex()], 'syslogName')]"
+ },
+ "syslogSeverities": {
+ "value": "[tryGet(coalesce(parameters('dataSources'), createArray())[copyIndex()], 'syslogSeverities')]"
+ },
+ "performanceCounters": {
+ "value": "[tryGet(coalesce(parameters('dataSources'), createArray())[copyIndex()], 'performanceCounters')]"
+ },
+ "tags": {
+ "value": "[tryGet(coalesce(parameters('dataSources'), createArray())[copyIndex()], 'tags')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "3186325409788999053"
+ },
+ "name": "Log Analytics Workspace Datasources",
+ "description": "This module deploys a Log Analytics Workspace Data Source."
+ },
+ "parameters": {
+ "logAnalyticsWorkspaceName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent Log Analytics workspace. Required if the template is used in a standalone deployment."
+ }
+ },
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of the data source."
+ }
+ },
+ "kind": {
+ "type": "string",
+ "defaultValue": "AzureActivityLog",
+ "allowedValues": [
+ "AzureActivityLog",
+ "WindowsEvent",
+ "WindowsPerformanceCounter",
+ "IISLogs",
+ "LinuxSyslog",
+ "LinuxSyslogCollection",
+ "LinuxPerformanceObject",
+ "LinuxPerformanceCollection"
+ ],
+ "metadata": {
+ "description": "Optional. The kind of the data source."
+ }
+ },
+ "tags": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Tags to configure in the resource."
+ }
+ },
+ "linkedResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the resource to be linked."
+ }
+ },
+ "eventLogName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Windows event log name to configure when kind is WindowsEvent."
+ }
+ },
+ "eventTypes": {
+ "type": "array",
+ "defaultValue": [],
+ "metadata": {
+ "description": "Optional. Windows event types to configure when kind is WindowsEvent."
+ }
+ },
+ "objectName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of the object to configure when kind is WindowsPerformanceCounter or LinuxPerformanceObject."
+ }
+ },
+ "instanceName": {
+ "type": "string",
+ "defaultValue": "*",
+ "metadata": {
+ "description": "Optional. Name of the instance to configure when kind is WindowsPerformanceCounter or LinuxPerformanceObject."
+ }
+ },
+ "intervalSeconds": {
+ "type": "int",
+ "defaultValue": 60,
+ "metadata": {
+ "description": "Optional. Interval in seconds to configure when kind is WindowsPerformanceCounter or LinuxPerformanceObject."
+ }
+ },
+ "performanceCounters": {
+ "type": "array",
+ "defaultValue": [],
+ "metadata": {
+ "description": "Optional. List of counters to configure when the kind is LinuxPerformanceObject."
+ }
+ },
+ "counterName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Counter name to configure when kind is WindowsPerformanceCounter."
+ }
+ },
+ "state": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. State to configure when kind is IISLogs or LinuxSyslogCollection or LinuxPerformanceCollection."
+ }
+ },
+ "syslogName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. System log to configure when kind is LinuxSyslog."
+ }
+ },
+ "syslogSeverities": {
+ "type": "array",
+ "defaultValue": [],
+ "metadata": {
+ "description": "Optional. Severities to configure when kind is LinuxSyslog."
+ }
+ }
+ },
+ "resources": {
+ "workspace": {
+ "existing": true,
+ "type": "Microsoft.OperationalInsights/workspaces",
+ "apiVersion": "2023-09-01",
+ "name": "[parameters('logAnalyticsWorkspaceName')]"
+ },
+ "dataSource": {
+ "type": "Microsoft.OperationalInsights/workspaces/dataSources",
+ "apiVersion": "2023-09-01",
+ "name": "[format('{0}/{1}', parameters('logAnalyticsWorkspaceName'), parameters('name'))]",
+ "kind": "[parameters('kind')]",
+ "tags": "[parameters('tags')]",
+ "properties": {
+ "linkedResourceId": "[if(and(not(empty(parameters('kind'))), equals(parameters('kind'), 'AzureActivityLog')), parameters('linkedResourceId'), null())]",
+ "eventLogName": "[if(and(not(empty(parameters('kind'))), equals(parameters('kind'), 'WindowsEvent')), parameters('eventLogName'), null())]",
+ "eventTypes": "[if(and(not(empty(parameters('kind'))), equals(parameters('kind'), 'WindowsEvent')), parameters('eventTypes'), null())]",
+ "objectName": "[if(and(not(empty(parameters('kind'))), or(equals(parameters('kind'), 'WindowsPerformanceCounter'), equals(parameters('kind'), 'LinuxPerformanceObject'))), parameters('objectName'), null())]",
+ "instanceName": "[if(and(not(empty(parameters('kind'))), or(equals(parameters('kind'), 'WindowsPerformanceCounter'), equals(parameters('kind'), 'LinuxPerformanceObject'))), parameters('instanceName'), null())]",
+ "intervalSeconds": "[if(and(not(empty(parameters('kind'))), or(equals(parameters('kind'), 'WindowsPerformanceCounter'), equals(parameters('kind'), 'LinuxPerformanceObject'))), parameters('intervalSeconds'), null())]",
+ "counterName": "[if(and(not(empty(parameters('kind'))), equals(parameters('kind'), 'WindowsPerformanceCounter')), parameters('counterName'), null())]",
+ "state": "[if(and(not(empty(parameters('kind'))), or(or(equals(parameters('kind'), 'IISLogs'), equals(parameters('kind'), 'LinuxSyslogCollection')), equals(parameters('kind'), 'LinuxPerformanceCollection'))), parameters('state'), null())]",
+ "syslogName": "[if(and(not(empty(parameters('kind'))), equals(parameters('kind'), 'LinuxSyslog')), parameters('syslogName'), null())]",
+ "syslogSeverities": "[if(and(not(empty(parameters('kind'))), or(equals(parameters('kind'), 'LinuxSyslog'), equals(parameters('kind'), 'LinuxPerformanceObject'))), parameters('syslogSeverities'), null())]",
+ "performanceCounters": "[if(and(not(empty(parameters('kind'))), equals(parameters('kind'), 'LinuxPerformanceObject')), parameters('performanceCounters'), null())]"
+ }
+ }
+ },
+ "outputs": {
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the deployed data source."
+ },
+ "value": "[resourceId('Microsoft.OperationalInsights/workspaces/dataSources', parameters('logAnalyticsWorkspaceName'), parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group where the data source is deployed."
+ },
+ "value": "[resourceGroup().name]"
+ },
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the deployed data source."
+ },
+ "value": "[parameters('name')]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "logAnalyticsWorkspace"
+ ]
+ },
+ "logAnalyticsWorkspace_tables": {
+ "copy": {
+ "name": "logAnalyticsWorkspace_tables",
+ "count": "[length(coalesce(parameters('tables'), createArray()))]"
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-LAW-Table-{1}', uniqueString(deployment().name, parameters('location')), copyIndex())]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "workspaceName": {
+ "value": "[parameters('name')]"
+ },
+ "name": {
+ "value": "[coalesce(parameters('tables'), createArray())[copyIndex()].name]"
+ },
+ "plan": {
+ "value": "[tryGet(coalesce(parameters('tables'), createArray())[copyIndex()], 'plan')]"
+ },
+ "schema": {
+ "value": "[tryGet(coalesce(parameters('tables'), createArray())[copyIndex()], 'schema')]"
+ },
+ "retentionInDays": {
+ "value": "[tryGet(coalesce(parameters('tables'), createArray())[copyIndex()], 'retentionInDays')]"
+ },
+ "totalRetentionInDays": {
+ "value": "[tryGet(coalesce(parameters('tables'), createArray())[copyIndex()], 'totalRetentionInDays')]"
+ },
+ "restoredLogs": {
+ "value": "[tryGet(coalesce(parameters('tables'), createArray())[copyIndex()], 'restoredLogs')]"
+ },
+ "searchResults": {
+ "value": "[tryGet(coalesce(parameters('tables'), createArray())[copyIndex()], 'searchResults')]"
+ },
+ "roleAssignments": {
+ "value": "[tryGet(coalesce(parameters('tables'), createArray())[copyIndex()], 'roleAssignments')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "4329017759962267155"
+ },
+ "name": "Log Analytics Workspace Tables",
+ "description": "This module deploys a Log Analytics Workspace Table."
+ },
+ "definitions": {
+ "restoredLogsType": {
+ "type": "object",
+ "properties": {
+ "sourceTable": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The table to restore data from."
+ }
+ },
+ "startRestoreTime": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The timestamp to start the restore from (UTC)."
+ }
+ },
+ "endRestoreTime": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The timestamp to end the restore by (UTC)."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true,
+ "description": "The parameters of the restore operation that initiated the table."
+ }
+ },
+ "schemaType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The table name."
+ }
+ },
+ "columns": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/columnType"
+ },
+ "metadata": {
+ "description": "Required. A list of table custom columns."
+ }
+ },
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The table description."
+ }
+ },
+ "displayName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The table display name."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true,
+ "description": "The table schema."
+ }
+ },
+ "columnType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The column name."
+ }
+ },
+ "type": {
+ "type": "string",
+ "allowedValues": [
+ "boolean",
+ "dateTime",
+ "dynamic",
+ "guid",
+ "int",
+ "long",
+ "real",
+ "string"
+ ],
+ "metadata": {
+ "description": "Required. The column type."
+ }
+ },
+ "dataTypeHint": {
+ "type": "string",
+ "allowedValues": [
+ "armPath",
+ "guid",
+ "ip",
+ "uri"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The column data type logical hint."
+ }
+ },
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The column description."
+ }
+ },
+ "displayName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Column display name."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true,
+ "description": "The parameters of the table column."
+ }
+ },
+ "searchResultsType": {
+ "type": "object",
+ "properties": {
+ "query": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The search job query."
+ }
+ },
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The search description."
+ }
+ },
+ "limit": {
+ "type": "int",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Limit the search job to return up to specified number of rows."
+ }
+ },
+ "startSearchTime": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The timestamp to start the search from (UTC)."
+ }
+ },
+ "endSearchTime": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The timestamp to end the search by (UTC)."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true,
+ "description": "The parameters of the search job that initiated the table."
+ }
+ },
+ "roleAssignmentType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name (as GUID) of the role assignment. If not provided, a GUID will be generated."
+ }
+ },
+ "roleDefinitionIdOrName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The role to assign. You can provide either the display name of the role definition, the role definition GUID, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'."
+ }
+ },
+ "principalId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The principal ID of the principal (user/group/identity) to assign the role to."
+ }
+ },
+ "principalType": {
+ "type": "string",
+ "allowedValues": [
+ "Device",
+ "ForeignGroup",
+ "Group",
+ "ServicePrincipal",
+ "User"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The principal type of the assigned principal ID."
+ }
+ },
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The description of the role assignment."
+ }
+ },
+ "condition": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase \"foo_storage_container\"."
+ }
+ },
+ "conditionVersion": {
+ "type": "string",
+ "allowedValues": [
+ "2.0"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Version of the condition."
+ }
+ },
+ "delegatedManagedIdentityResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The Resource Id of the delegated managed identity resource."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a role assignment.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.2.1"
+ }
+ }
+ }
+ },
+ "parameters": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the table."
+ }
+ },
+ "workspaceName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent workspaces. Required if the template is used in a standalone deployment."
+ }
+ },
+ "plan": {
+ "type": "string",
+ "defaultValue": "Analytics",
+ "allowedValues": [
+ "Basic",
+ "Analytics"
+ ],
+ "metadata": {
+ "description": "Optional. Instruct the system how to handle and charge the logs ingested to this table."
+ }
+ },
+ "restoredLogs": {
+ "$ref": "#/definitions/restoredLogsType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Restore parameters."
+ }
+ },
+ "retentionInDays": {
+ "type": "int",
+ "defaultValue": -1,
+ "minValue": -1,
+ "maxValue": 730,
+ "metadata": {
+ "description": "Optional. The table retention in days, between 4 and 730. Setting this property to -1 will default to the workspace retention."
+ }
+ },
+ "schema": {
+ "$ref": "#/definitions/schemaType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Table's schema."
+ }
+ },
+ "searchResults": {
+ "$ref": "#/definitions/searchResultsType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Parameters of the search job that initiated this table."
+ }
+ },
+ "totalRetentionInDays": {
+ "type": "int",
+ "defaultValue": -1,
+ "minValue": -1,
+ "maxValue": 2555,
+ "metadata": {
+ "description": "Optional. The table total retention in days, between 4 and 2555. Setting this property to -1 will default to table retention."
+ }
+ },
+ "roleAssignments": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/roleAssignmentType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Array of role assignments to create."
+ }
+ }
+ },
+ "variables": {
+ "copy": [
+ {
+ "name": "formattedRoleAssignments",
+ "count": "[length(coalesce(parameters('roleAssignments'), createArray()))]",
+ "input": "[union(coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')], createObject('roleDefinitionId', coalesce(tryGet(variables('builtInRoleNames'), coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName), if(contains(coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/'), coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName)))))]"
+ }
+ ],
+ "builtInRoleNames": {
+ "Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
+ "Log Analytics Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '92aaf0da-9dab-42b6-94a3-d43ce8d16293')]",
+ "Log Analytics Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '73c42c96-874c-492b-b04d-ab87d138a893')]",
+ "Monitoring Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '749f88d5-cbae-40b8-bcfc-e573ddc772fa')]",
+ "Monitoring Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '43d0d8ad-25c7-4714-9337-8ba259a9fe05')]",
+ "Owner": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]",
+ "Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'acdd72a7-3385-48ef-bd42-f606fba81ae7')]",
+ "Role Based Access Control Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'f58310d9-a9f6-439a-9e8d-f62e7b41a168')]",
+ "User Access Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '18d7d88d-d35e-4fb5-a5c3-7773c20a72d9')]"
+ }
+ },
+ "resources": {
+ "workspace": {
+ "existing": true,
+ "type": "Microsoft.OperationalInsights/workspaces",
+ "apiVersion": "2023-09-01",
+ "name": "[parameters('workspaceName')]"
+ },
+ "table": {
+ "type": "Microsoft.OperationalInsights/workspaces/tables",
+ "apiVersion": "2023-09-01",
+ "name": "[format('{0}/{1}', parameters('workspaceName'), parameters('name'))]",
+ "properties": {
+ "plan": "[parameters('plan')]",
+ "restoredLogs": "[parameters('restoredLogs')]",
+ "retentionInDays": "[parameters('retentionInDays')]",
+ "schema": "[parameters('schema')]",
+ "searchResults": "[parameters('searchResults')]",
+ "totalRetentionInDays": "[parameters('totalRetentionInDays')]"
+ }
+ },
+ "table_roleAssignments": {
+ "copy": {
+ "name": "table_roleAssignments",
+ "count": "[length(coalesce(variables('formattedRoleAssignments'), createArray()))]"
+ },
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.OperationalInsights/workspaces/{0}/tables/{1}', parameters('workspaceName'), parameters('name'))]",
+ "name": "[coalesce(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'name'), guid(resourceId('Microsoft.OperationalInsights/workspaces/tables', parameters('workspaceName'), parameters('name')), coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].principalId, coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].roleDefinitionId))]",
+ "properties": {
+ "roleDefinitionId": "[coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].roleDefinitionId]",
+ "principalId": "[coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].principalId]",
+ "description": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'description')]",
+ "principalType": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'principalType')]",
+ "condition": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'condition')]",
+ "conditionVersion": "[if(not(empty(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'condition'))), coalesce(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'conditionVersion'), '2.0'), null())]",
+ "delegatedManagedIdentityResourceId": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'delegatedManagedIdentityResourceId')]"
+ },
+ "dependsOn": [
+ "table"
+ ]
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the table."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the table."
+ },
+ "value": "[resourceId('Microsoft.OperationalInsights/workspaces/tables', parameters('workspaceName'), parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the resource group the table was created in."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "logAnalyticsWorkspace"
+ ]
+ },
+ "logAnalyticsWorkspace_solutions": {
+ "copy": {
+ "name": "logAnalyticsWorkspace_solutions",
+ "count": "[length(coalesce(parameters('gallerySolutions'), createArray()))]"
+ },
+ "condition": "[not(empty(parameters('gallerySolutions')))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-LAW-Solution-{1}', uniqueString(deployment().name, parameters('location')), copyIndex())]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "name": {
+ "value": "[coalesce(parameters('gallerySolutions'), createArray())[copyIndex()].name]"
+ },
+ "location": {
+ "value": "[parameters('location')]"
+ },
+ "logAnalyticsWorkspaceName": {
+ "value": "[parameters('name')]"
+ },
+ "plan": {
+ "value": "[coalesce(parameters('gallerySolutions'), createArray())[copyIndex()].plan]"
+ },
+ "enableTelemetry": {
+ "value": "[variables('enableReferencedModulesTelemetry')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.30.23.60470",
+ "templateHash": "1867653058254938383"
+ },
+ "name": "Operations Management Solutions",
+ "description": "This module deploys an Operations Management Solution.",
+ "owner": "Azure/module-maintainers"
+ },
+ "definitions": {
+ "solutionPlanType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of the solution to be created.\nFor solutions authored by Microsoft, the name must be in the pattern: `SolutionType(WorkspaceName)`, for example: `AntiMalware(contoso-Logs)`.\nFor solutions authored by third parties, it can be anything.\nThe solution type is case-sensitive.\nIf not provided, the value of the `name` parameter will be used."
+ }
+ },
+ "product": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The product name of the deployed solution.\nFor Microsoft published gallery solution it should be `OMSGallery/{solutionType}`, for example `OMSGallery/AntiMalware`.\nFor a third party solution, it can be anything.\nThis is case sensitive."
+ }
+ },
+ "publisher": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The publisher name of the deployed solution. For Microsoft published gallery solution, it is `Microsoft`, which is the default value."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true
+ }
+ }
+ },
+ "parameters": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of the solution.\nFor solutions authored by Microsoft, the name must be in the pattern: `SolutionType(WorkspaceName)`, for example: `AntiMalware(contoso-Logs)`.\nFor solutions authored by third parties, the name should be in the pattern: `SolutionType[WorkspaceName]`, for example `MySolution[contoso-Logs]`.\nThe solution type is case-sensitive."
+ }
+ },
+ "plan": {
+ "$ref": "#/definitions/solutionPlanType",
+ "metadata": {
+ "description": "Required. Plan for solution object supported by the OperationsManagement resource provider."
+ }
+ },
+ "logAnalyticsWorkspaceName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of the Log Analytics workspace where the solution will be deployed/enabled."
+ }
+ },
+ "location": {
+ "type": "string",
+ "defaultValue": "[resourceGroup().location]",
+ "metadata": {
+ "description": "Optional. Location for all resources."
+ }
+ },
+ "enableTelemetry": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. Enable/Disable usage telemetry for module."
+ }
+ }
+ },
+ "resources": {
+ "avmTelemetry": {
+ "condition": "[parameters('enableTelemetry')]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2024-03-01",
+ "name": "[format('46d3xbcp.res.operationsmanagement-solution.{0}.{1}', replace('0.3.0', '.', '-'), substring(uniqueString(deployment().name, parameters('location')), 0, 4))]",
+ "properties": {
+ "mode": "Incremental",
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "resources": [],
+ "outputs": {
+ "telemetry": {
+ "type": "String",
+ "value": "For more information, see https://aka.ms/avm/TelemetryInfo"
+ }
+ }
+ }
+ }
+ },
+ "logAnalyticsWorkspace": {
+ "existing": true,
+ "type": "Microsoft.OperationalInsights/workspaces",
+ "apiVersion": "2021-06-01",
+ "name": "[parameters('logAnalyticsWorkspaceName')]"
+ },
+ "solution": {
+ "type": "Microsoft.OperationsManagement/solutions",
+ "apiVersion": "2015-11-01-preview",
+ "name": "[parameters('name')]",
+ "location": "[parameters('location')]",
+ "properties": {
+ "workspaceResourceId": "[resourceId('Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceName'))]"
+ },
+ "plan": {
+ "name": "[coalesce(tryGet(parameters('plan'), 'name'), parameters('name'))]",
+ "promotionCode": "",
+ "product": "[parameters('plan').product]",
+ "publisher": "[coalesce(tryGet(parameters('plan'), 'publisher'), 'Microsoft')]"
+ },
+ "dependsOn": [
+ "logAnalyticsWorkspace"
+ ]
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the deployed solution."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the deployed solution."
+ },
+ "value": "[resourceId('Microsoft.OperationsManagement/solutions', parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group where the solution is deployed."
+ },
+ "value": "[resourceGroup().name]"
+ },
+ "location": {
+ "type": "string",
+ "metadata": {
+ "description": "The location the resource was deployed into."
+ },
+ "value": "[reference('solution', '2015-11-01-preview', 'full').location]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "logAnalyticsWorkspace"
+ ]
+ }
+ },
+ "outputs": {
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the deployed log analytics workspace."
+ },
+ "value": "[resourceId('Microsoft.OperationalInsights/workspaces', parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group of the deployed log analytics workspace."
+ },
+ "value": "[resourceGroup().name]"
+ },
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the deployed log analytics workspace."
+ },
+ "value": "[parameters('name')]"
+ },
+ "logAnalyticsWorkspaceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The ID associated with the workspace."
+ },
+ "value": "[reference('logAnalyticsWorkspace').customerId]"
+ },
+ "location": {
+ "type": "string",
+ "metadata": {
+ "description": "The location the resource was deployed into."
+ },
+ "value": "[reference('logAnalyticsWorkspace', '2023-09-01', 'full').location]"
+ },
+ "systemAssignedMIPrincipalId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "The principal ID of the system assigned identity."
+ },
+ "value": "[tryGet(tryGet(reference('logAnalyticsWorkspace', '2023-09-01', 'full'), 'identity'), 'principalId')]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "[subscriptionResourceId('Microsoft.Resources/resourceGroups', if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName'))))]"
+ ]
+ },
+ {
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2025-04-01",
+ "name": "[format('{0}-appinsights', uniqueString(deployment().name, parameters('location')))]",
+ "resourceGroup": "[if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "name": "[if(not(empty(parameters('applicationInsightsName'))), createObject('value', parameters('applicationInsightsName')), createObject('value', format('{0}{1}', variables('abbrs').insightsComponents, variables('resourceToken'))))]",
+ "location": {
+ "value": "[parameters('location')]"
+ },
+ "tags": {
+ "value": "[variables('tags')]"
+ },
+ "workspaceResourceId": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('{0}-loganalytics', uniqueString(deployment().name, parameters('location')))), '2025-04-01').outputs.resourceId.value]"
+ },
+ "disableLocalAuth": {
+ "value": true
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "5735496719243704506"
+ },
+ "name": "Application Insights",
+ "description": "This component deploys an Application Insights instance."
+ },
+ "definitions": {
+ "diagnosticSettingFullType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of the diagnostic setting."
+ }
+ },
+ "logCategoriesAndGroups": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "category": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of a Diagnostic Log category for a resource type this setting is applied to. Set the specific logs to collect here."
+ }
+ },
+ "categoryGroup": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of a Diagnostic Log category group for a resource type this setting is applied to. Set to `allLogs` to collect all logs."
+ }
+ },
+ "enabled": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable or disable the category explicitly. Default is `true`."
+ }
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of logs that will be streamed. \"allLogs\" includes all possible logs for the resource. Set to `[]` to disable log collection."
+ }
+ },
+ "metricCategories": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "category": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of a Diagnostic Metric category for a resource type this setting is applied to. Set to `AllMetrics` to collect all metrics."
+ }
+ },
+ "enabled": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable or disable the category explicitly. Default is `true`."
+ }
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of metrics that will be streamed. \"allMetrics\" includes all possible metrics for the resource. Set to `[]` to disable metric collection."
+ }
+ },
+ "logAnalyticsDestinationType": {
+ "type": "string",
+ "allowedValues": [
+ "AzureDiagnostics",
+ "Dedicated"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type."
+ }
+ },
+ "workspaceResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic log analytics workspace. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "storageAccountResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic storage account. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "eventHubAuthorizationRuleResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to."
+ }
+ },
+ "eventHubName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of the diagnostic event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "marketplacePartnerResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The full ARM resource ID of the Marketplace resource to which you would like to send Diagnostic Logs."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a diagnostic setting. To be used if both logs & metrics are supported by the resource provider.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.3.0"
+ }
+ }
+ },
+ "lockType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the name of lock."
+ }
+ },
+ "kind": {
+ "type": "string",
+ "allowedValues": [
+ "CanNotDelete",
+ "None",
+ "ReadOnly"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the type of lock."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a lock.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ },
+ "roleAssignmentType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name (as GUID) of the role assignment. If not provided, a GUID will be generated."
+ }
+ },
+ "roleDefinitionIdOrName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The role to assign. You can provide either the display name of the role definition, the role definition GUID, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'."
+ }
+ },
+ "principalId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The principal ID of the principal (user/group/identity) to assign the role to."
+ }
+ },
+ "principalType": {
+ "type": "string",
+ "allowedValues": [
+ "Device",
+ "ForeignGroup",
+ "Group",
+ "ServicePrincipal",
+ "User"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The principal type of the assigned principal ID."
+ }
+ },
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The description of the role assignment."
+ }
+ },
+ "condition": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase \"foo_storage_container\"."
+ }
+ },
+ "conditionVersion": {
+ "type": "string",
+ "allowedValues": [
+ "2.0"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Version of the condition."
+ }
+ },
+ "delegatedManagedIdentityResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The Resource Id of the delegated managed identity resource."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a role assignment.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.3.0"
+ }
+ }
+ }
+ },
+ "parameters": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of the Application Insights."
+ }
+ },
+ "applicationType": {
+ "type": "string",
+ "defaultValue": "web",
+ "allowedValues": [
+ "web",
+ "other"
+ ],
+ "metadata": {
+ "description": "Optional. Application type."
+ }
+ },
+ "workspaceResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Resource ID of the log analytics workspace which the data will be ingested to. This property is required to create an application with this API version. Applications from older versions will not have this property."
+ }
+ },
+ "disableIpMasking": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. Disable IP masking. Default value is set to true."
+ }
+ },
+ "disableLocalAuth": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. Disable Non-AAD based Auth. Default value is set to false."
+ }
+ },
+ "forceCustomerStorageForProfiler": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. Force users to create their own storage account for profiler and debugger."
+ }
+ },
+ "linkedStorageAccountResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Linked storage account resource ID."
+ }
+ },
+ "publicNetworkAccessForIngestion": {
+ "type": "string",
+ "defaultValue": "Enabled",
+ "allowedValues": [
+ "Enabled",
+ "Disabled"
+ ],
+ "metadata": {
+ "description": "Optional. The network access type for accessing Application Insights ingestion. - Enabled or Disabled."
+ }
+ },
+ "publicNetworkAccessForQuery": {
+ "type": "string",
+ "defaultValue": "Enabled",
+ "allowedValues": [
+ "Enabled",
+ "Disabled"
+ ],
+ "metadata": {
+ "description": "Optional. The network access type for accessing Application Insights query. - Enabled or Disabled."
+ }
+ },
+ "retentionInDays": {
+ "type": "int",
+ "defaultValue": 365,
+ "allowedValues": [
+ 30,
+ 60,
+ 90,
+ 120,
+ 180,
+ 270,
+ 365,
+ 550,
+ 730
+ ],
+ "metadata": {
+ "description": "Optional. Retention period in days."
+ }
+ },
+ "samplingPercentage": {
+ "type": "int",
+ "defaultValue": 100,
+ "minValue": 0,
+ "maxValue": 100,
+ "metadata": {
+ "description": "Optional. Percentage of the data produced by the application being monitored that is being sampled for Application Insights telemetry."
+ }
+ },
+ "flowType": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Used by the Application Insights system to determine what kind of flow this component was created by. This is to be set to 'Bluefield' when creating/updating a component via the REST API."
+ }
+ },
+ "requestSource": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Describes what tool created this Application Insights component. Customers using this API should set this to the default 'rest'."
+ }
+ },
+ "kind": {
+ "type": "string",
+ "defaultValue": "",
+ "metadata": {
+ "description": "Optional. The kind of application that this component refers to, used to customize UI. This value is a freeform string, values should typically be one of the following: web, ios, other, store, java, phone."
+ }
+ },
+ "location": {
+ "type": "string",
+ "defaultValue": "[resourceGroup().location]",
+ "metadata": {
+ "description": "Optional. Location for all Resources."
+ }
+ },
+ "lock": {
+ "$ref": "#/definitions/lockType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The lock settings of the service."
+ }
+ },
+ "roleAssignments": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/roleAssignmentType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Array of role assignments to create."
+ }
+ },
+ "tags": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Tags of the resource."
+ }
+ },
+ "enableTelemetry": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. Enable/Disable usage telemetry for module."
+ }
+ },
+ "diagnosticSettings": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/diagnosticSettingFullType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The diagnostic settings of the service."
+ }
+ }
+ },
+ "variables": {
+ "copy": [
+ {
+ "name": "formattedRoleAssignments",
+ "count": "[length(coalesce(parameters('roleAssignments'), createArray()))]",
+ "input": "[union(coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')], createObject('roleDefinitionId', coalesce(tryGet(variables('builtInRoleNames'), coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName), if(contains(coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/'), coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName)))))]"
+ }
+ ],
+ "builtInRoleNames": {
+ "Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
+ "Owner": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]",
+ "Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'acdd72a7-3385-48ef-bd42-f606fba81ae7')]",
+ "Role Based Access Control Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'f58310d9-a9f6-439a-9e8d-f62e7b41a168')]",
+ "User Access Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '18d7d88d-d35e-4fb5-a5c3-7773c20a72d9')]",
+ "Monitoring Metrics Publisher": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '3913510d-42f4-4e42-8a64-420c390055eb')]",
+ "Application Insights Component Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'ae349356-3a1b-4a5e-921d-050484c6347e')]",
+ "Application Insights Snapshot Debugger": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '08954f03-6346-4c2e-81c0-ec3a5cfae23b')]",
+ "Monitoring Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '749f88d5-cbae-40b8-bcfc-e573ddc772fa')]"
+ }
+ },
+ "resources": {
+ "avmTelemetry": {
+ "condition": "[parameters('enableTelemetry')]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2024-03-01",
+ "name": "[format('46d3xbcp.res.insights-component.{0}.{1}', replace('0.6.0', '.', '-'), substring(uniqueString(deployment().name, parameters('location')), 0, 4))]",
+ "properties": {
+ "mode": "Incremental",
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "resources": [],
+ "outputs": {
+ "telemetry": {
+ "type": "String",
+ "value": "For more information, see https://aka.ms/avm/TelemetryInfo"
+ }
+ }
+ }
+ }
+ },
+ "appInsights": {
+ "type": "Microsoft.Insights/components",
+ "apiVersion": "2020-02-02",
+ "name": "[parameters('name')]",
+ "location": "[parameters('location')]",
+ "tags": "[parameters('tags')]",
+ "kind": "[parameters('kind')]",
+ "properties": {
+ "Application_Type": "[parameters('applicationType')]",
+ "DisableIpMasking": "[parameters('disableIpMasking')]",
+ "DisableLocalAuth": "[parameters('disableLocalAuth')]",
+ "ForceCustomerStorageForProfiler": "[parameters('forceCustomerStorageForProfiler')]",
+ "WorkspaceResourceId": "[parameters('workspaceResourceId')]",
+ "publicNetworkAccessForIngestion": "[parameters('publicNetworkAccessForIngestion')]",
+ "publicNetworkAccessForQuery": "[parameters('publicNetworkAccessForQuery')]",
+ "RetentionInDays": "[parameters('retentionInDays')]",
+ "SamplingPercentage": "[parameters('samplingPercentage')]",
+ "Flow_Type": "[parameters('flowType')]",
+ "Request_Source": "[parameters('requestSource')]"
+ }
+ },
+ "appInsights_roleAssignments": {
+ "copy": {
+ "name": "appInsights_roleAssignments",
+ "count": "[length(coalesce(variables('formattedRoleAssignments'), createArray()))]"
+ },
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Insights/components/{0}', parameters('name'))]",
+ "name": "[coalesce(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'name'), guid(resourceId('Microsoft.Insights/components', parameters('name')), coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].principalId, coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].roleDefinitionId))]",
+ "properties": {
+ "roleDefinitionId": "[coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].roleDefinitionId]",
+ "principalId": "[coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].principalId]",
+ "description": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'description')]",
+ "principalType": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'principalType')]",
+ "condition": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'condition')]",
+ "conditionVersion": "[if(not(empty(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'condition'))), coalesce(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'conditionVersion'), '2.0'), null())]",
+ "delegatedManagedIdentityResourceId": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'delegatedManagedIdentityResourceId')]"
+ },
+ "dependsOn": [
+ "appInsights"
+ ]
+ },
+ "appInsights_lock": {
+ "condition": "[and(not(empty(coalesce(parameters('lock'), createObject()))), not(equals(tryGet(parameters('lock'), 'kind'), 'None')))]",
+ "type": "Microsoft.Authorization/locks",
+ "apiVersion": "2020-05-01",
+ "scope": "[format('Microsoft.Insights/components/{0}', parameters('name'))]",
+ "name": "[coalesce(tryGet(parameters('lock'), 'name'), format('lock-{0}', parameters('name')))]",
+ "properties": {
+ "level": "[coalesce(tryGet(parameters('lock'), 'kind'), '')]",
+ "notes": "[if(equals(tryGet(parameters('lock'), 'kind'), 'CanNotDelete'), 'Cannot delete resource or child resources.', 'Cannot delete or modify the resource or child resources.')]"
+ },
+ "dependsOn": [
+ "appInsights"
+ ]
+ },
+ "appInsights_diagnosticSettings": {
+ "copy": {
+ "name": "appInsights_diagnosticSettings",
+ "count": "[length(coalesce(parameters('diagnosticSettings'), createArray()))]"
+ },
+ "type": "Microsoft.Insights/diagnosticSettings",
+ "apiVersion": "2021-05-01-preview",
+ "scope": "[format('Microsoft.Insights/components/{0}', parameters('name'))]",
+ "name": "[coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'name'), format('{0}-diagnosticSettings', parameters('name')))]",
+ "properties": {
+ "copy": [
+ {
+ "name": "metrics",
+ "count": "[length(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics'))))]",
+ "input": {
+ "category": "[coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics')))[copyIndex('metrics')].category]",
+ "enabled": "[coalesce(tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics')))[copyIndex('metrics')], 'enabled'), true())]",
+ "timeGrain": null
+ }
+ },
+ {
+ "name": "logs",
+ "count": "[length(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs'))))]",
+ "input": {
+ "categoryGroup": "[tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'categoryGroup')]",
+ "category": "[tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'category')]",
+ "enabled": "[coalesce(tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'enabled'), true())]"
+ }
+ }
+ ],
+ "storageAccountId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'storageAccountResourceId')]",
+ "workspaceId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'workspaceResourceId')]",
+ "eventHubAuthorizationRuleId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'eventHubAuthorizationRuleResourceId')]",
+ "eventHubName": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'eventHubName')]",
+ "marketplacePartnerId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'marketplacePartnerResourceId')]",
+ "logAnalyticsDestinationType": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logAnalyticsDestinationType')]"
+ },
+ "dependsOn": [
+ "appInsights"
+ ]
+ },
+ "linkedStorageAccount": {
+ "condition": "[not(empty(parameters('linkedStorageAccountResourceId')))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-appInsights-linkedStorageAccount', uniqueString(deployment().name, parameters('location')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "appInsightsName": {
+ "value": "[parameters('name')]"
+ },
+ "storageAccountResourceId": {
+ "value": "[coalesce(parameters('linkedStorageAccountResourceId'), '')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "10861379689695100897"
+ },
+ "name": "Application Insights Linked Storage Account",
+ "description": "This component deploys an Application Insights Linked Storage Account."
+ },
+ "parameters": {
+ "appInsightsName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent Application Insights instance. Required if the template is used in a standalone deployment."
+ }
+ },
+ "storageAccountResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Linked storage account resource ID."
+ }
+ }
+ },
+ "resources": [
+ {
+ "type": "microsoft.insights/components/linkedStorageAccounts",
+ "apiVersion": "2020-03-01-preview",
+ "name": "[format('{0}/{1}', parameters('appInsightsName'), 'ServiceProfiler')]",
+ "properties": {
+ "linkedStorageAccount": "[parameters('storageAccountResourceId')]"
+ }
+ }
+ ],
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the Linked Storage Account."
+ },
+ "value": "ServiceProfiler"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the Linked Storage Account."
+ },
+ "value": "[resourceId('microsoft.insights/components/linkedStorageAccounts', parameters('appInsightsName'), 'ServiceProfiler')]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group the agent pool was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "appInsights"
+ ]
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the application insights component."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the application insights component."
+ },
+ "value": "[resourceId('Microsoft.Insights/components', parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group the application insights component was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ },
+ "applicationId": {
+ "type": "string",
+ "metadata": {
+ "description": "The application ID of the application insights component."
+ },
+ "value": "[reference('appInsights').AppId]"
+ },
+ "location": {
+ "type": "string",
+ "metadata": {
+ "description": "The location the resource was deployed into."
+ },
+ "value": "[reference('appInsights', '2020-02-02', 'full').location]"
+ },
+ "instrumentationKey": {
+ "type": "string",
+ "metadata": {
+ "description": "Application Insights Instrumentation key. A read-only value that applications can use to identify the destination for all telemetry sent to Azure Application Insights. This value will be supplied upon construction of each new Application Insights component."
+ },
+ "value": "[reference('appInsights').InstrumentationKey]"
+ },
+ "connectionString": {
+ "type": "string",
+ "metadata": {
+ "description": "Application Insights Connection String."
+ },
+ "value": "[reference('appInsights').ConnectionString]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('{0}-loganalytics', uniqueString(deployment().name, parameters('location'))))]",
+ "[subscriptionResourceId('Microsoft.Resources/resourceGroups', if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName'))))]"
+ ]
+ },
+ {
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2025-04-01",
+ "name": "storage",
+ "resourceGroup": "[if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "name": "[if(not(empty(parameters('storageAccountName'))), createObject('value', parameters('storageAccountName')), createObject('value', format('{0}{1}', variables('abbrs').storageStorageAccounts, variables('resourceToken'))))]",
+ "allowBlobPublicAccess": {
+ "value": false
+ },
+ "allowSharedKeyAccess": {
+ "value": false
+ },
+ "dnsEndpointType": {
+ "value": "Standard"
+ },
+ "publicNetworkAccess": "[if(parameters('vnetEnabled'), createObject('value', 'Disabled'), createObject('value', 'Enabled'))]",
+ "networkAcls": "[if(parameters('vnetEnabled'), createObject('value', createObject('defaultAction', 'Deny', 'bypass', 'AzureServices')), createObject('value', createObject('defaultAction', 'Allow', 'bypass', 'AzureServices')))]",
+ "blobServices": {
+ "value": {
+ "containers": [
+ {
+ "name": "[variables('deploymentStorageContainerName')]"
+ }
+ ]
+ }
+ },
+ "queueServices": {
+ "value": {
+ "queues": [
+ {
+ "name": "input"
+ },
+ {
+ "name": "output"
+ }
+ ]
+ }
+ },
+ "minimumTlsVersion": {
+ "value": "TLS1_2"
+ },
+ "location": {
+ "value": "[parameters('location')]"
+ },
+ "tags": {
+ "value": "[variables('tags')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.26.170.59819",
+ "templateHash": "16887137065839172279"
+ },
+ "name": "Storage Accounts",
+ "description": "This module deploys a Storage Account.",
+ "owner": "Azure/module-maintainers"
+ },
+ "definitions": {
+ "managedIdentitiesType": {
+ "type": "object",
+ "properties": {
+ "systemAssigned": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enables system assigned managed identity on the resource."
+ }
+ },
+ "userAssignedResourceIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The resource ID(s) to assign to the resource."
+ }
+ }
+ },
+ "nullable": true
+ },
+ "lockType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the name of lock."
+ }
+ },
+ "kind": {
+ "type": "string",
+ "allowedValues": [
+ "CanNotDelete",
+ "None",
+ "ReadOnly"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the type of lock."
+ }
+ }
+ },
+ "nullable": true
+ },
+ "roleAssignmentType": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "roleDefinitionIdOrName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The role to assign. You can provide either the display name of the role definition, the role definition GUID, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'."
+ }
+ },
+ "principalId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The principal ID of the principal (user/group/identity) to assign the role to."
+ }
+ },
+ "principalType": {
+ "type": "string",
+ "allowedValues": [
+ "Device",
+ "ForeignGroup",
+ "Group",
+ "ServicePrincipal",
+ "User"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The principal type of the assigned principal ID."
+ }
+ },
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The description of the role assignment."
+ }
+ },
+ "condition": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase \"foo_storage_container\"."
+ }
+ },
+ "conditionVersion": {
+ "type": "string",
+ "allowedValues": [
+ "2.0"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Version of the condition."
+ }
+ },
+ "delegatedManagedIdentityResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The Resource Id of the delegated managed identity resource."
+ }
+ }
+ }
+ },
+ "nullable": true
+ },
+ "networkAclsType": {
+ "type": "object",
+ "properties": {
+ "resourceAccessRules": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "tenantId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The ID of the tenant in which the resource resides in."
+ }
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The resource ID of the target service. Can also contain a wildcard, if multiple services e.g. in a resource group should be included."
+ }
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Sets the resource access rules. Array entries must consist of \"tenantId\" and \"resourceId\" fields only."
+ }
+ },
+ "bypass": {
+ "type": "string",
+ "allowedValues": [
+ "AzureServices",
+ "AzureServices, Logging",
+ "AzureServices, Logging, Metrics",
+ "AzureServices, Metrics",
+ "Logging",
+ "Logging, Metrics",
+ "Metrics",
+ "None"
+ ],
+ "metadata": {
+ "description": "Required. Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging,Metrics,AzureServices (For example, \"Logging, Metrics\"), or None to bypass none of those traffics."
+ }
+ },
+ "virtualNetworkRules": {
+ "type": "array",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Sets the virtual network rules."
+ }
+ },
+ "ipRules": {
+ "type": "array",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Sets the IP ACL rules."
+ }
+ },
+ "defaultAction": {
+ "type": "string",
+ "allowedValues": [
+ "Allow",
+ "Deny"
+ ],
+ "metadata": {
+ "description": "Required. Specifies the default action of allow or deny when no other rules match."
+ }
+ }
+ }
+ },
+ "privateEndpointType": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of the private endpoint."
+ }
+ },
+ "location": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The location to deploy the private endpoint to."
+ }
+ },
+ "service": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The service (sub-) type to deploy the private endpoint for. For example \"vault\" or \"blob\"."
+ }
+ },
+ "subnetResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Resource ID of the subnet where the endpoint needs to be created."
+ }
+ },
+ "privateDnsZoneGroupName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of the private DNS zone group to create if privateDnsZoneResourceIds were provided."
+ }
+ },
+ "privateDnsZoneResourceIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The private DNS zone groups to associate the private endpoint with. A DNS zone group can support up to 5 DNS zones."
+ }
+ },
+ "isManualConnection": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Manual PrivateLink Service Connections."
+ }
+ },
+ "manualConnectionRequestMessage": {
+ "type": "string",
+ "nullable": true,
+ "maxLength": 140,
+ "metadata": {
+ "description": "Optional. A message passed to the owner of the remote resource with the manual connection request."
+ }
+ },
+ "customDnsConfigs": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "fqdn": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Required. Fqdn that resolves to private endpoint ip address."
+ }
+ },
+ "ipAddresses": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "metadata": {
+ "description": "Required. A list of private ip addresses of the private endpoint."
+ }
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Custom DNS configurations."
+ }
+ },
+ "ipConfigurations": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the resource that is unique within a resource group."
+ }
+ },
+ "properties": {
+ "type": "object",
+ "properties": {
+ "groupId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The ID of a group obtained from the remote resource that this private endpoint should connect to."
+ }
+ },
+ "memberName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The member name of a group obtained from the remote resource that this private endpoint should connect to."
+ }
+ },
+ "privateIPAddress": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. A private ip address obtained from the private endpoint's subnet."
+ }
+ }
+ },
+ "metadata": {
+ "description": "Required. Properties of private endpoint IP configurations."
+ }
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. A list of IP configurations of the private endpoint. This will be used to map to the First Party Service endpoints."
+ }
+ },
+ "applicationSecurityGroupResourceIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Application security groups in which the private endpoint IP configuration is included."
+ }
+ },
+ "customNetworkInterfaceName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The custom name of the network interface attached to the private endpoint."
+ }
+ },
+ "lock": {
+ "$ref": "#/definitions/lockType",
+ "metadata": {
+ "description": "Optional. Specify the type of lock."
+ }
+ },
+ "roleAssignments": {
+ "$ref": "#/definitions/roleAssignmentType",
+ "metadata": {
+ "description": "Optional. Array of role assignments to create."
+ }
+ },
+ "tags": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Tags to be applied on all resources/resource groups in this deployment."
+ }
+ },
+ "enableTelemetry": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable/Disable usage telemetry for module."
+ }
+ }
+ }
+ },
+ "nullable": true
+ },
+ "diagnosticSettingType": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of diagnostic setting."
+ }
+ },
+ "metricCategories": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "category": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of a Diagnostic Metric category for a resource type this setting is applied to. Set to `AllMetrics` to collect all metrics."
+ }
+ },
+ "enabled": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable or disable the category explicitly. Default is `true`."
+ }
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of logs that will be streamed. \"allLogs\" includes all possible logs for the resource. Set to `[]` to disable log collection."
+ }
+ },
+ "logAnalyticsDestinationType": {
+ "type": "string",
+ "allowedValues": [
+ "AzureDiagnostics",
+ "Dedicated"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type."
+ }
+ },
+ "workspaceResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic log analytics workspace. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "storageAccountResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic storage account. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "eventHubAuthorizationRuleResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to."
+ }
+ },
+ "eventHubName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of the diagnostic event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "marketplacePartnerResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The full ARM resource ID of the Marketplace resource to which you would like to send Diagnostic Logs."
+ }
+ }
+ }
+ },
+ "nullable": true
+ },
+ "customerManagedKeyType": {
+ "type": "object",
+ "properties": {
+ "keyVaultResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The resource ID of a key vault to reference a customer managed key for encryption from."
+ }
+ },
+ "keyName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the customer managed key to use for encryption."
+ }
+ },
+ "keyVersion": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The version of the customer managed key to reference for encryption. If not provided, using 'latest'."
+ }
+ },
+ "userAssignedIdentityResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. User assigned identity to use when fetching the customer managed key. If used must also be specified in `managedIdentities.userAssignedResourceIds`. Required if no system assigned identity is available for use."
+ }
+ }
+ },
+ "nullable": true
+ }
+ },
+ "parameters": {
+ "name": {
+ "type": "string",
+ "maxLength": 24,
+ "metadata": {
+ "description": "Required. Name of the Storage Account. Must be lower-case."
+ }
+ },
+ "location": {
+ "type": "string",
+ "defaultValue": "[resourceGroup().location]",
+ "metadata": {
+ "description": "Optional. Location for all resources."
+ }
+ },
+ "roleAssignments": {
+ "$ref": "#/definitions/roleAssignmentType",
+ "metadata": {
+ "description": "Optional. Array of role assignments to create."
+ }
+ },
+ "managedIdentities": {
+ "$ref": "#/definitions/managedIdentitiesType",
+ "metadata": {
+ "description": "Optional. The managed identity definition for this resource."
+ }
+ },
+ "kind": {
+ "type": "string",
+ "defaultValue": "StorageV2",
+ "allowedValues": [
+ "Storage",
+ "StorageV2",
+ "BlobStorage",
+ "FileStorage",
+ "BlockBlobStorage"
+ ],
+ "metadata": {
+ "description": "Optional. Type of Storage Account to create."
+ }
+ },
+ "skuName": {
+ "type": "string",
+ "defaultValue": "Standard_GRS",
+ "allowedValues": [
+ "Standard_LRS",
+ "Standard_GRS",
+ "Standard_RAGRS",
+ "Standard_ZRS",
+ "Premium_LRS",
+ "Premium_ZRS",
+ "Standard_GZRS",
+ "Standard_RAGZRS"
+ ],
+ "metadata": {
+ "description": "Optional. Storage Account Sku Name."
+ }
+ },
+ "accessTier": {
+ "type": "string",
+ "defaultValue": "Hot",
+ "allowedValues": [
+ "Premium",
+ "Hot",
+ "Cool"
+ ],
+ "metadata": {
+ "description": "Conditional. Required if the Storage Account kind is set to BlobStorage. The access tier is used for billing. The \"Premium\" access tier is the default value for premium block blobs storage account type and it cannot be changed for the premium block blobs storage account type."
+ }
+ },
+ "largeFileSharesState": {
+ "type": "string",
+ "defaultValue": "Disabled",
+ "allowedValues": [
+ "Disabled",
+ "Enabled"
+ ],
+ "metadata": {
+ "description": "Optional. Allow large file shares if sets to 'Enabled'. It cannot be disabled once it is enabled. Only supported on locally redundant and zone redundant file shares. It cannot be set on FileStorage storage accounts (storage accounts for premium file shares)."
+ }
+ },
+ "azureFilesIdentityBasedAuthentication": {
+ "type": "object",
+ "defaultValue": {},
+ "metadata": {
+ "description": "Optional. Provides the identity based authentication settings for Azure Files."
+ }
+ },
+ "defaultToOAuthAuthentication": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. A boolean flag which indicates whether the default authentication is OAuth or not."
+ }
+ },
+ "allowSharedKeyAccess": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including shared access signatures, must be authorized with Azure Active Directory (Azure AD). The default value is null, which is equivalent to true."
+ }
+ },
+ "privateEndpoints": {
+ "$ref": "#/definitions/privateEndpointType",
+ "metadata": {
+ "description": "Optional. Configuration details for private endpoints. For security reasons, it is recommended to use private endpoints whenever possible."
+ }
+ },
+ "managementPolicyRules": {
+ "type": "array",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The Storage Account ManagementPolicies Rules."
+ }
+ },
+ "networkAcls": {
+ "$ref": "#/definitions/networkAclsType",
+ "defaultValue": {
+ "bypass": "AzureServices",
+ "defaultAction": "Deny"
+ },
+ "metadata": {
+ "description": "Required. Networks ACLs, this value contains IPs to whitelist and/or Subnet information. If in use, bypass needs to be supplied. For security reasons, it is recommended to set the DefaultAction Deny."
+ }
+ },
+ "requireInfrastructureEncryption": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. A Boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest. For security reasons, it is recommended to set it to true."
+ }
+ },
+ "allowCrossTenantReplication": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. Allow or disallow cross AAD tenant object replication."
+ }
+ },
+ "customDomainName": {
+ "type": "string",
+ "defaultValue": "",
+ "metadata": {
+ "description": "Optional. Sets the custom domain name assigned to the storage account. Name is the CNAME source."
+ }
+ },
+ "customDomainUseSubDomainName": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. Indicates whether indirect CName validation is enabled. This should only be set on updates."
+ }
+ },
+ "dnsEndpointType": {
+ "type": "string",
+ "defaultValue": "",
+ "allowedValues": [
+ "",
+ "AzureDnsZone",
+ "Standard"
+ ],
+ "metadata": {
+ "description": "Optional. Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier."
+ }
+ },
+ "blobServices": {
+ "type": "object",
+ "defaultValue": "[if(not(equals(parameters('kind'), 'FileStorage')), createObject('containerDeleteRetentionPolicyEnabled', true(), 'containerDeleteRetentionPolicyDays', 7, 'deleteRetentionPolicyEnabled', true(), 'deleteRetentionPolicyDays', 6), createObject())]",
+ "metadata": {
+ "description": "Optional. Blob service and containers to deploy."
+ }
+ },
+ "fileServices": {
+ "type": "object",
+ "defaultValue": {},
+ "metadata": {
+ "description": "Optional. File service and shares to deploy."
+ }
+ },
+ "queueServices": {
+ "type": "object",
+ "defaultValue": {},
+ "metadata": {
+ "description": "Optional. Queue service and queues to create."
+ }
+ },
+ "tableServices": {
+ "type": "object",
+ "defaultValue": {},
+ "metadata": {
+ "description": "Optional. Table service and tables to create."
+ }
+ },
+ "allowBlobPublicAccess": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. Indicates whether public access is enabled for all blobs or containers in the storage account. For security reasons, it is recommended to set it to false."
+ }
+ },
+ "minimumTlsVersion": {
+ "type": "string",
+ "defaultValue": "TLS1_2",
+ "allowedValues": [
+ "TLS1_0",
+ "TLS1_1",
+ "TLS1_2"
+ ],
+ "metadata": {
+ "description": "Optional. Set the minimum TLS version on request to storage."
+ }
+ },
+ "enableHierarchicalNamespace": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Conditional. If true, enables Hierarchical Namespace for the storage account. Required if enableSftp or enableNfsV3 is set to true."
+ }
+ },
+ "enableSftp": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. If true, enables Secure File Transfer Protocol for the storage account. Requires enableHierarchicalNamespace to be true."
+ }
+ },
+ "localUsers": {
+ "type": "array",
+ "defaultValue": [],
+ "metadata": {
+ "description": "Optional. Local users to deploy for SFTP authentication."
+ }
+ },
+ "isLocalUserEnabled": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. Enables local users feature, if set to true."
+ }
+ },
+ "enableNfsV3": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. If true, enables NFS 3.0 support for the storage account. Requires enableHierarchicalNamespace to be true."
+ }
+ },
+ "diagnosticSettings": {
+ "$ref": "#/definitions/diagnosticSettingType",
+ "metadata": {
+ "description": "Optional. The diagnostic settings of the service."
+ }
+ },
+ "lock": {
+ "$ref": "#/definitions/lockType",
+ "metadata": {
+ "description": "Optional. The lock settings of the service."
+ }
+ },
+ "tags": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Tags of the resource."
+ }
+ },
+ "enableTelemetry": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. Enable/Disable usage telemetry for module."
+ }
+ },
+ "allowedCopyScope": {
+ "type": "string",
+ "defaultValue": "",
+ "allowedValues": [
+ "",
+ "AAD",
+ "PrivateLink"
+ ],
+ "metadata": {
+ "description": "Optional. Restrict copy to and from Storage Accounts within an AAD tenant or with Private Links to the same VNet."
+ }
+ },
+ "publicNetworkAccess": {
+ "type": "string",
+ "defaultValue": "",
+ "allowedValues": [
+ "",
+ "Enabled",
+ "Disabled"
+ ],
+ "metadata": {
+ "description": "Optional. Whether or not public network access is allowed for this resource. For security reasons it should be disabled. If not specified, it will be disabled by default if private endpoints are set and networkAcls are not set."
+ }
+ },
+ "supportsHttpsTrafficOnly": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. Allows HTTPS traffic only to storage service if sets to true."
+ }
+ },
+ "customerManagedKey": {
+ "$ref": "#/definitions/customerManagedKeyType",
+ "metadata": {
+ "description": "Optional. The customer managed key definition."
+ }
+ },
+ "sasExpirationPeriod": {
+ "type": "string",
+ "defaultValue": "",
+ "metadata": {
+ "description": "Optional. The SAS expiration period. DD.HH:MM:SS."
+ }
+ }
+ },
+ "variables": {
+ "supportsBlobService": "[or(or(or(equals(parameters('kind'), 'BlockBlobStorage'), equals(parameters('kind'), 'BlobStorage')), equals(parameters('kind'), 'StorageV2')), equals(parameters('kind'), 'Storage'))]",
+ "supportsFileService": "[or(or(equals(parameters('kind'), 'FileStorage'), equals(parameters('kind'), 'StorageV2')), equals(parameters('kind'), 'Storage'))]",
+ "formattedUserAssignedIdentities": "[reduce(map(coalesce(tryGet(parameters('managedIdentities'), 'userAssignedResourceIds'), createArray()), lambda('id', createObject(format('{0}', lambdaVariables('id')), createObject()))), createObject(), lambda('cur', 'next', union(lambdaVariables('cur'), lambdaVariables('next'))))]",
+ "identity": "[if(not(empty(parameters('managedIdentities'))), createObject('type', if(coalesce(tryGet(parameters('managedIdentities'), 'systemAssigned'), false()), if(not(empty(coalesce(tryGet(parameters('managedIdentities'), 'userAssignedResourceIds'), createObject()))), 'SystemAssigned,UserAssigned', 'SystemAssigned'), if(not(empty(coalesce(tryGet(parameters('managedIdentities'), 'userAssignedResourceIds'), createObject()))), 'UserAssigned', 'None')), 'userAssignedIdentities', if(not(empty(variables('formattedUserAssignedIdentities'))), variables('formattedUserAssignedIdentities'), null())), null())]",
+ "builtInRoleNames": {
+ "Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
+ "Owner": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]",
+ "Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'acdd72a7-3385-48ef-bd42-f606fba81ae7')]",
+ "Reader and Data Access": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'c12c1c16-33a1-487b-954d-41c89c60f349')]",
+ "Role Based Access Control Administrator (Preview)": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'f58310d9-a9f6-439a-9e8d-f62e7b41a168')]",
+ "Storage Account Backup Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'e5e2a7ff-d759-4cd2-bb51-3152d37e2eb1')]",
+ "Storage Account Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '17d1049b-9a84-46fb-8f53-869881c3d3ab')]",
+ "Storage Account Key Operator Service Role": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '81a9662b-bebf-436f-a333-f67b29880f12')]",
+ "Storage Blob Data Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'ba92f5b4-2d11-453d-a403-e96b0029c9fe')]",
+ "Storage Blob Data Owner": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b7e6dc6d-f1e8-4753-8033-0f276bb0955b')]",
+ "Storage Blob Data Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '2a2b9908-6ea1-4ae2-8e65-a410df84e7d1')]",
+ "Storage Blob Delegator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'db58b8e5-c6ad-4a2a-8342-4190687cbf4a')]",
+ "Storage File Data SMB Share Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '0c867c2a-1d8c-454a-a3db-ab2ea1bdc8bb')]",
+ "Storage File Data SMB Share Elevated Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'a7264617-510b-434b-a828-9731dc254ea7')]",
+ "Storage File Data SMB Share Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'aba4ae5f-2193-4029-9191-0cb91df5e314')]",
+ "Storage Queue Data Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '974c5e8b-45b9-4653-ba55-5f855dd0fb88')]",
+ "Storage Queue Data Message Processor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '8a0f0c08-91a1-4084-bc3d-661d67233fed')]",
+ "Storage Queue Data Message Sender": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'c6a89b2d-59bc-44d0-9896-0f6e12d7b80a')]",
+ "Storage Queue Data Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '19e7f393-937e-4f77-808e-94535e297925')]",
+ "Storage Table Data Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '0a9a7e1f-b9d0-4cc4-a60d-0319b160aaa3')]",
+ "Storage Table Data Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '76199698-9eea-4c19-bc75-cec21354c6b6')]",
+ "User Access Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '18d7d88d-d35e-4fb5-a5c3-7773c20a72d9')]"
+ }
+ },
+ "resources": {
+ "cMKKeyVault::cMKKey": {
+ "condition": "[and(not(empty(tryGet(parameters('customerManagedKey'), 'keyVaultResourceId'))), and(not(empty(tryGet(parameters('customerManagedKey'), 'keyVaultResourceId'))), not(empty(tryGet(parameters('customerManagedKey'), 'keyName')))))]",
+ "existing": true,
+ "type": "Microsoft.KeyVault/vaults/keys",
+ "apiVersion": "2023-02-01",
+ "subscriptionId": "[split(coalesce(tryGet(parameters('customerManagedKey'), 'keyVaultResourceId'), '//'), '/')[2]]",
+ "resourceGroup": "[split(coalesce(tryGet(parameters('customerManagedKey'), 'keyVaultResourceId'), '////'), '/')[4]]",
+ "name": "[format('{0}/{1}', last(split(coalesce(tryGet(parameters('customerManagedKey'), 'keyVaultResourceId'), 'dummyVault'), '/')), coalesce(tryGet(parameters('customerManagedKey'), 'keyName'), 'dummyKey'))]",
+ "dependsOn": [
+ "cMKKeyVault"
+ ]
+ },
+ "avmTelemetry": {
+ "condition": "[parameters('enableTelemetry')]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2023-07-01",
+ "name": "[format('46d3xbcp.res.storage-storageaccount.{0}.{1}', replace('0.8.3', '.', '-'), substring(uniqueString(deployment().name, parameters('location')), 0, 4))]",
+ "properties": {
+ "mode": "Incremental",
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "resources": [],
+ "outputs": {
+ "telemetry": {
+ "type": "String",
+ "value": "For more information, see https://aka.ms/avm/TelemetryInfo"
+ }
+ }
+ }
+ }
+ },
+ "cMKKeyVault": {
+ "condition": "[not(empty(tryGet(parameters('customerManagedKey'), 'keyVaultResourceId')))]",
+ "existing": true,
+ "type": "Microsoft.KeyVault/vaults",
+ "apiVersion": "2023-02-01",
+ "subscriptionId": "[split(coalesce(tryGet(parameters('customerManagedKey'), 'keyVaultResourceId'), '//'), '/')[2]]",
+ "resourceGroup": "[split(coalesce(tryGet(parameters('customerManagedKey'), 'keyVaultResourceId'), '////'), '/')[4]]",
+ "name": "[last(split(coalesce(tryGet(parameters('customerManagedKey'), 'keyVaultResourceId'), 'dummyVault'), '/'))]"
+ },
+ "cMKUserAssignedIdentity": {
+ "condition": "[not(empty(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId')))]",
+ "existing": true,
+ "type": "Microsoft.ManagedIdentity/userAssignedIdentities",
+ "apiVersion": "2023-01-31",
+ "subscriptionId": "[split(coalesce(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'), '//'), '/')[2]]",
+ "resourceGroup": "[split(coalesce(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'), '////'), '/')[4]]",
+ "name": "[last(split(coalesce(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'), 'dummyMsi'), '/'))]"
+ },
+ "storageAccount": {
+ "type": "Microsoft.Storage/storageAccounts",
+ "apiVersion": "2022-09-01",
+ "name": "[parameters('name')]",
+ "location": "[parameters('location')]",
+ "kind": "[parameters('kind')]",
+ "sku": {
+ "name": "[parameters('skuName')]"
+ },
+ "identity": "[variables('identity')]",
+ "tags": "[parameters('tags')]",
+ "properties": {
+ "allowSharedKeyAccess": "[parameters('allowSharedKeyAccess')]",
+ "defaultToOAuthAuthentication": "[parameters('defaultToOAuthAuthentication')]",
+ "allowCrossTenantReplication": "[parameters('allowCrossTenantReplication')]",
+ "allowedCopyScope": "[if(not(empty(parameters('allowedCopyScope'))), parameters('allowedCopyScope'), null())]",
+ "customDomain": {
+ "name": "[parameters('customDomainName')]",
+ "useSubDomainName": "[parameters('customDomainUseSubDomainName')]"
+ },
+ "dnsEndpointType": "[if(not(empty(parameters('dnsEndpointType'))), parameters('dnsEndpointType'), null())]",
+ "isLocalUserEnabled": "[parameters('isLocalUserEnabled')]",
+ "encryption": "[union(createObject('keySource', if(not(empty(parameters('customerManagedKey'))), 'Microsoft.Keyvault', 'Microsoft.Storage'), 'services', createObject('blob', if(variables('supportsBlobService'), createObject('enabled', true()), null()), 'file', if(variables('supportsFileService'), createObject('enabled', true()), null()), 'table', createObject('enabled', true()), 'queue', createObject('enabled', true())), 'keyvaultproperties', if(not(empty(parameters('customerManagedKey'))), createObject('keyname', parameters('customerManagedKey').keyName, 'keyvaulturi', reference('cMKKeyVault').vaultUri, 'keyversion', if(not(empty(coalesce(tryGet(parameters('customerManagedKey'), 'keyVersion'), ''))), parameters('customerManagedKey').keyVersion, last(split(reference('cMKKeyVault::cMKKey').keyUriWithVersion, '/')))), null()), 'identity', createObject('userAssignedIdentity', if(not(empty(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'))), extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(coalesce(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'), '//'), '/')[2], split(coalesce(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'), '////'), '/')[4]), 'Microsoft.ManagedIdentity/userAssignedIdentities', last(split(coalesce(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'), 'dummyMsi'), '/'))), null()))), if(parameters('requireInfrastructureEncryption'), createObject('requireInfrastructureEncryption', if(not(equals(parameters('kind'), 'Storage')), parameters('requireInfrastructureEncryption'), null())), createObject()))]",
+ "accessTier": "[if(and(not(equals(parameters('kind'), 'Storage')), not(equals(parameters('kind'), 'BlockBlobStorage'))), parameters('accessTier'), null())]",
+ "sasPolicy": "[if(not(empty(parameters('sasExpirationPeriod'))), createObject('expirationAction', 'Log', 'sasExpirationPeriod', parameters('sasExpirationPeriod')), null())]",
+ "supportsHttpsTrafficOnly": "[parameters('supportsHttpsTrafficOnly')]",
+ "isHnsEnabled": "[if(parameters('enableHierarchicalNamespace'), parameters('enableHierarchicalNamespace'), null())]",
+ "isSftpEnabled": "[parameters('enableSftp')]",
+ "isNfsV3Enabled": "[if(parameters('enableNfsV3'), parameters('enableNfsV3'), '')]",
+ "largeFileSharesState": "[if(or(equals(parameters('skuName'), 'Standard_LRS'), equals(parameters('skuName'), 'Standard_ZRS')), parameters('largeFileSharesState'), null())]",
+ "minimumTlsVersion": "[parameters('minimumTlsVersion')]",
+ "networkAcls": "[if(not(empty(parameters('networkAcls'))), createObject('resourceAccessRules', tryGet(parameters('networkAcls'), 'resourceAccessRules'), 'bypass', tryGet(parameters('networkAcls'), 'bypass'), 'defaultAction', tryGet(parameters('networkAcls'), 'defaultAction'), 'virtualNetworkRules', tryGet(parameters('networkAcls'), 'virtualNetworkRules'), 'ipRules', tryGet(parameters('networkAcls'), 'ipRules')), null())]",
+ "allowBlobPublicAccess": "[parameters('allowBlobPublicAccess')]",
+ "publicNetworkAccess": "[if(not(empty(parameters('publicNetworkAccess'))), parameters('publicNetworkAccess'), if(and(not(empty(parameters('privateEndpoints'))), empty(parameters('networkAcls'))), 'Disabled', null()))]",
+ "azureFilesIdentityBasedAuthentication": "[if(not(empty(parameters('azureFilesIdentityBasedAuthentication'))), parameters('azureFilesIdentityBasedAuthentication'), null())]"
+ },
+ "dependsOn": [
+ "cMKKeyVault",
+ "cMKUserAssignedIdentity"
+ ]
+ },
+ "storageAccount_diagnosticSettings": {
+ "copy": {
+ "name": "storageAccount_diagnosticSettings",
+ "count": "[length(coalesce(parameters('diagnosticSettings'), createArray()))]"
+ },
+ "type": "Microsoft.Insights/diagnosticSettings",
+ "apiVersion": "2021-05-01-preview",
+ "scope": "[format('Microsoft.Storage/storageAccounts/{0}', parameters('name'))]",
+ "name": "[coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'name'), format('{0}-diagnosticSettings', parameters('name')))]",
+ "properties": {
+ "copy": [
+ {
+ "name": "metrics",
+ "count": "[length(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics'))))]",
+ "input": {
+ "category": "[coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics')))[copyIndex('metrics')].category]",
+ "enabled": "[coalesce(tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics')))[copyIndex('metrics')], 'enabled'), true())]",
+ "timeGrain": null
+ }
+ }
+ ],
+ "storageAccountId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'storageAccountResourceId')]",
+ "workspaceId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'workspaceResourceId')]",
+ "eventHubAuthorizationRuleId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'eventHubAuthorizationRuleResourceId')]",
+ "eventHubName": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'eventHubName')]",
+ "marketplacePartnerId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'marketplacePartnerResourceId')]",
+ "logAnalyticsDestinationType": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logAnalyticsDestinationType')]"
+ },
+ "dependsOn": [
+ "storageAccount"
+ ]
+ },
+ "storageAccount_lock": {
+ "condition": "[and(not(empty(coalesce(parameters('lock'), createObject()))), not(equals(tryGet(parameters('lock'), 'kind'), 'None')))]",
+ "type": "Microsoft.Authorization/locks",
+ "apiVersion": "2020-05-01",
+ "scope": "[format('Microsoft.Storage/storageAccounts/{0}', parameters('name'))]",
+ "name": "[coalesce(tryGet(parameters('lock'), 'name'), format('lock-{0}', parameters('name')))]",
+ "properties": {
+ "level": "[coalesce(tryGet(parameters('lock'), 'kind'), '')]",
+ "notes": "[if(equals(tryGet(parameters('lock'), 'kind'), 'CanNotDelete'), 'Cannot delete resource or child resources.', 'Cannot delete or modify the resource or child resources.')]"
+ },
+ "dependsOn": [
+ "storageAccount"
+ ]
+ },
+ "storageAccount_roleAssignments": {
+ "copy": {
+ "name": "storageAccount_roleAssignments",
+ "count": "[length(coalesce(parameters('roleAssignments'), createArray()))]"
+ },
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Storage/storageAccounts/{0}', parameters('name'))]",
+ "name": "[guid(resourceId('Microsoft.Storage/storageAccounts', parameters('name')), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].principalId, coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName)]",
+ "properties": {
+ "roleDefinitionId": "[if(contains(variables('builtInRoleNames'), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName), variables('builtInRoleNames')[coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName], if(contains(coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/'), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName)))]",
+ "principalId": "[coalesce(parameters('roleAssignments'), createArray())[copyIndex()].principalId]",
+ "description": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'description')]",
+ "principalType": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'principalType')]",
+ "condition": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'condition')]",
+ "conditionVersion": "[if(not(empty(tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'condition'))), coalesce(tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'conditionVersion'), '2.0'), null())]",
+ "delegatedManagedIdentityResourceId": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'delegatedManagedIdentityResourceId')]"
+ },
+ "dependsOn": [
+ "storageAccount"
+ ]
+ },
+ "storageAccount_privateEndpoints": {
+ "copy": {
+ "name": "storageAccount_privateEndpoints",
+ "count": "[length(coalesce(parameters('privateEndpoints'), createArray()))]"
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-StorageAccount-PrivateEndpoint-{1}', uniqueString(deployment().name, parameters('location')), copyIndex())]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "name": {
+ "value": "[coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'name'), format('pep-{0}-{1}-{2}', last(split(resourceId('Microsoft.Storage/storageAccounts', parameters('name')), '/')), coalesce(parameters('privateEndpoints'), createArray())[copyIndex()].service, copyIndex()))]"
+ },
+ "privateLinkServiceConnections": "[if(not(equals(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'manualPrivateLinkServiceConnections'), true())), createObject('value', createArray(createObject('name', coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'privateLinkServiceConnectionName'), format('{0}-{1}-{2}', last(split(resourceId('Microsoft.Storage/storageAccounts', parameters('name')), '/')), coalesce(parameters('privateEndpoints'), createArray())[copyIndex()].service, copyIndex())), 'properties', createObject('privateLinkServiceId', resourceId('Microsoft.Storage/storageAccounts', parameters('name')), 'groupIds', createArray(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()].service))))), createObject('value', null()))]",
+ "manualPrivateLinkServiceConnections": "[if(equals(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'manualPrivateLinkServiceConnections'), true()), createObject('value', createArray(createObject('name', coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'privateLinkServiceConnectionName'), format('{0}-{1}-{2}', last(split(resourceId('Microsoft.Storage/storageAccounts', parameters('name')), '/')), coalesce(parameters('privateEndpoints'), createArray())[copyIndex()].service, copyIndex())), 'properties', createObject('privateLinkServiceId', resourceId('Microsoft.Storage/storageAccounts', parameters('name')), 'groupIds', createArray(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()].service), 'requestMessage', coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'manualConnectionRequestMessage'), 'Manual approval required.'))))), createObject('value', null()))]",
+ "subnetResourceId": {
+ "value": "[coalesce(parameters('privateEndpoints'), createArray())[copyIndex()].subnetResourceId]"
+ },
+ "enableTelemetry": {
+ "value": "[coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'enableTelemetry'), parameters('enableTelemetry'))]"
+ },
+ "location": {
+ "value": "[coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'location'), reference(split(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()].subnetResourceId, '/subnets/')[0], '2020-06-01', 'Full').location)]"
+ },
+ "lock": {
+ "value": "[coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'lock'), parameters('lock'))]"
+ },
+ "privateDnsZoneGroupName": {
+ "value": "[tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'privateDnsZoneGroupName')]"
+ },
+ "privateDnsZoneResourceIds": {
+ "value": "[tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'privateDnsZoneResourceIds')]"
+ },
+ "roleAssignments": {
+ "value": "[tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'roleAssignments')]"
+ },
+ "tags": {
+ "value": "[coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'tags'), parameters('tags'))]"
+ },
+ "customDnsConfigs": {
+ "value": "[tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'customDnsConfigs')]"
+ },
+ "ipConfigurations": {
+ "value": "[tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'ipConfigurations')]"
+ },
+ "applicationSecurityGroupResourceIds": {
+ "value": "[tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'applicationSecurityGroupResourceIds')]"
+ },
+ "customNetworkInterfaceName": {
+ "value": "[tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'customNetworkInterfaceName')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.24.24.22086",
+ "templateHash": "2592884001616184297"
+ },
+ "name": "Private Endpoints",
+ "description": "This module deploys a Private Endpoint.",
+ "owner": "Azure/module-maintainers"
+ },
+ "definitions": {
+ "roleAssignmentType": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "roleDefinitionIdOrName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The role to assign. You can provide either the display name of the role definition, the role definition GUID, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'."
+ }
+ },
+ "principalId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The principal ID of the principal (user/group/identity) to assign the role to."
+ }
+ },
+ "principalType": {
+ "type": "string",
+ "allowedValues": [
+ "Device",
+ "ForeignGroup",
+ "Group",
+ "ServicePrincipal",
+ "User"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The principal type of the assigned principal ID."
+ }
+ },
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The description of the role assignment."
+ }
+ },
+ "condition": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase \"foo_storage_container\"."
+ }
+ },
+ "conditionVersion": {
+ "type": "string",
+ "allowedValues": [
+ "2.0"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Version of the condition."
+ }
+ },
+ "delegatedManagedIdentityResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The Resource Id of the delegated managed identity resource."
+ }
+ }
+ }
+ },
+ "nullable": true
+ },
+ "lockType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the name of lock."
+ }
+ },
+ "kind": {
+ "type": "string",
+ "allowedValues": [
+ "CanNotDelete",
+ "None",
+ "ReadOnly"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the type of lock."
+ }
+ }
+ },
+ "nullable": true
+ },
+ "ipConfigurationsType": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the resource that is unique within a resource group."
+ }
+ },
+ "properties": {
+ "type": "object",
+ "properties": {
+ "groupId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The ID of a group obtained from the remote resource that this private endpoint should connect to."
+ }
+ },
+ "memberName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The member name of a group obtained from the remote resource that this private endpoint should connect to."
+ }
+ },
+ "privateIPAddress": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. A private IP address obtained from the private endpoint's subnet."
+ }
+ }
+ },
+ "metadata": {
+ "description": "Required. Properties of private endpoint IP configurations."
+ }
+ }
+ }
+ },
+ "nullable": true
+ },
+ "manualPrivateLinkServiceConnectionsType": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the private link service connection."
+ }
+ },
+ "properties": {
+ "type": "object",
+ "properties": {
+ "groupIds": {
+ "type": "array",
+ "metadata": {
+ "description": "Required. The ID of a group obtained from the remote resource that this private endpoint should connect to."
+ }
+ },
+ "privateLinkServiceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The resource id of private link service."
+ }
+ },
+ "requestMessage": {
+ "type": "string",
+ "metadata": {
+ "description": "Optional. A message passed to the owner of the remote resource with this connection request. Restricted to 140 chars."
+ }
+ }
+ },
+ "metadata": {
+ "description": "Required. Properties of private link service connection."
+ }
+ }
+ }
+ },
+ "nullable": true
+ },
+ "privateLinkServiceConnectionsType": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the private link service connection."
+ }
+ },
+ "properties": {
+ "type": "object",
+ "properties": {
+ "groupIds": {
+ "type": "array",
+ "metadata": {
+ "description": "Required. The ID of a group obtained from the remote resource that this private endpoint should connect to."
+ }
+ },
+ "privateLinkServiceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The resource id of private link service."
+ }
+ },
+ "requestMessage": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. A message passed to the owner of the remote resource with this connection request. Restricted to 140 chars."
+ }
+ }
+ },
+ "metadata": {
+ "description": "Required. Properties of private link service connection."
+ }
+ }
+ }
+ },
+ "nullable": true
+ },
+ "customDnsConfigType": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "fqdn": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Fqdn that resolves to private endpoint IP address."
+ }
+ },
+ "ipAddresses": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "metadata": {
+ "description": "Required. A list of private IP addresses of the private endpoint."
+ }
+ }
+ }
+ },
+ "nullable": true
+ }
+ },
+ "parameters": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of the private endpoint resource to create."
+ }
+ },
+ "subnetResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Resource ID of the subnet where the endpoint needs to be created."
+ }
+ },
+ "applicationSecurityGroupResourceIds": {
+ "type": "array",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Application security groups in which the private endpoint IP configuration is included."
+ }
+ },
+ "customNetworkInterfaceName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The custom name of the network interface attached to the private endpoint."
+ }
+ },
+ "ipConfigurations": {
+ "$ref": "#/definitions/ipConfigurationsType",
+ "metadata": {
+ "description": "Optional. A list of IP configurations of the private endpoint. This will be used to map to the First Party Service endpoints."
+ }
+ },
+ "privateDnsZoneGroupName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of the private DNS zone group to create if `privateDnsZoneResourceIds` were provided."
+ }
+ },
+ "privateDnsZoneResourceIds": {
+ "type": "array",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The private DNS zone groups to associate the private endpoint. A DNS zone group can support up to 5 DNS zones."
+ }
+ },
+ "location": {
+ "type": "string",
+ "defaultValue": "[resourceGroup().location]",
+ "metadata": {
+ "description": "Optional. Location for all Resources."
+ }
+ },
+ "lock": {
+ "$ref": "#/definitions/lockType",
+ "metadata": {
+ "description": "Optional. The lock settings of the service."
+ }
+ },
+ "roleAssignments": {
+ "$ref": "#/definitions/roleAssignmentType",
+ "metadata": {
+ "description": "Optional. Array of role assignments to create."
+ }
+ },
+ "tags": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Tags to be applied on all resources/resource groups in this deployment."
+ }
+ },
+ "customDnsConfigs": {
+ "$ref": "#/definitions/customDnsConfigType",
+ "metadata": {
+ "description": "Optional. Custom DNS configurations."
+ }
+ },
+ "manualPrivateLinkServiceConnections": {
+ "$ref": "#/definitions/manualPrivateLinkServiceConnectionsType",
+ "metadata": {
+ "description": "Optional. A grouping of information about the connection to the remote resource. Used when the network admin does not have access to approve connections to the remote resource."
+ }
+ },
+ "privateLinkServiceConnections": {
+ "$ref": "#/definitions/privateLinkServiceConnectionsType",
+ "metadata": {
+ "description": "Optional. A grouping of information about the connection to the remote resource."
+ }
+ },
+ "enableTelemetry": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. Enable/Disable usage telemetry for module."
+ }
+ }
+ },
+ "variables": {
+ "builtInRoleNames": {
+ "Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
+ "DNS Resolver Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '0f2ebee7-ffd4-4fc0-b3b7-664099fdad5d')]",
+ "DNS Zone Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'befefa01-2a29-4197-83a8-272ff33ce314')]",
+ "Domain Services Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'eeaeda52-9324-47f6-8069-5d5bade478b2')]",
+ "Domain Services Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '361898ef-9ed1-48c2-849c-a832951106bb')]",
+ "Network Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '4d97b98b-1d4f-4787-a291-c67834d212e7')]",
+ "Owner": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]",
+ "Private DNS Zone Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b12aa53e-6015-4669-85d0-8515ebb3ae7f')]",
+ "Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'acdd72a7-3385-48ef-bd42-f606fba81ae7')]",
+ "Role Based Access Control Administrator (Preview)": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'f58310d9-a9f6-439a-9e8d-f62e7b41a168')]"
+ }
+ },
+ "resources": {
+ "avmTelemetry": {
+ "condition": "[parameters('enableTelemetry')]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2023-07-01",
+ "name": "[format('46d3xbcp.res.network-privateendpoint.{0}.{1}', replace('0.4.0', '.', '-'), substring(uniqueString(deployment().name, parameters('location')), 0, 4))]",
+ "properties": {
+ "mode": "Incremental",
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "resources": [],
+ "outputs": {
+ "telemetry": {
+ "type": "String",
+ "value": "For more information, see https://aka.ms/avm/TelemetryInfo"
+ }
+ }
+ }
+ }
+ },
+ "privateEndpoint": {
+ "type": "Microsoft.Network/privateEndpoints",
+ "apiVersion": "2023-04-01",
+ "name": "[parameters('name')]",
+ "location": "[parameters('location')]",
+ "tags": "[parameters('tags')]",
+ "properties": {
+ "copy": [
+ {
+ "name": "applicationSecurityGroups",
+ "count": "[length(coalesce(parameters('applicationSecurityGroupResourceIds'), createArray()))]",
+ "input": {
+ "id": "[coalesce(parameters('applicationSecurityGroupResourceIds'), createArray())[copyIndex('applicationSecurityGroups')]]"
+ }
+ }
+ ],
+ "customDnsConfigs": "[coalesce(parameters('customDnsConfigs'), createArray())]",
+ "customNetworkInterfaceName": "[coalesce(parameters('customNetworkInterfaceName'), '')]",
+ "ipConfigurations": "[coalesce(parameters('ipConfigurations'), createArray())]",
+ "manualPrivateLinkServiceConnections": "[coalesce(parameters('manualPrivateLinkServiceConnections'), createArray())]",
+ "privateLinkServiceConnections": "[coalesce(parameters('privateLinkServiceConnections'), createArray())]",
+ "subnet": {
+ "id": "[parameters('subnetResourceId')]"
+ }
+ }
+ },
+ "privateEndpoint_lock": {
+ "condition": "[and(not(empty(coalesce(parameters('lock'), createObject()))), not(equals(tryGet(parameters('lock'), 'kind'), 'None')))]",
+ "type": "Microsoft.Authorization/locks",
+ "apiVersion": "2020-05-01",
+ "scope": "[format('Microsoft.Network/privateEndpoints/{0}', parameters('name'))]",
+ "name": "[coalesce(tryGet(parameters('lock'), 'name'), format('lock-{0}', parameters('name')))]",
+ "properties": {
+ "level": "[coalesce(tryGet(parameters('lock'), 'kind'), '')]",
+ "notes": "[if(equals(tryGet(parameters('lock'), 'kind'), 'CanNotDelete'), 'Cannot delete resource or child resources.', 'Cannot delete or modify the resource or child resources.')]"
+ },
+ "dependsOn": [
+ "privateEndpoint"
+ ]
+ },
+ "privateEndpoint_roleAssignments": {
+ "copy": {
+ "name": "privateEndpoint_roleAssignments",
+ "count": "[length(coalesce(parameters('roleAssignments'), createArray()))]"
+ },
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Network/privateEndpoints/{0}', parameters('name'))]",
+ "name": "[guid(resourceId('Microsoft.Network/privateEndpoints', parameters('name')), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].principalId, coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName)]",
+ "properties": {
+ "roleDefinitionId": "[if(contains(variables('builtInRoleNames'), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName), variables('builtInRoleNames')[coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName], if(contains(coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/'), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName)))]",
+ "principalId": "[coalesce(parameters('roleAssignments'), createArray())[copyIndex()].principalId]",
+ "description": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'description')]",
+ "principalType": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'principalType')]",
+ "condition": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'condition')]",
+ "conditionVersion": "[if(not(empty(tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'condition'))), coalesce(tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'conditionVersion'), '2.0'), null())]",
+ "delegatedManagedIdentityResourceId": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'delegatedManagedIdentityResourceId')]"
+ },
+ "dependsOn": [
+ "privateEndpoint"
+ ]
+ },
+ "privateEndpoint_privateDnsZoneGroup": {
+ "condition": "[not(empty(parameters('privateDnsZoneResourceIds')))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-PrivateEndpoint-PrivateDnsZoneGroup', uniqueString(deployment().name))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "name": {
+ "value": "[coalesce(parameters('privateDnsZoneGroupName'), 'default')]"
+ },
+ "privateDNSResourceIds": {
+ "value": "[coalesce(parameters('privateDnsZoneResourceIds'), createArray())]"
+ },
+ "privateEndpointName": {
+ "value": "[parameters('name')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.24.24.22086",
+ "templateHash": "9321937464667207030"
+ },
+ "name": "Private Endpoint Private DNS Zone Groups",
+ "description": "This module deploys a Private Endpoint Private DNS Zone Group.",
+ "owner": "Azure/module-maintainers"
+ },
+ "parameters": {
+ "privateEndpointName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent private endpoint. Required if the template is used in a standalone deployment."
+ }
+ },
+ "privateDNSResourceIds": {
+ "type": "array",
+ "minLength": 1,
+ "maxLength": 5,
+ "metadata": {
+ "description": "Required. Array of private DNS zone resource IDs. A DNS zone group can support up to 5 DNS zones."
+ }
+ },
+ "name": {
+ "type": "string",
+ "defaultValue": "default",
+ "metadata": {
+ "description": "Optional. The name of the private DNS zone group."
+ }
+ }
+ },
+ "variables": {
+ "copy": [
+ {
+ "name": "privateDnsZoneConfigs",
+ "count": "[length(parameters('privateDNSResourceIds'))]",
+ "input": {
+ "name": "[last(split(parameters('privateDNSResourceIds')[copyIndex('privateDnsZoneConfigs')], '/'))]",
+ "properties": {
+ "privateDnsZoneId": "[parameters('privateDNSResourceIds')[copyIndex('privateDnsZoneConfigs')]]"
+ }
+ }
+ }
+ ]
+ },
+ "resources": [
+ {
+ "type": "Microsoft.Network/privateEndpoints/privateDnsZoneGroups",
+ "apiVersion": "2023-04-01",
+ "name": "[format('{0}/{1}', parameters('privateEndpointName'), parameters('name'))]",
+ "properties": {
+ "privateDnsZoneConfigs": "[variables('privateDnsZoneConfigs')]"
+ }
+ }
+ ],
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the private endpoint DNS zone group."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the private endpoint DNS zone group."
+ },
+ "value": "[resourceId('Microsoft.Network/privateEndpoints/privateDnsZoneGroups', parameters('privateEndpointName'), parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group the private endpoint DNS zone group was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "privateEndpoint"
+ ]
+ }
+ },
+ "outputs": {
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group the private endpoint was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the private endpoint."
+ },
+ "value": "[resourceId('Microsoft.Network/privateEndpoints', parameters('name'))]"
+ },
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the private endpoint."
+ },
+ "value": "[parameters('name')]"
+ },
+ "location": {
+ "type": "string",
+ "metadata": {
+ "description": "The location the resource was deployed into."
+ },
+ "value": "[reference('privateEndpoint', '2023-04-01', 'full').location]"
+ },
+ "groupId": {
+ "type": "string",
+ "metadata": {
+ "description": "The group Id for the private endpoint Group."
+ },
+ "value": "[if(not(empty(reference('privateEndpoint').manualPrivateLinkServiceConnections)), reference('privateEndpoint').manualPrivateLinkServiceConnections[0].properties.groupIds[0], reference('privateEndpoint').privateLinkServiceConnections[0].properties.groupIds[0])]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "storageAccount"
+ ]
+ },
+ "storageAccount_managementPolicies": {
+ "condition": "[not(empty(coalesce(parameters('managementPolicyRules'), createArray())))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Storage-ManagementPolicies', uniqueString(deployment().name, parameters('location')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "storageAccountName": {
+ "value": "[parameters('name')]"
+ },
+ "rules": {
+ "value": "[coalesce(parameters('managementPolicyRules'), createArray())]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.26.170.59819",
+ "templateHash": "4153955640795225346"
+ },
+ "name": "Storage Account Management Policies",
+ "description": "This module deploys a Storage Account Management Policy.",
+ "owner": "Azure/module-maintainers"
+ },
+ "parameters": {
+ "storageAccountName": {
+ "type": "string",
+ "maxLength": 24,
+ "metadata": {
+ "description": "Conditional. The name of the parent Storage Account. Required if the template is used in a standalone deployment."
+ }
+ },
+ "rules": {
+ "type": "array",
+ "metadata": {
+ "description": "Required. The Storage Account ManagementPolicies Rules."
+ }
+ }
+ },
+ "resources": [
+ {
+ "type": "Microsoft.Storage/storageAccounts/managementPolicies",
+ "apiVersion": "2023-01-01",
+ "name": "[format('{0}/{1}', parameters('storageAccountName'), 'default')]",
+ "properties": {
+ "policy": {
+ "rules": "[parameters('rules')]"
+ }
+ }
+ }
+ ],
+ "outputs": {
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the deployed management policy."
+ },
+ "value": "default"
+ },
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the deployed management policy."
+ },
+ "value": "default"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group of the deployed management policy."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "storageAccount",
+ "storageAccount_blobServices"
+ ]
+ },
+ "storageAccount_localUsers": {
+ "copy": {
+ "name": "storageAccount_localUsers",
+ "count": "[length(parameters('localUsers'))]"
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Storage-LocalUsers-{1}', uniqueString(deployment().name, parameters('location')), copyIndex())]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "storageAccountName": {
+ "value": "[parameters('name')]"
+ },
+ "name": {
+ "value": "[parameters('localUsers')[copyIndex()].name]"
+ },
+ "hasSshKey": {
+ "value": "[parameters('localUsers')[copyIndex()].hasSshKey]"
+ },
+ "hasSshPassword": {
+ "value": "[parameters('localUsers')[copyIndex()].hasSshPassword]"
+ },
+ "permissionScopes": {
+ "value": "[parameters('localUsers')[copyIndex()].permissionScopes]"
+ },
+ "hasSharedKey": {
+ "value": "[tryGet(parameters('localUsers')[copyIndex()], 'hasSharedKey')]"
+ },
+ "homeDirectory": {
+ "value": "[tryGet(parameters('localUsers')[copyIndex()], 'homeDirectory')]"
+ },
+ "sshAuthorizedKeys": {
+ "value": "[tryGet(parameters('localUsers')[copyIndex()], 'sshAuthorizedKeys')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.26.170.59819",
+ "templateHash": "14593329616022153178"
+ },
+ "name": "Storage Account Local Users",
+ "description": "This module deploys a Storage Account Local User, which is used for SFTP authentication.",
+ "owner": "Azure/module-maintainers"
+ },
+ "definitions": {
+ "sshAuthorizedKeysType": {
+ "type": "secureObject",
+ "properties": {
+ "secureList": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Description used to store the function/usage of the key."
+ }
+ },
+ "key": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. SSH public key base64 encoded. The format should be: '{keyType} {keyData}', e.g. ssh-rsa AAAABBBB."
+ }
+ }
+ }
+ },
+ "metadata": {
+ "description": "Optional. The list of SSH authorized keys."
+ }
+ }
+ },
+ "nullable": true
+ }
+ },
+ "parameters": {
+ "storageAccountName": {
+ "type": "string",
+ "maxLength": 24,
+ "metadata": {
+ "description": "Conditional. The name of the parent Storage Account. Required if the template is used in a standalone deployment."
+ }
+ },
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the local user used for SFTP Authentication."
+ }
+ },
+ "hasSharedKey": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. Indicates whether shared key exists. Set it to false to remove existing shared key."
+ }
+ },
+ "hasSshKey": {
+ "type": "bool",
+ "metadata": {
+ "description": "Required. Indicates whether SSH key exists. Set it to false to remove existing SSH key."
+ }
+ },
+ "hasSshPassword": {
+ "type": "bool",
+ "metadata": {
+ "description": "Required. Indicates whether SSH password exists. Set it to false to remove existing SSH password."
+ }
+ },
+ "homeDirectory": {
+ "type": "string",
+ "defaultValue": "",
+ "metadata": {
+ "description": "Optional. The local user home directory."
+ }
+ },
+ "permissionScopes": {
+ "type": "array",
+ "metadata": {
+ "description": "Required. The permission scopes of the local user."
+ }
+ },
+ "sshAuthorizedKeys": {
+ "$ref": "#/definitions/sshAuthorizedKeysType",
+ "metadata": {
+ "description": "Optional. The local user SSH authorized keys for SFTP."
+ }
+ }
+ },
+ "resources": {
+ "storageAccount": {
+ "existing": true,
+ "type": "Microsoft.Storage/storageAccounts",
+ "apiVersion": "2021-09-01",
+ "name": "[parameters('storageAccountName')]"
+ },
+ "localUsers": {
+ "type": "Microsoft.Storage/storageAccounts/localUsers",
+ "apiVersion": "2022-05-01",
+ "name": "[format('{0}/{1}', parameters('storageAccountName'), parameters('name'))]",
+ "properties": {
+ "hasSharedKey": "[parameters('hasSharedKey')]",
+ "hasSshKey": "[parameters('hasSshKey')]",
+ "hasSshPassword": "[parameters('hasSshPassword')]",
+ "homeDirectory": "[parameters('homeDirectory')]",
+ "permissionScopes": "[parameters('permissionScopes')]",
+ "sshAuthorizedKeys": "[tryGet(parameters('sshAuthorizedKeys'), 'secureList')]"
+ },
+ "dependsOn": [
+ "storageAccount"
+ ]
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the deployed local user."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group of the deployed local user."
+ },
+ "value": "[resourceGroup().name]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the deployed local user."
+ },
+ "value": "[resourceId('Microsoft.Storage/storageAccounts/localUsers', parameters('storageAccountName'), parameters('name'))]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "storageAccount"
+ ]
+ },
+ "storageAccount_blobServices": {
+ "condition": "[not(empty(parameters('blobServices')))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Storage-BlobServices', uniqueString(deployment().name, parameters('location')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "storageAccountName": {
+ "value": "[parameters('name')]"
+ },
+ "containers": {
+ "value": "[tryGet(parameters('blobServices'), 'containers')]"
+ },
+ "automaticSnapshotPolicyEnabled": {
+ "value": "[tryGet(parameters('blobServices'), 'automaticSnapshotPolicyEnabled')]"
+ },
+ "changeFeedEnabled": {
+ "value": "[tryGet(parameters('blobServices'), 'changeFeedEnabled')]"
+ },
+ "changeFeedRetentionInDays": {
+ "value": "[tryGet(parameters('blobServices'), 'changeFeedRetentionInDays')]"
+ },
+ "containerDeleteRetentionPolicyEnabled": {
+ "value": "[tryGet(parameters('blobServices'), 'containerDeleteRetentionPolicyEnabled')]"
+ },
+ "containerDeleteRetentionPolicyDays": {
+ "value": "[tryGet(parameters('blobServices'), 'containerDeleteRetentionPolicyDays')]"
+ },
+ "containerDeleteRetentionPolicyAllowPermanentDelete": {
+ "value": "[tryGet(parameters('blobServices'), 'containerDeleteRetentionPolicyAllowPermanentDelete')]"
+ },
+ "corsRules": {
+ "value": "[tryGet(parameters('blobServices'), 'corsRules')]"
+ },
+ "defaultServiceVersion": {
+ "value": "[tryGet(parameters('blobServices'), 'defaultServiceVersion')]"
+ },
+ "deleteRetentionPolicyAllowPermanentDelete": {
+ "value": "[tryGet(parameters('blobServices'), 'deleteRetentionPolicyAllowPermanentDelete')]"
+ },
+ "deleteRetentionPolicyEnabled": {
+ "value": "[tryGet(parameters('blobServices'), 'deleteRetentionPolicyEnabled')]"
+ },
+ "deleteRetentionPolicyDays": {
+ "value": "[tryGet(parameters('blobServices'), 'deleteRetentionPolicyDays')]"
+ },
+ "isVersioningEnabled": {
+ "value": "[tryGet(parameters('blobServices'), 'isVersioningEnabled')]"
+ },
+ "lastAccessTimeTrackingPolicyEnabled": {
+ "value": "[tryGet(parameters('blobServices'), 'lastAccessTimeTrackingPolicyEnabled')]"
+ },
+ "restorePolicyEnabled": {
+ "value": "[tryGet(parameters('blobServices'), 'restorePolicyEnabled')]"
+ },
+ "restorePolicyDays": {
+ "value": "[tryGet(parameters('blobServices'), 'restorePolicyDays')]"
+ },
+ "diagnosticSettings": {
+ "value": "[tryGet(parameters('blobServices'), 'diagnosticSettings')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.26.170.59819",
+ "templateHash": "7278814029590745003"
+ },
+ "name": "Storage Account blob Services",
+ "description": "This module deploys a Storage Account Blob Service.",
+ "owner": "Azure/module-maintainers"
+ },
+ "definitions": {
+ "diagnosticSettingType": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of diagnostic setting."
+ }
+ },
+ "logCategoriesAndGroups": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "category": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of a Diagnostic Log category for a resource type this setting is applied to. Set the specific logs to collect here."
+ }
+ },
+ "categoryGroup": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of a Diagnostic Log category group for a resource type this setting is applied to. Set to `allLogs` to collect all logs."
+ }
+ },
+ "enabled": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable or disable the category explicitly. Default is `true`."
+ }
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of logs that will be streamed. \"allLogs\" includes all possible logs for the resource. Set to `[]` to disable log collection."
+ }
+ },
+ "metricCategories": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "category": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of a Diagnostic Metric category for a resource type this setting is applied to. Set to `AllMetrics` to collect all metrics."
+ }
+ },
+ "enabled": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable or disable the category explicitly. Default is `true`."
+ }
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of logs that will be streamed. \"allLogs\" includes all possible logs for the resource. Set to `[]` to disable log collection."
+ }
+ },
+ "logAnalyticsDestinationType": {
+ "type": "string",
+ "allowedValues": [
+ "AzureDiagnostics",
+ "Dedicated"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type."
+ }
+ },
+ "workspaceResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic log analytics workspace. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "storageAccountResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic storage account. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "eventHubAuthorizationRuleResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to."
+ }
+ },
+ "eventHubName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of the diagnostic event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "marketplacePartnerResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The full ARM resource ID of the Marketplace resource to which you would like to send Diagnostic Logs."
+ }
+ }
+ }
+ },
+ "nullable": true
+ }
+ },
+ "parameters": {
+ "storageAccountName": {
+ "type": "string",
+ "maxLength": 24,
+ "metadata": {
+ "description": "Conditional. The name of the parent Storage Account. Required if the template is used in a standalone deployment."
+ }
+ },
+ "automaticSnapshotPolicyEnabled": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. Automatic Snapshot is enabled if set to true."
+ }
+ },
+ "changeFeedEnabled": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. The blob service properties for change feed events. Indicates whether change feed event logging is enabled for the Blob service."
+ }
+ },
+ "changeFeedRetentionInDays": {
+ "type": "int",
+ "nullable": true,
+ "minValue": 0,
+ "maxValue": 146000,
+ "metadata": {
+ "description": "Optional. Indicates whether change feed event logging is enabled for the Blob service. Indicates the duration of changeFeed retention in days. A \"0\" value indicates an infinite retention of the change feed."
+ }
+ },
+ "containerDeleteRetentionPolicyEnabled": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. The blob service properties for container soft delete. Indicates whether DeleteRetentionPolicy is enabled."
+ }
+ },
+ "containerDeleteRetentionPolicyDays": {
+ "type": "int",
+ "nullable": true,
+ "minValue": 1,
+ "maxValue": 365,
+ "metadata": {
+ "description": "Optional. Indicates the number of days that the deleted item should be retained."
+ }
+ },
+ "containerDeleteRetentionPolicyAllowPermanentDelete": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. This property when set to true allows deletion of the soft deleted blob versions and snapshots. This property cannot be used with blob restore policy. This property only applies to blob service and does not apply to containers or file share."
+ }
+ },
+ "corsRules": {
+ "type": "array",
+ "defaultValue": [],
+ "metadata": {
+ "description": "Optional. Specifies CORS rules for the Blob service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Blob service."
+ }
+ },
+ "defaultServiceVersion": {
+ "type": "string",
+ "defaultValue": "",
+ "metadata": {
+ "description": "Optional. Indicates the default version to use for requests to the Blob service if an incoming request's version is not specified. Possible values include version 2008-10-27 and all more recent versions."
+ }
+ },
+ "deleteRetentionPolicyEnabled": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. The blob service properties for blob soft delete."
+ }
+ },
+ "deleteRetentionPolicyDays": {
+ "type": "int",
+ "defaultValue": 7,
+ "minValue": 1,
+ "maxValue": 365,
+ "metadata": {
+ "description": "Optional. Indicates the number of days that the deleted blob should be retained."
+ }
+ },
+ "deleteRetentionPolicyAllowPermanentDelete": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. This property when set to true allows deletion of the soft deleted blob versions and snapshots. This property cannot be used with blob restore policy. This property only applies to blob service and does not apply to containers or file share."
+ }
+ },
+ "isVersioningEnabled": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. Use versioning to automatically maintain previous versions of your blobs."
+ }
+ },
+ "lastAccessTimeTrackingPolicyEnabled": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. The blob service property to configure last access time based tracking policy. When set to true last access time based tracking is enabled."
+ }
+ },
+ "restorePolicyEnabled": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. The blob service properties for blob restore policy. If point-in-time restore is enabled, then versioning, change feed, and blob soft delete must also be enabled."
+ }
+ },
+ "restorePolicyDays": {
+ "type": "int",
+ "defaultValue": 6,
+ "minValue": 1,
+ "metadata": {
+ "description": "Optional. How long this blob can be restored. It should be less than DeleteRetentionPolicy days."
+ }
+ },
+ "containers": {
+ "type": "array",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Blob containers to create."
+ }
+ },
+ "diagnosticSettings": {
+ "$ref": "#/definitions/diagnosticSettingType",
+ "metadata": {
+ "description": "Optional. The diagnostic settings of the service."
+ }
+ }
+ },
+ "variables": {
+ "name": "default"
+ },
+ "resources": {
+ "storageAccount": {
+ "existing": true,
+ "type": "Microsoft.Storage/storageAccounts",
+ "apiVersion": "2022-09-01",
+ "name": "[parameters('storageAccountName')]"
+ },
+ "blobServices": {
+ "type": "Microsoft.Storage/storageAccounts/blobServices",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}/{1}', parameters('storageAccountName'), variables('name'))]",
+ "properties": {
+ "automaticSnapshotPolicyEnabled": "[parameters('automaticSnapshotPolicyEnabled')]",
+ "changeFeed": "[if(parameters('changeFeedEnabled'), createObject('enabled', true(), 'retentionInDays', parameters('changeFeedRetentionInDays')), null())]",
+ "containerDeleteRetentionPolicy": {
+ "enabled": "[parameters('containerDeleteRetentionPolicyEnabled')]",
+ "days": "[parameters('containerDeleteRetentionPolicyDays')]",
+ "allowPermanentDelete": "[if(equals(parameters('containerDeleteRetentionPolicyEnabled'), true()), parameters('containerDeleteRetentionPolicyAllowPermanentDelete'), null())]"
+ },
+ "cors": {
+ "corsRules": "[parameters('corsRules')]"
+ },
+ "defaultServiceVersion": "[if(not(empty(parameters('defaultServiceVersion'))), parameters('defaultServiceVersion'), null())]",
+ "deleteRetentionPolicy": {
+ "enabled": "[parameters('deleteRetentionPolicyEnabled')]",
+ "days": "[parameters('deleteRetentionPolicyDays')]",
+ "allowPermanentDelete": "[if(and(parameters('deleteRetentionPolicyEnabled'), parameters('deleteRetentionPolicyAllowPermanentDelete')), true(), null())]"
+ },
+ "isVersioningEnabled": "[parameters('isVersioningEnabled')]",
+ "lastAccessTimeTrackingPolicy": "[if(not(equals(reference('storageAccount', '2022-09-01', 'full').kind, 'Storage')), createObject('enable', parameters('lastAccessTimeTrackingPolicyEnabled'), 'name', if(equals(parameters('lastAccessTimeTrackingPolicyEnabled'), true()), 'AccessTimeTracking', null()), 'trackingGranularityInDays', if(equals(parameters('lastAccessTimeTrackingPolicyEnabled'), true()), 1, null())), null())]",
+ "restorePolicy": "[if(parameters('restorePolicyEnabled'), createObject('enabled', true(), 'days', parameters('restorePolicyDays')), null())]"
+ },
+ "dependsOn": [
+ "storageAccount"
+ ]
+ },
+ "blobServices_diagnosticSettings": {
+ "copy": {
+ "name": "blobServices_diagnosticSettings",
+ "count": "[length(coalesce(parameters('diagnosticSettings'), createArray()))]"
+ },
+ "type": "Microsoft.Insights/diagnosticSettings",
+ "apiVersion": "2021-05-01-preview",
+ "scope": "[format('Microsoft.Storage/storageAccounts/{0}/blobServices/{1}', parameters('storageAccountName'), variables('name'))]",
+ "name": "[coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'name'), format('{0}-diagnosticSettings', variables('name')))]",
+ "properties": {
+ "copy": [
+ {
+ "name": "metrics",
+ "count": "[length(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics'))))]",
+ "input": {
+ "category": "[coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics')))[copyIndex('metrics')].category]",
+ "enabled": "[coalesce(tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics')))[copyIndex('metrics')], 'enabled'), true())]",
+ "timeGrain": null
+ }
+ },
+ {
+ "name": "logs",
+ "count": "[length(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs'))))]",
+ "input": {
+ "categoryGroup": "[tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'categoryGroup')]",
+ "category": "[tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'category')]",
+ "enabled": "[coalesce(tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'enabled'), true())]"
+ }
+ }
+ ],
+ "storageAccountId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'storageAccountResourceId')]",
+ "workspaceId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'workspaceResourceId')]",
+ "eventHubAuthorizationRuleId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'eventHubAuthorizationRuleResourceId')]",
+ "eventHubName": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'eventHubName')]",
+ "marketplacePartnerId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'marketplacePartnerResourceId')]",
+ "logAnalyticsDestinationType": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logAnalyticsDestinationType')]"
+ },
+ "dependsOn": [
+ "blobServices"
+ ]
+ },
+ "blobServices_container": {
+ "copy": {
+ "name": "blobServices_container",
+ "count": "[length(coalesce(parameters('containers'), createArray()))]"
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Container-{1}', deployment().name, copyIndex())]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "storageAccountName": {
+ "value": "[parameters('storageAccountName')]"
+ },
+ "name": {
+ "value": "[coalesce(parameters('containers'), createArray())[copyIndex()].name]"
+ },
+ "defaultEncryptionScope": {
+ "value": "[tryGet(coalesce(parameters('containers'), createArray())[copyIndex()], 'defaultEncryptionScope')]"
+ },
+ "denyEncryptionScopeOverride": {
+ "value": "[tryGet(coalesce(parameters('containers'), createArray())[copyIndex()], 'denyEncryptionScopeOverride')]"
+ },
+ "enableNfsV3AllSquash": {
+ "value": "[tryGet(coalesce(parameters('containers'), createArray())[copyIndex()], 'enableNfsV3AllSquash')]"
+ },
+ "enableNfsV3RootSquash": {
+ "value": "[tryGet(coalesce(parameters('containers'), createArray())[copyIndex()], 'enableNfsV3RootSquash')]"
+ },
+ "immutableStorageWithVersioningEnabled": {
+ "value": "[tryGet(coalesce(parameters('containers'), createArray())[copyIndex()], 'immutableStorageWithVersioningEnabled')]"
+ },
+ "metadata": {
+ "value": "[tryGet(coalesce(parameters('containers'), createArray())[copyIndex()], 'metadata')]"
+ },
+ "publicAccess": {
+ "value": "[tryGet(coalesce(parameters('containers'), createArray())[copyIndex()], 'publicAccess')]"
+ },
+ "roleAssignments": {
+ "value": "[tryGet(coalesce(parameters('containers'), createArray())[copyIndex()], 'roleAssignments')]"
+ },
+ "immutabilityPolicyProperties": {
+ "value": "[tryGet(coalesce(parameters('containers'), createArray())[copyIndex()], 'immutabilityPolicyProperties')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.26.170.59819",
+ "templateHash": "3805384021483033369"
+ },
+ "name": "Storage Account Blob Containers",
+ "description": "This module deploys a Storage Account Blob Container.",
+ "owner": "Azure/module-maintainers"
+ },
+ "definitions": {
+ "roleAssignmentType": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "roleDefinitionIdOrName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The role to assign. You can provide either the display name of the role definition, the role definition GUID, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'."
+ }
+ },
+ "principalId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The principal ID of the principal (user/group/identity) to assign the role to."
+ }
+ },
+ "principalType": {
+ "type": "string",
+ "allowedValues": [
+ "Device",
+ "ForeignGroup",
+ "Group",
+ "ServicePrincipal",
+ "User"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The principal type of the assigned principal ID."
+ }
+ },
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The description of the role assignment."
+ }
+ },
+ "condition": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase \"foo_storage_container\"."
+ }
+ },
+ "conditionVersion": {
+ "type": "string",
+ "allowedValues": [
+ "2.0"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Version of the condition."
+ }
+ },
+ "delegatedManagedIdentityResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The Resource Id of the delegated managed identity resource."
+ }
+ }
+ }
+ },
+ "nullable": true
+ }
+ },
+ "parameters": {
+ "storageAccountName": {
+ "type": "string",
+ "maxLength": 24,
+ "metadata": {
+ "description": "Conditional. The name of the parent Storage Account. Required if the template is used in a standalone deployment."
+ }
+ },
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the storage container to deploy."
+ }
+ },
+ "defaultEncryptionScope": {
+ "type": "string",
+ "defaultValue": "",
+ "metadata": {
+ "description": "Optional. Default the container to use specified encryption scope for all writes."
+ }
+ },
+ "denyEncryptionScopeOverride": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. Block override of encryption scope from the container default."
+ }
+ },
+ "enableNfsV3AllSquash": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. Enable NFSv3 all squash on blob container."
+ }
+ },
+ "enableNfsV3RootSquash": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. Enable NFSv3 root squash on blob container."
+ }
+ },
+ "immutableStorageWithVersioningEnabled": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. This is an immutable property, when set to true it enables object level immutability at the container level. The property is immutable and can only be set to true at the container creation time. Existing containers must undergo a migration process."
+ }
+ },
+ "immutabilityPolicyName": {
+ "type": "string",
+ "defaultValue": "default",
+ "metadata": {
+ "description": "Optional. Name of the immutable policy."
+ }
+ },
+ "immutabilityPolicyProperties": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Configure immutability policy."
+ }
+ },
+ "metadata": {
+ "type": "object",
+ "defaultValue": {},
+ "metadata": {
+ "description": "Optional. A name-value pair to associate with the container as metadata."
+ }
+ },
+ "publicAccess": {
+ "type": "string",
+ "defaultValue": "None",
+ "allowedValues": [
+ "Container",
+ "Blob",
+ "None"
+ ],
+ "metadata": {
+ "description": "Optional. Specifies whether data in the container may be accessed publicly and the level of access."
+ }
+ },
+ "roleAssignments": {
+ "$ref": "#/definitions/roleAssignmentType",
+ "metadata": {
+ "description": "Optional. Array of role assignments to create."
+ }
+ }
+ },
+ "variables": {
+ "builtInRoleNames": {
+ "Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
+ "Owner": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]",
+ "Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'acdd72a7-3385-48ef-bd42-f606fba81ae7')]",
+ "Reader and Data Access": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'c12c1c16-33a1-487b-954d-41c89c60f349')]",
+ "Role Based Access Control Administrator (Preview)": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'f58310d9-a9f6-439a-9e8d-f62e7b41a168')]",
+ "Storage Account Backup Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'e5e2a7ff-d759-4cd2-bb51-3152d37e2eb1')]",
+ "Storage Account Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '17d1049b-9a84-46fb-8f53-869881c3d3ab')]",
+ "Storage Account Key Operator Service Role": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '81a9662b-bebf-436f-a333-f67b29880f12')]",
+ "Storage Blob Data Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'ba92f5b4-2d11-453d-a403-e96b0029c9fe')]",
+ "Storage Blob Data Owner": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b7e6dc6d-f1e8-4753-8033-0f276bb0955b')]",
+ "Storage Blob Data Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '2a2b9908-6ea1-4ae2-8e65-a410df84e7d1')]",
+ "Storage Blob Delegator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'db58b8e5-c6ad-4a2a-8342-4190687cbf4a')]",
+ "User Access Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '18d7d88d-d35e-4fb5-a5c3-7773c20a72d9')]"
+ }
+ },
+ "resources": {
+ "storageAccount::blobServices": {
+ "existing": true,
+ "type": "Microsoft.Storage/storageAccounts/blobServices",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}/{1}', parameters('storageAccountName'), 'default')]",
+ "dependsOn": [
+ "storageAccount"
+ ]
+ },
+ "storageAccount": {
+ "existing": true,
+ "type": "Microsoft.Storage/storageAccounts",
+ "apiVersion": "2022-09-01",
+ "name": "[parameters('storageAccountName')]"
+ },
+ "container": {
+ "type": "Microsoft.Storage/storageAccounts/blobServices/containers",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}/{1}/{2}', parameters('storageAccountName'), 'default', parameters('name'))]",
+ "properties": {
+ "defaultEncryptionScope": "[if(not(empty(parameters('defaultEncryptionScope'))), parameters('defaultEncryptionScope'), null())]",
+ "denyEncryptionScopeOverride": "[if(equals(parameters('denyEncryptionScopeOverride'), true()), parameters('denyEncryptionScopeOverride'), null())]",
+ "enableNfsV3AllSquash": "[if(equals(parameters('enableNfsV3AllSquash'), true()), parameters('enableNfsV3AllSquash'), null())]",
+ "enableNfsV3RootSquash": "[if(equals(parameters('enableNfsV3RootSquash'), true()), parameters('enableNfsV3RootSquash'), null())]",
+ "immutableStorageWithVersioning": "[if(equals(parameters('immutableStorageWithVersioningEnabled'), true()), createObject('enabled', parameters('immutableStorageWithVersioningEnabled')), null())]",
+ "metadata": "[parameters('metadata')]",
+ "publicAccess": "[parameters('publicAccess')]"
+ },
+ "dependsOn": [
+ "storageAccount::blobServices"
+ ]
+ },
+ "container_roleAssignments": {
+ "copy": {
+ "name": "container_roleAssignments",
+ "count": "[length(coalesce(parameters('roleAssignments'), createArray()))]"
+ },
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Storage/storageAccounts/{0}/blobServices/{1}/containers/{2}', parameters('storageAccountName'), 'default', parameters('name'))]",
+ "name": "[guid(resourceId('Microsoft.Storage/storageAccounts/blobServices/containers', parameters('storageAccountName'), 'default', parameters('name')), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].principalId, coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName)]",
+ "properties": {
+ "roleDefinitionId": "[if(contains(variables('builtInRoleNames'), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName), variables('builtInRoleNames')[coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName], if(contains(coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/'), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName)))]",
+ "principalId": "[coalesce(parameters('roleAssignments'), createArray())[copyIndex()].principalId]",
+ "description": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'description')]",
+ "principalType": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'principalType')]",
+ "condition": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'condition')]",
+ "conditionVersion": "[if(not(empty(tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'condition'))), coalesce(tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'conditionVersion'), '2.0'), null())]",
+ "delegatedManagedIdentityResourceId": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'delegatedManagedIdentityResourceId')]"
+ },
+ "dependsOn": [
+ "container"
+ ]
+ },
+ "immutabilityPolicy": {
+ "condition": "[not(empty(coalesce(parameters('immutabilityPolicyProperties'), createObject())))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[parameters('immutabilityPolicyName')]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "storageAccountName": {
+ "value": "[parameters('storageAccountName')]"
+ },
+ "containerName": {
+ "value": "[parameters('name')]"
+ },
+ "immutabilityPeriodSinceCreationInDays": {
+ "value": "[tryGet(parameters('immutabilityPolicyProperties'), 'immutabilityPeriodSinceCreationInDays')]"
+ },
+ "allowProtectedAppendWrites": {
+ "value": "[tryGet(parameters('immutabilityPolicyProperties'), 'allowProtectedAppendWrites')]"
+ },
+ "allowProtectedAppendWritesAll": {
+ "value": "[tryGet(parameters('immutabilityPolicyProperties'), 'allowProtectedAppendWritesAll')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.26.170.59819",
+ "templateHash": "12849754295459852309"
+ },
+ "name": "Storage Account Blob Container Immutability Policies",
+ "description": "This module deploys a Storage Account Blob Container Immutability Policy.",
+ "owner": "Azure/module-maintainers"
+ },
+ "parameters": {
+ "storageAccountName": {
+ "type": "string",
+ "maxLength": 24,
+ "metadata": {
+ "description": "Conditional. The name of the parent Storage Account. Required if the template is used in a standalone deployment."
+ }
+ },
+ "containerName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent container to apply the policy to. Required if the template is used in a standalone deployment."
+ }
+ },
+ "immutabilityPeriodSinceCreationInDays": {
+ "type": "int",
+ "defaultValue": 365,
+ "metadata": {
+ "description": "Optional. The immutability period for the blobs in the container since the policy creation, in days."
+ }
+ },
+ "allowProtectedAppendWrites": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining immutability protection and compliance. Only new blocks can be added and any existing blocks cannot be modified or deleted. This property cannot be changed with ExtendImmutabilityPolicy API."
+ }
+ },
+ "allowProtectedAppendWritesAll": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to both \"Append and Block Blobs\" while maintaining immutability protection and compliance. Only new blocks can be added and any existing blocks cannot be modified or deleted. This property cannot be changed with ExtendImmutabilityPolicy API. The \"allowProtectedAppendWrites\" and \"allowProtectedAppendWritesAll\" properties are mutually exclusive."
+ }
+ }
+ },
+ "resources": [
+ {
+ "type": "Microsoft.Storage/storageAccounts/blobServices/containers/immutabilityPolicies",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}/{1}/{2}/{3}', parameters('storageAccountName'), 'default', parameters('containerName'), 'default')]",
+ "properties": {
+ "immutabilityPeriodSinceCreationInDays": "[parameters('immutabilityPeriodSinceCreationInDays')]",
+ "allowProtectedAppendWrites": "[parameters('allowProtectedAppendWrites')]",
+ "allowProtectedAppendWritesAll": "[parameters('allowProtectedAppendWritesAll')]"
+ }
+ }
+ ],
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the deployed immutability policy."
+ },
+ "value": "default"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the deployed immutability policy."
+ },
+ "value": "[resourceId('Microsoft.Storage/storageAccounts/blobServices/containers/immutabilityPolicies', parameters('storageAccountName'), 'default', parameters('containerName'), 'default')]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group of the deployed immutability policy."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "container",
+ "storageAccount"
+ ]
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the deployed container."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the deployed container."
+ },
+ "value": "[resourceId('Microsoft.Storage/storageAccounts/blobServices/containers', parameters('storageAccountName'), 'default', parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group of the deployed container."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "storageAccount"
+ ]
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the deployed blob service."
+ },
+ "value": "[variables('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the deployed blob service."
+ },
+ "value": "[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccountName'), variables('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the deployed blob service."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "storageAccount"
+ ]
+ },
+ "storageAccount_fileServices": {
+ "condition": "[not(empty(parameters('fileServices')))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Storage-FileServices', uniqueString(deployment().name, parameters('location')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "storageAccountName": {
+ "value": "[parameters('name')]"
+ },
+ "diagnosticSettings": {
+ "value": "[tryGet(parameters('fileServices'), 'diagnosticSettings')]"
+ },
+ "protocolSettings": {
+ "value": "[tryGet(parameters('fileServices'), 'protocolSettings')]"
+ },
+ "shareDeleteRetentionPolicy": {
+ "value": "[tryGet(parameters('fileServices'), 'shareDeleteRetentionPolicy')]"
+ },
+ "shares": {
+ "value": "[tryGet(parameters('fileServices'), 'shares')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.26.170.59819",
+ "templateHash": "4306536926065797375"
+ },
+ "name": "Storage Account File Share Services",
+ "description": "This module deploys a Storage Account File Share Service.",
+ "owner": "Azure/module-maintainers"
+ },
+ "definitions": {
+ "diagnosticSettingType": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of diagnostic setting."
+ }
+ },
+ "logCategoriesAndGroups": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "category": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of a Diagnostic Log category for a resource type this setting is applied to. Set the specific logs to collect here."
+ }
+ },
+ "categoryGroup": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of a Diagnostic Log category group for a resource type this setting is applied to. Set to `allLogs` to collect all logs."
+ }
+ },
+ "enabled": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable or disable the category explicitly. Default is `true`."
+ }
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of logs that will be streamed. \"allLogs\" includes all possible logs for the resource. Set to `[]` to disable log collection."
+ }
+ },
+ "metricCategories": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "category": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of a Diagnostic Metric category for a resource type this setting is applied to. Set to `AllMetrics` to collect all metrics."
+ }
+ },
+ "enabled": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable or disable the category explicitly. Default is `true`."
+ }
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of logs that will be streamed. \"allLogs\" includes all possible logs for the resource. Set to `[]` to disable log collection."
+ }
+ },
+ "logAnalyticsDestinationType": {
+ "type": "string",
+ "allowedValues": [
+ "AzureDiagnostics",
+ "Dedicated"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type."
+ }
+ },
+ "workspaceResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic log analytics workspace. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "storageAccountResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic storage account. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "eventHubAuthorizationRuleResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to."
+ }
+ },
+ "eventHubName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of the diagnostic event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "marketplacePartnerResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The full ARM resource ID of the Marketplace resource to which you would like to send Diagnostic Logs."
+ }
+ }
+ }
+ },
+ "nullable": true
+ }
+ },
+ "parameters": {
+ "storageAccountName": {
+ "type": "string",
+ "maxLength": 24,
+ "metadata": {
+ "description": "Conditional. The name of the parent Storage Account. Required if the template is used in a standalone deployment."
+ }
+ },
+ "name": {
+ "type": "string",
+ "defaultValue": "default",
+ "metadata": {
+ "description": "Optional. The name of the file service."
+ }
+ },
+ "protocolSettings": {
+ "type": "object",
+ "defaultValue": {},
+ "metadata": {
+ "description": "Optional. Protocol settings for file service."
+ }
+ },
+ "shareDeleteRetentionPolicy": {
+ "type": "object",
+ "defaultValue": {
+ "enabled": true,
+ "days": 7
+ },
+ "metadata": {
+ "description": "Optional. The service properties for soft delete."
+ }
+ },
+ "diagnosticSettings": {
+ "$ref": "#/definitions/diagnosticSettingType",
+ "metadata": {
+ "description": "Optional. The diagnostic settings of the service."
+ }
+ },
+ "shares": {
+ "type": "array",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. File shares to create."
+ }
+ }
+ },
+ "resources": {
+ "storageAccount": {
+ "existing": true,
+ "type": "Microsoft.Storage/storageAccounts",
+ "apiVersion": "2021-09-01",
+ "name": "[parameters('storageAccountName')]"
+ },
+ "fileServices": {
+ "type": "Microsoft.Storage/storageAccounts/fileServices",
+ "apiVersion": "2021-09-01",
+ "name": "[format('{0}/{1}', parameters('storageAccountName'), parameters('name'))]",
+ "properties": {
+ "protocolSettings": "[parameters('protocolSettings')]",
+ "shareDeleteRetentionPolicy": "[parameters('shareDeleteRetentionPolicy')]"
+ },
+ "dependsOn": [
+ "storageAccount"
+ ]
+ },
+ "fileServices_diagnosticSettings": {
+ "copy": {
+ "name": "fileServices_diagnosticSettings",
+ "count": "[length(coalesce(parameters('diagnosticSettings'), createArray()))]"
+ },
+ "type": "Microsoft.Insights/diagnosticSettings",
+ "apiVersion": "2021-05-01-preview",
+ "scope": "[format('Microsoft.Storage/storageAccounts/{0}/fileServices/{1}', parameters('storageAccountName'), parameters('name'))]",
+ "name": "[coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'name'), format('{0}-diagnosticSettings', parameters('name')))]",
+ "properties": {
+ "copy": [
+ {
+ "name": "metrics",
+ "count": "[length(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics'))))]",
+ "input": {
+ "category": "[coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics')))[copyIndex('metrics')].category]",
+ "enabled": "[coalesce(tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics')))[copyIndex('metrics')], 'enabled'), true())]",
+ "timeGrain": null
+ }
+ },
+ {
+ "name": "logs",
+ "count": "[length(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs'))))]",
+ "input": {
+ "categoryGroup": "[tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'categoryGroup')]",
+ "category": "[tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'category')]",
+ "enabled": "[coalesce(tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'enabled'), true())]"
+ }
+ }
+ ],
+ "storageAccountId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'storageAccountResourceId')]",
+ "workspaceId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'workspaceResourceId')]",
+ "eventHubAuthorizationRuleId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'eventHubAuthorizationRuleResourceId')]",
+ "eventHubName": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'eventHubName')]",
+ "marketplacePartnerId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'marketplacePartnerResourceId')]",
+ "logAnalyticsDestinationType": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logAnalyticsDestinationType')]"
+ },
+ "dependsOn": [
+ "fileServices"
+ ]
+ },
+ "fileServices_shares": {
+ "copy": {
+ "name": "fileServices_shares",
+ "count": "[length(coalesce(parameters('shares'), createArray()))]"
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-shares-{1}', deployment().name, copyIndex())]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "storageAccountName": {
+ "value": "[parameters('storageAccountName')]"
+ },
+ "fileServicesName": {
+ "value": "[parameters('name')]"
+ },
+ "name": {
+ "value": "[coalesce(parameters('shares'), createArray())[copyIndex()].name]"
+ },
+ "accessTier": {
+ "value": "[coalesce(tryGet(coalesce(parameters('shares'), createArray())[copyIndex()], 'accessTier'), if(equals(reference('storageAccount', '2021-09-01', 'full').kind, 'FileStorage'), 'Premium', 'TransactionOptimized'))]"
+ },
+ "enabledProtocols": {
+ "value": "[tryGet(coalesce(parameters('shares'), createArray())[copyIndex()], 'enabledProtocols')]"
+ },
+ "rootSquash": {
+ "value": "[tryGet(coalesce(parameters('shares'), createArray())[copyIndex()], 'rootSquash')]"
+ },
+ "shareQuota": {
+ "value": "[tryGet(coalesce(parameters('shares'), createArray())[copyIndex()], 'shareQuota')]"
+ },
+ "roleAssignments": {
+ "value": "[tryGet(coalesce(parameters('shares'), createArray())[copyIndex()], 'roleAssignments')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.26.170.59819",
+ "templateHash": "13618261904162439978"
+ },
+ "name": "Storage Account File Shares",
+ "description": "This module deploys a Storage Account File Share.",
+ "owner": "Azure/module-maintainers"
+ },
+ "definitions": {
+ "roleAssignmentType": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "roleDefinitionIdOrName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The role to assign. You can provide either the display name of the role definition, the role definition GUID, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'."
+ }
+ },
+ "principalId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The principal ID of the principal (user/group/identity) to assign the role to."
+ }
+ },
+ "principalType": {
+ "type": "string",
+ "allowedValues": [
+ "Device",
+ "ForeignGroup",
+ "Group",
+ "ServicePrincipal",
+ "User"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The principal type of the assigned principal ID."
+ }
+ },
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The description of the role assignment."
+ }
+ },
+ "condition": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase \"foo_storage_container\"."
+ }
+ },
+ "conditionVersion": {
+ "type": "string",
+ "allowedValues": [
+ "2.0"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Version of the condition."
+ }
+ },
+ "delegatedManagedIdentityResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The Resource Id of the delegated managed identity resource."
+ }
+ }
+ }
+ },
+ "nullable": true
+ }
+ },
+ "parameters": {
+ "storageAccountName": {
+ "type": "string",
+ "maxLength": 24,
+ "metadata": {
+ "description": "Conditional. The name of the parent Storage Account. Required if the template is used in a standalone deployment."
+ }
+ },
+ "fileServicesName": {
+ "type": "string",
+ "defaultValue": "default",
+ "metadata": {
+ "description": "Conditional. The name of the parent file service. Required if the template is used in a standalone deployment."
+ }
+ },
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the file share to create."
+ }
+ },
+ "accessTier": {
+ "type": "string",
+ "defaultValue": "TransactionOptimized",
+ "allowedValues": [
+ "Premium",
+ "Hot",
+ "Cool",
+ "TransactionOptimized"
+ ],
+ "metadata": {
+ "description": "Conditional. Access tier for specific share. Required if the Storage Account kind is set to FileStorage (should be set to \"Premium\"). GpV2 account can choose between TransactionOptimized (default), Hot, and Cool."
+ }
+ },
+ "shareQuota": {
+ "type": "int",
+ "defaultValue": 5120,
+ "metadata": {
+ "description": "Optional. The maximum size of the share, in gigabytes. Must be greater than 0, and less than or equal to 5120 (5TB). For Large File Shares, the maximum size is 102400 (100TB)."
+ }
+ },
+ "enabledProtocols": {
+ "type": "string",
+ "defaultValue": "SMB",
+ "allowedValues": [
+ "NFS",
+ "SMB"
+ ],
+ "metadata": {
+ "description": "Optional. The authentication protocol that is used for the file share. Can only be specified when creating a share."
+ }
+ },
+ "rootSquash": {
+ "type": "string",
+ "defaultValue": "NoRootSquash",
+ "allowedValues": [
+ "AllSquash",
+ "NoRootSquash",
+ "RootSquash"
+ ],
+ "metadata": {
+ "description": "Optional. Permissions for NFS file shares are enforced by the client OS rather than the Azure Files service. Toggling the root squash behavior reduces the rights of the root user for NFS shares."
+ }
+ },
+ "roleAssignments": {
+ "$ref": "#/definitions/roleAssignmentType",
+ "metadata": {
+ "description": "Optional. Array of role assignments to create."
+ }
+ }
+ },
+ "resources": {
+ "storageAccount::fileService": {
+ "existing": true,
+ "type": "Microsoft.Storage/storageAccounts/fileServices",
+ "apiVersion": "2021-09-01",
+ "name": "[format('{0}/{1}', parameters('storageAccountName'), parameters('fileServicesName'))]",
+ "dependsOn": [
+ "storageAccount"
+ ]
+ },
+ "storageAccount": {
+ "existing": true,
+ "type": "Microsoft.Storage/storageAccounts",
+ "apiVersion": "2021-09-01",
+ "name": "[parameters('storageAccountName')]"
+ },
+ "fileShare": {
+ "type": "Microsoft.Storage/storageAccounts/fileServices/shares",
+ "apiVersion": "2023-01-01",
+ "name": "[format('{0}/{1}/{2}', parameters('storageAccountName'), parameters('fileServicesName'), parameters('name'))]",
+ "properties": {
+ "accessTier": "[parameters('accessTier')]",
+ "shareQuota": "[parameters('shareQuota')]",
+ "rootSquash": "[if(equals(parameters('enabledProtocols'), 'NFS'), parameters('rootSquash'), null())]",
+ "enabledProtocols": "[parameters('enabledProtocols')]"
+ },
+ "dependsOn": [
+ "storageAccount::fileService"
+ ]
+ },
+ "fileShare_roleAssignments": {
+ "condition": "[not(empty(parameters('roleAssignments')))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Share-Rbac', uniqueString(deployment().name))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "fileShareResourceId": {
+ "value": "[resourceId('Microsoft.Storage/storageAccounts/fileServices/shares', parameters('storageAccountName'), parameters('fileServicesName'), parameters('name'))]"
+ },
+ "roleAssignments": {
+ "value": "[parameters('roleAssignments')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.26.170.59819",
+ "templateHash": "6057169747302051267"
+ }
+ },
+ "parameters": {
+ "roleAssignments": {
+ "type": "array",
+ "metadata": {
+ "description": "Optional. Array of role assignments to create."
+ }
+ },
+ "fileShareResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The resource id of the file share to assign the roles to."
+ }
+ }
+ },
+ "variables": {
+ "$fxv#0": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "parameters": {
+ "scope": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The scope to deploy the role assignment to."
+ }
+ },
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the role assignment."
+ }
+ },
+ "roleDefinitionId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The role definition Id to assign."
+ }
+ },
+ "principalId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The principal ID of the principal (user/group/identity) to assign the role to."
+ }
+ },
+ "principalType": {
+ "type": "string",
+ "allowedValues": [
+ "Device",
+ "ForeignGroup",
+ "Group",
+ "ServicePrincipal",
+ "User",
+ ""
+ ],
+ "defaultValue": "",
+ "metadata": {
+ "description": "Optional. The principal type of the assigned principal ID."
+ }
+ },
+ "description": {
+ "type": "string",
+ "defaultValue": "",
+ "metadata": {
+ "description": "Optional. The description of the role assignment."
+ }
+ },
+ "condition": {
+ "type": "string",
+ "defaultValue": "",
+ "metadata": {
+ "description": "Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase \"foo_storage_container\""
+ }
+ },
+ "conditionVersion": {
+ "type": "string",
+ "allowedValues": [
+ "2.0"
+ ],
+ "defaultValue": "2.0",
+ "metadata": {
+ "description": "Optional. Version of the condition."
+ }
+ },
+ "delegatedManagedIdentityResourceId": {
+ "type": "string",
+ "defaultValue": "",
+ "metadata": {
+ "description": "Optional. The Resource Id of the delegated managed identity resource."
+ }
+ }
+ },
+ "resources": [
+ {
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[[parameters('scope')]",
+ "name": "[[parameters('name')]",
+ "properties": {
+ "roleDefinitionId": "[[parameters('roleDefinitionId')]",
+ "principalId": "[[parameters('principalId')]",
+ "description": "[[parameters('description')]",
+ "principalType": "[[if(not(empty(parameters('principalType'))), parameters('principalType'), null())]",
+ "condition": "[[if(not(empty(parameters('condition'))), parameters('condition'), null())]",
+ "conditionVersion": "[[if(and(not(empty(parameters('conditionVersion'))), not(empty(parameters('condition')))), parameters('conditionVersion'), null())]",
+ "delegatedManagedIdentityResourceId": "[[if(not(empty(parameters('delegatedManagedIdentityResourceId'))), parameters('delegatedManagedIdentityResourceId'), null())]"
+ }
+ }
+ ]
+ },
+ "builtInRoleNames": {
+ "Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
+ "Owner": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]",
+ "Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'acdd72a7-3385-48ef-bd42-f606fba81ae7')]",
+ "Reader and Data Access": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'c12c1c16-33a1-487b-954d-41c89c60f349')]",
+ "Role Based Access Control Administrator (Preview)": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'f58310d9-a9f6-439a-9e8d-f62e7b41a168')]",
+ "Storage Account Backup Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'e5e2a7ff-d759-4cd2-bb51-3152d37e2eb1')]",
+ "Storage Account Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '17d1049b-9a84-46fb-8f53-869881c3d3ab')]",
+ "Storage Account Key Operator Service Role": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '81a9662b-bebf-436f-a333-f67b29880f12')]",
+ "Storage File Data SMB Share Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '0c867c2a-1d8c-454a-a3db-ab2ea1bdc8bb')]",
+ "Storage File Data SMB Share Elevated Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'a7264617-510b-434b-a828-9731dc254ea7')]",
+ "Storage File Data SMB Share Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'aba4ae5f-2193-4029-9191-0cb91df5e314')]",
+ "User Access Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '18d7d88d-d35e-4fb5-a5c3-7773c20a72d9')]"
+ }
+ },
+ "resources": [
+ {
+ "copy": {
+ "name": "fileShare_roleAssignments",
+ "count": "[length(coalesce(parameters('roleAssignments'), createArray()))]"
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2021-04-01",
+ "name": "[format('{0}-Share-Rbac-{1}', uniqueString(deployment().name), copyIndex())]",
+ "properties": {
+ "mode": "Incremental",
+ "expressionEvaluationOptions": {
+ "scope": "Outer"
+ },
+ "template": "[variables('$fxv#0')]",
+ "parameters": {
+ "scope": {
+ "value": "[replace(parameters('fileShareResourceId'), '/shares/', '/fileShares/')]"
+ },
+ "name": {
+ "value": "[guid(parameters('fileShareResourceId'), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].principalId, coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName, 'tyfa')]"
+ },
+ "roleDefinitionId": {
+ "value": "[if(contains(variables('builtInRoleNames'), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName), variables('builtInRoleNames')[coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName], if(contains(coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/'), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName)))]"
+ },
+ "principalId": {
+ "value": "[coalesce(parameters('roleAssignments'), createArray())[copyIndex()].principalId]"
+ },
+ "principalType": {
+ "value": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'principalType')]"
+ },
+ "description": {
+ "value": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'description')]"
+ },
+ "condition": {
+ "value": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'condition')]"
+ },
+ "conditionVersion": {
+ "value": "[if(not(empty(tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'condition'))), coalesce(tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'conditionVersion'), '2.0'), null())]"
+ },
+ "delegatedManagedIdentityResourceId": {
+ "value": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'delegatedManagedIdentityResourceId')]"
+ }
+ }
+ }
+ }
+ ]
+ }
+ },
+ "dependsOn": [
+ "fileShare"
+ ]
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the deployed file share."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the deployed file share."
+ },
+ "value": "[resourceId('Microsoft.Storage/storageAccounts/fileServices/shares', parameters('storageAccountName'), parameters('fileServicesName'), parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group of the deployed file share."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "fileServices",
+ "storageAccount"
+ ]
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the deployed file share service."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the deployed file share service."
+ },
+ "value": "[resourceId('Microsoft.Storage/storageAccounts/fileServices', parameters('storageAccountName'), parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group of the deployed file share service."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "storageAccount"
+ ]
+ },
+ "storageAccount_queueServices": {
+ "condition": "[not(empty(parameters('queueServices')))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Storage-QueueServices', uniqueString(deployment().name, parameters('location')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "storageAccountName": {
+ "value": "[parameters('name')]"
+ },
+ "diagnosticSettings": {
+ "value": "[tryGet(parameters('queueServices'), 'diagnosticSettings')]"
+ },
+ "queues": {
+ "value": "[tryGet(parameters('queueServices'), 'queues')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.26.170.59819",
+ "templateHash": "4494965320132257914"
+ },
+ "name": "Storage Account Queue Services",
+ "description": "This module deploys a Storage Account Queue Service.",
+ "owner": "Azure/module-maintainers"
+ },
+ "definitions": {
+ "diagnosticSettingType": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of diagnostic setting."
+ }
+ },
+ "logCategoriesAndGroups": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "category": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of a Diagnostic Log category for a resource type this setting is applied to. Set the specific logs to collect here."
+ }
+ },
+ "categoryGroup": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of a Diagnostic Log category group for a resource type this setting is applied to. Set to `allLogs` to collect all logs."
+ }
+ },
+ "enabled": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable or disable the category explicitly. Default is `true`."
+ }
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of logs that will be streamed. \"allLogs\" includes all possible logs for the resource. Set to `[]` to disable log collection."
+ }
+ },
+ "metricCategories": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "category": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of a Diagnostic Metric category for a resource type this setting is applied to. Set to `AllMetrics` to collect all metrics."
+ }
+ },
+ "enabled": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable or disable the category explicitly. Default is `true`."
+ }
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of logs that will be streamed. \"allLogs\" includes all possible logs for the resource. Set to `[]` to disable log collection."
+ }
+ },
+ "logAnalyticsDestinationType": {
+ "type": "string",
+ "allowedValues": [
+ "AzureDiagnostics",
+ "Dedicated"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type."
+ }
+ },
+ "workspaceResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic log analytics workspace. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "storageAccountResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic storage account. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "eventHubAuthorizationRuleResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to."
+ }
+ },
+ "eventHubName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of the diagnostic event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "marketplacePartnerResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The full ARM resource ID of the Marketplace resource to which you would like to send Diagnostic Logs."
+ }
+ }
+ }
+ },
+ "nullable": true
+ }
+ },
+ "parameters": {
+ "storageAccountName": {
+ "type": "string",
+ "maxLength": 24,
+ "metadata": {
+ "description": "Conditional. The name of the parent Storage Account. Required if the template is used in a standalone deployment."
+ }
+ },
+ "queues": {
+ "type": "array",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Queues to create."
+ }
+ },
+ "diagnosticSettings": {
+ "$ref": "#/definitions/diagnosticSettingType",
+ "metadata": {
+ "description": "Optional. The diagnostic settings of the service."
+ }
+ }
+ },
+ "variables": {
+ "name": "default"
+ },
+ "resources": {
+ "storageAccount": {
+ "existing": true,
+ "type": "Microsoft.Storage/storageAccounts",
+ "apiVersion": "2021-09-01",
+ "name": "[parameters('storageAccountName')]"
+ },
+ "queueServices": {
+ "type": "Microsoft.Storage/storageAccounts/queueServices",
+ "apiVersion": "2021-09-01",
+ "name": "[format('{0}/{1}', parameters('storageAccountName'), variables('name'))]",
+ "properties": {},
+ "dependsOn": [
+ "storageAccount"
+ ]
+ },
+ "queueServices_diagnosticSettings": {
+ "copy": {
+ "name": "queueServices_diagnosticSettings",
+ "count": "[length(coalesce(parameters('diagnosticSettings'), createArray()))]"
+ },
+ "type": "Microsoft.Insights/diagnosticSettings",
+ "apiVersion": "2021-05-01-preview",
+ "scope": "[format('Microsoft.Storage/storageAccounts/{0}/queueServices/{1}', parameters('storageAccountName'), variables('name'))]",
+ "name": "[coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'name'), format('{0}-diagnosticSettings', variables('name')))]",
+ "properties": {
+ "copy": [
+ {
+ "name": "metrics",
+ "count": "[length(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics'))))]",
+ "input": {
+ "category": "[coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics')))[copyIndex('metrics')].category]",
+ "enabled": "[coalesce(tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics')))[copyIndex('metrics')], 'enabled'), true())]",
+ "timeGrain": null
+ }
+ },
+ {
+ "name": "logs",
+ "count": "[length(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs'))))]",
+ "input": {
+ "categoryGroup": "[tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'categoryGroup')]",
+ "category": "[tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'category')]",
+ "enabled": "[coalesce(tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'enabled'), true())]"
+ }
+ }
+ ],
+ "storageAccountId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'storageAccountResourceId')]",
+ "workspaceId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'workspaceResourceId')]",
+ "eventHubAuthorizationRuleId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'eventHubAuthorizationRuleResourceId')]",
+ "eventHubName": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'eventHubName')]",
+ "marketplacePartnerId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'marketplacePartnerResourceId')]",
+ "logAnalyticsDestinationType": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logAnalyticsDestinationType')]"
+ },
+ "dependsOn": [
+ "queueServices"
+ ]
+ },
+ "queueServices_queues": {
+ "copy": {
+ "name": "queueServices_queues",
+ "count": "[length(coalesce(parameters('queues'), createArray()))]"
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Queue-{1}', deployment().name, copyIndex())]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "storageAccountName": {
+ "value": "[parameters('storageAccountName')]"
+ },
+ "name": {
+ "value": "[coalesce(parameters('queues'), createArray())[copyIndex()].name]"
+ },
+ "metadata": {
+ "value": "[tryGet(coalesce(parameters('queues'), createArray())[copyIndex()], 'metadata')]"
+ },
+ "roleAssignments": {
+ "value": "[tryGet(coalesce(parameters('queues'), createArray())[copyIndex()], 'roleAssignments')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.26.170.59819",
+ "templateHash": "2870814699283520878"
+ },
+ "name": "Storage Account Queues",
+ "description": "This module deploys a Storage Account Queue.",
+ "owner": "Azure/module-maintainers"
+ },
+ "definitions": {
+ "roleAssignmentType": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "roleDefinitionIdOrName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The role to assign. You can provide either the display name of the role definition, the role definition GUID, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'."
+ }
+ },
+ "principalId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The principal ID of the principal (user/group/identity) to assign the role to."
+ }
+ },
+ "principalType": {
+ "type": "string",
+ "allowedValues": [
+ "Device",
+ "ForeignGroup",
+ "Group",
+ "ServicePrincipal",
+ "User"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The principal type of the assigned principal ID."
+ }
+ },
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The description of the role assignment."
+ }
+ },
+ "condition": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase \"foo_storage_container\"."
+ }
+ },
+ "conditionVersion": {
+ "type": "string",
+ "allowedValues": [
+ "2.0"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Version of the condition."
+ }
+ },
+ "delegatedManagedIdentityResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The Resource Id of the delegated managed identity resource."
+ }
+ }
+ }
+ },
+ "nullable": true
+ }
+ },
+ "parameters": {
+ "storageAccountName": {
+ "type": "string",
+ "maxLength": 24,
+ "metadata": {
+ "description": "Conditional. The name of the parent Storage Account. Required if the template is used in a standalone deployment."
+ }
+ },
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the storage queue to deploy."
+ }
+ },
+ "metadata": {
+ "type": "object",
+ "defaultValue": {},
+ "metadata": {
+ "description": "Required. A name-value pair that represents queue metadata."
+ }
+ },
+ "roleAssignments": {
+ "$ref": "#/definitions/roleAssignmentType",
+ "metadata": {
+ "description": "Optional. Array of role assignments to create."
+ }
+ }
+ },
+ "variables": {
+ "builtInRoleNames": {
+ "Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
+ "Owner": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]",
+ "Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'acdd72a7-3385-48ef-bd42-f606fba81ae7')]",
+ "Reader and Data Access": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'c12c1c16-33a1-487b-954d-41c89c60f349')]",
+ "Role Based Access Control Administrator (Preview)": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'f58310d9-a9f6-439a-9e8d-f62e7b41a168')]",
+ "Storage Account Backup Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'e5e2a7ff-d759-4cd2-bb51-3152d37e2eb1')]",
+ "Storage Account Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '17d1049b-9a84-46fb-8f53-869881c3d3ab')]",
+ "Storage Account Key Operator Service Role": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '81a9662b-bebf-436f-a333-f67b29880f12')]",
+ "Storage Queue Data Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '974c5e8b-45b9-4653-ba55-5f855dd0fb88')]",
+ "Storage Queue Data Message Processor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '8a0f0c08-91a1-4084-bc3d-661d67233fed')]",
+ "Storage Queue Data Message Sender": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'c6a89b2d-59bc-44d0-9896-0f6e12d7b80a')]",
+ "Storage Queue Data Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '19e7f393-937e-4f77-808e-94535e297925')]",
+ "User Access Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '18d7d88d-d35e-4fb5-a5c3-7773c20a72d9')]"
+ }
+ },
+ "resources": {
+ "storageAccount::queueServices": {
+ "existing": true,
+ "type": "Microsoft.Storage/storageAccounts/queueServices",
+ "apiVersion": "2021-09-01",
+ "name": "[format('{0}/{1}', parameters('storageAccountName'), 'default')]",
+ "dependsOn": [
+ "storageAccount"
+ ]
+ },
+ "storageAccount": {
+ "existing": true,
+ "type": "Microsoft.Storage/storageAccounts",
+ "apiVersion": "2021-09-01",
+ "name": "[parameters('storageAccountName')]"
+ },
+ "queue": {
+ "type": "Microsoft.Storage/storageAccounts/queueServices/queues",
+ "apiVersion": "2021-09-01",
+ "name": "[format('{0}/{1}/{2}', parameters('storageAccountName'), 'default', parameters('name'))]",
+ "properties": {
+ "metadata": "[parameters('metadata')]"
+ },
+ "dependsOn": [
+ "storageAccount::queueServices"
+ ]
+ },
+ "queue_roleAssignments": {
+ "copy": {
+ "name": "queue_roleAssignments",
+ "count": "[length(coalesce(parameters('roleAssignments'), createArray()))]"
+ },
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Storage/storageAccounts/{0}/queueServices/{1}/queues/{2}', parameters('storageAccountName'), 'default', parameters('name'))]",
+ "name": "[guid(resourceId('Microsoft.Storage/storageAccounts/queueServices/queues', parameters('storageAccountName'), 'default', parameters('name')), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].principalId, coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName)]",
+ "properties": {
+ "roleDefinitionId": "[if(contains(variables('builtInRoleNames'), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName), variables('builtInRoleNames')[coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName], if(contains(coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/'), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName)))]",
+ "principalId": "[coalesce(parameters('roleAssignments'), createArray())[copyIndex()].principalId]",
+ "description": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'description')]",
+ "principalType": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'principalType')]",
+ "condition": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'condition')]",
+ "conditionVersion": "[if(not(empty(tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'condition'))), coalesce(tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'conditionVersion'), '2.0'), null())]",
+ "delegatedManagedIdentityResourceId": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'delegatedManagedIdentityResourceId')]"
+ },
+ "dependsOn": [
+ "queue"
+ ]
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the deployed queue."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the deployed queue."
+ },
+ "value": "[resourceId('Microsoft.Storage/storageAccounts/queueServices/queues', parameters('storageAccountName'), 'default', parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group of the deployed queue."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "storageAccount"
+ ]
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the deployed file share service."
+ },
+ "value": "[variables('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the deployed file share service."
+ },
+ "value": "[resourceId('Microsoft.Storage/storageAccounts/queueServices', parameters('storageAccountName'), variables('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group of the deployed file share service."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "storageAccount"
+ ]
+ },
+ "storageAccount_tableServices": {
+ "condition": "[not(empty(parameters('tableServices')))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Storage-TableServices', uniqueString(deployment().name, parameters('location')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "storageAccountName": {
+ "value": "[parameters('name')]"
+ },
+ "diagnosticSettings": {
+ "value": "[tryGet(parameters('tableServices'), 'diagnosticSettings')]"
+ },
+ "tables": {
+ "value": "[tryGet(parameters('tableServices'), 'tables')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.26.170.59819",
+ "templateHash": "6806949296172999226"
+ },
+ "name": "Storage Account Table Services",
+ "description": "This module deploys a Storage Account Table Service.",
+ "owner": "Azure/module-maintainers"
+ },
+ "definitions": {
+ "diagnosticSettingType": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of diagnostic setting."
+ }
+ },
+ "logCategoriesAndGroups": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "category": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of a Diagnostic Log category for a resource type this setting is applied to. Set the specific logs to collect here."
+ }
+ },
+ "categoryGroup": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of a Diagnostic Log category group for a resource type this setting is applied to. Set to `allLogs` to collect all logs."
+ }
+ },
+ "enabled": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable or disable the category explicitly. Default is `true`."
+ }
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of logs that will be streamed. \"allLogs\" includes all possible logs for the resource. Set to `[]` to disable log collection."
+ }
+ },
+ "metricCategories": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "category": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of a Diagnostic Metric category for a resource type this setting is applied to. Set to `AllMetrics` to collect all metrics."
+ }
+ },
+ "enabled": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable or disable the category explicitly. Default is `true`."
+ }
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of logs that will be streamed. \"allLogs\" includes all possible logs for the resource. Set to `[]` to disable log collection."
+ }
+ },
+ "logAnalyticsDestinationType": {
+ "type": "string",
+ "allowedValues": [
+ "AzureDiagnostics",
+ "Dedicated"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type."
+ }
+ },
+ "workspaceResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic log analytics workspace. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "storageAccountResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic storage account. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "eventHubAuthorizationRuleResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to."
+ }
+ },
+ "eventHubName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of the diagnostic event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "marketplacePartnerResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The full ARM resource ID of the Marketplace resource to which you would like to send Diagnostic Logs."
+ }
+ }
+ }
+ },
+ "nullable": true
+ }
+ },
+ "parameters": {
+ "storageAccountName": {
+ "type": "string",
+ "maxLength": 24,
+ "metadata": {
+ "description": "Conditional. The name of the parent Storage Account. Required if the template is used in a standalone deployment."
+ }
+ },
+ "tables": {
+ "type": "array",
+ "defaultValue": [],
+ "metadata": {
+ "description": "Optional. tables to create."
+ }
+ },
+ "diagnosticSettings": {
+ "$ref": "#/definitions/diagnosticSettingType",
+ "metadata": {
+ "description": "Optional. The diagnostic settings of the service."
+ }
+ }
+ },
+ "variables": {
+ "name": "default"
+ },
+ "resources": {
+ "storageAccount": {
+ "existing": true,
+ "type": "Microsoft.Storage/storageAccounts",
+ "apiVersion": "2021-09-01",
+ "name": "[parameters('storageAccountName')]"
+ },
+ "tableServices": {
+ "type": "Microsoft.Storage/storageAccounts/tableServices",
+ "apiVersion": "2021-09-01",
+ "name": "[format('{0}/{1}', parameters('storageAccountName'), variables('name'))]",
+ "properties": {},
+ "dependsOn": [
+ "storageAccount"
+ ]
+ },
+ "tableServices_diagnosticSettings": {
+ "copy": {
+ "name": "tableServices_diagnosticSettings",
+ "count": "[length(coalesce(parameters('diagnosticSettings'), createArray()))]"
+ },
+ "type": "Microsoft.Insights/diagnosticSettings",
+ "apiVersion": "2021-05-01-preview",
+ "scope": "[format('Microsoft.Storage/storageAccounts/{0}/tableServices/{1}', parameters('storageAccountName'), variables('name'))]",
+ "name": "[coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'name'), format('{0}-diagnosticSettings', variables('name')))]",
+ "properties": {
+ "copy": [
+ {
+ "name": "metrics",
+ "count": "[length(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics'))))]",
+ "input": {
+ "category": "[coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics')))[copyIndex('metrics')].category]",
+ "enabled": "[coalesce(tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics')))[copyIndex('metrics')], 'enabled'), true())]",
+ "timeGrain": null
+ }
+ },
+ {
+ "name": "logs",
+ "count": "[length(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs'))))]",
+ "input": {
+ "categoryGroup": "[tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'categoryGroup')]",
+ "category": "[tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'category')]",
+ "enabled": "[coalesce(tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'enabled'), true())]"
+ }
+ }
+ ],
+ "storageAccountId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'storageAccountResourceId')]",
+ "workspaceId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'workspaceResourceId')]",
+ "eventHubAuthorizationRuleId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'eventHubAuthorizationRuleResourceId')]",
+ "eventHubName": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'eventHubName')]",
+ "marketplacePartnerId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'marketplacePartnerResourceId')]",
+ "logAnalyticsDestinationType": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logAnalyticsDestinationType')]"
+ },
+ "dependsOn": [
+ "tableServices"
+ ]
+ },
+ "tableServices_tables": {
+ "copy": {
+ "name": "tableServices_tables",
+ "count": "[length(parameters('tables'))]"
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Table-{1}', deployment().name, copyIndex())]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "name": {
+ "value": "[parameters('tables')[copyIndex()].name]"
+ },
+ "storageAccountName": {
+ "value": "[parameters('storageAccountName')]"
+ },
+ "roleAssignments": {
+ "value": "[tryGet(parameters('tables')[copyIndex()], 'roleAssignments')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.26.170.59819",
+ "templateHash": "5583637725561111612"
+ },
+ "name": "Storage Account Table",
+ "description": "This module deploys a Storage Account Table.",
+ "owner": "Azure/module-maintainers"
+ },
+ "definitions": {
+ "roleAssignmentType": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "roleDefinitionIdOrName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The role to assign. You can provide either the display name of the role definition, the role definition GUID, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'."
+ }
+ },
+ "principalId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The principal ID of the principal (user/group/identity) to assign the role to."
+ }
+ },
+ "principalType": {
+ "type": "string",
+ "allowedValues": [
+ "Device",
+ "ForeignGroup",
+ "Group",
+ "ServicePrincipal",
+ "User"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The principal type of the assigned principal ID."
+ }
+ },
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The description of the role assignment."
+ }
+ },
+ "condition": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase \"foo_storage_container\"."
+ }
+ },
+ "conditionVersion": {
+ "type": "string",
+ "allowedValues": [
+ "2.0"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Version of the condition."
+ }
+ },
+ "delegatedManagedIdentityResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The Resource Id of the delegated managed identity resource."
+ }
+ }
+ }
+ },
+ "nullable": true
+ }
+ },
+ "parameters": {
+ "storageAccountName": {
+ "type": "string",
+ "maxLength": 24,
+ "metadata": {
+ "description": "Conditional. The name of the parent Storage Account. Required if the template is used in a standalone deployment."
+ }
+ },
+ "roleAssignments": {
+ "$ref": "#/definitions/roleAssignmentType",
+ "metadata": {
+ "description": "Optional. Array of role assignments to create."
+ }
+ },
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of the table."
+ }
+ }
+ },
+ "variables": {
+ "builtInRoleNames": {
+ "Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
+ "Owner": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]",
+ "Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'acdd72a7-3385-48ef-bd42-f606fba81ae7')]",
+ "Reader and Data Access": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'c12c1c16-33a1-487b-954d-41c89c60f349')]",
+ "Role Based Access Control Administrator (Preview)": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'f58310d9-a9f6-439a-9e8d-f62e7b41a168')]",
+ "Storage Account Backup Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'e5e2a7ff-d759-4cd2-bb51-3152d37e2eb1')]",
+ "Storage Account Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '17d1049b-9a84-46fb-8f53-869881c3d3ab')]",
+ "Storage Account Key Operator Service Role": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '81a9662b-bebf-436f-a333-f67b29880f12')]",
+ "Storage Table Data Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '0a9a7e1f-b9d0-4cc4-a60d-0319b160aaa3')]",
+ "Storage Table Data Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '76199698-9eea-4c19-bc75-cec21354c6b6')]",
+ "User Access Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '18d7d88d-d35e-4fb5-a5c3-7773c20a72d9')]"
+ }
+ },
+ "resources": {
+ "storageAccount::tableServices": {
+ "existing": true,
+ "type": "Microsoft.Storage/storageAccounts/tableServices",
+ "apiVersion": "2021-09-01",
+ "name": "[format('{0}/{1}', parameters('storageAccountName'), 'default')]",
+ "dependsOn": [
+ "storageAccount"
+ ]
+ },
+ "storageAccount": {
+ "existing": true,
+ "type": "Microsoft.Storage/storageAccounts",
+ "apiVersion": "2021-09-01",
+ "name": "[parameters('storageAccountName')]"
+ },
+ "table": {
+ "type": "Microsoft.Storage/storageAccounts/tableServices/tables",
+ "apiVersion": "2021-09-01",
+ "name": "[format('{0}/{1}/{2}', parameters('storageAccountName'), 'default', parameters('name'))]",
+ "dependsOn": [
+ "storageAccount::tableServices"
+ ]
+ },
+ "table_roleAssignments": {
+ "copy": {
+ "name": "table_roleAssignments",
+ "count": "[length(coalesce(parameters('roleAssignments'), createArray()))]"
+ },
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Storage/storageAccounts/{0}/tableServices/{1}/tables/{2}', parameters('storageAccountName'), 'default', parameters('name'))]",
+ "name": "[guid(resourceId('Microsoft.Storage/storageAccounts/tableServices/tables', parameters('storageAccountName'), 'default', parameters('name')), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].principalId, coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName)]",
+ "properties": {
+ "roleDefinitionId": "[if(contains(variables('builtInRoleNames'), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName), variables('builtInRoleNames')[coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName], if(contains(coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/'), coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', coalesce(parameters('roleAssignments'), createArray())[copyIndex()].roleDefinitionIdOrName)))]",
+ "principalId": "[coalesce(parameters('roleAssignments'), createArray())[copyIndex()].principalId]",
+ "description": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'description')]",
+ "principalType": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'principalType')]",
+ "condition": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'condition')]",
+ "conditionVersion": "[if(not(empty(tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'condition'))), coalesce(tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'conditionVersion'), '2.0'), null())]",
+ "delegatedManagedIdentityResourceId": "[tryGet(coalesce(parameters('roleAssignments'), createArray())[copyIndex()], 'delegatedManagedIdentityResourceId')]"
+ },
+ "dependsOn": [
+ "table"
+ ]
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the deployed file share service."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the deployed file share service."
+ },
+ "value": "[resourceId('Microsoft.Storage/storageAccounts/tableServices/tables', parameters('storageAccountName'), 'default', parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group of the deployed file share service."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "storageAccount"
+ ]
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the deployed table service."
+ },
+ "value": "[variables('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the deployed table service."
+ },
+ "value": "[resourceId('Microsoft.Storage/storageAccounts/tableServices', parameters('storageAccountName'), variables('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group of the deployed table service."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "storageAccount"
+ ]
+ }
+ },
+ "outputs": {
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the deployed storage account."
+ },
+ "value": "[resourceId('Microsoft.Storage/storageAccounts', parameters('name'))]"
+ },
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the deployed storage account."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group of the deployed storage account."
+ },
+ "value": "[resourceGroup().name]"
+ },
+ "primaryBlobEndpoint": {
+ "type": "string",
+ "metadata": {
+ "description": "The primary blob endpoint reference if blob services are deployed."
+ },
+ "value": "[if(and(not(empty(parameters('blobServices'))), contains(parameters('blobServices'), 'containers')), reference(format('Microsoft.Storage/storageAccounts/{0}', parameters('name')), '2019-04-01').primaryEndpoints.blob, '')]"
+ },
+ "systemAssignedMIPrincipalId": {
+ "type": "string",
+ "metadata": {
+ "description": "The principal ID of the system assigned identity."
+ },
+ "value": "[coalesce(tryGet(tryGet(reference('storageAccount', '2022-09-01', 'full'), 'identity'), 'principalId'), '')]"
+ },
+ "location": {
+ "type": "string",
+ "metadata": {
+ "description": "The location the resource was deployed into."
+ },
+ "value": "[reference('storageAccount', '2022-09-01', 'full').location]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "[subscriptionResourceId('Microsoft.Resources/resourceGroups', if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName'))))]"
+ ]
+ },
+ {
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2025-04-01",
+ "name": "[format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))]",
+ "resourceGroup": "[if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "location": {
+ "value": "[parameters('location')]"
+ },
+ "storageName": {
+ "value": "[format('stai{0}', variables('uniqueSuffix'))]"
+ },
+ "aiServicesName": {
+ "value": "[format('{0}{1}', parameters('aiServicesName'), variables('uniqueSuffix'))]"
+ },
+ "aiSearchName": {
+ "value": "[format('{0}{1}', parameters('aiSearchName'), variables('uniqueSuffix'))]"
+ },
+ "cosmosDbName": {
+ "value": "[format('{0}{1}', parameters('cosmosDbName'), variables('uniqueSuffix'))]"
+ },
+ "tags": {
+ "value": "[variables('tags')]"
+ },
+ "enableAzureSearch": {
+ "value": "[parameters('enableAzureSearch')]"
+ },
+ "enableCosmosDb": {
+ "value": "[parameters('enableCosmosDb')]"
+ },
+ "modelName": {
+ "value": "[parameters('modelName')]"
+ },
+ "modelFormat": {
+ "value": "[parameters('modelFormat')]"
+ },
+ "modelVersion": {
+ "value": "[parameters('modelVersion')]"
+ },
+ "modelSkuName": {
+ "value": "[parameters('modelSkuName')]"
+ },
+ "modelCapacity": {
+ "value": "[parameters('modelCapacity')]"
+ },
+ "modelDeploymentName": {
+ "value": "[parameters('modelDeploymentName')]"
+ },
+ "modelLocation": {
+ "value": "[parameters('location')]"
+ },
+ "aiServiceAccountResourceId": {
+ "value": "[parameters('aiServiceAccountResourceId')]"
+ },
+ "aiSearchServiceResourceId": {
+ "value": "[parameters('aiSearchServiceResourceId')]"
+ },
+ "aiStorageAccountResourceId": {
+ "value": "[parameters('aiStorageAccountResourceId')]"
+ },
+ "aiCosmosDbAccountResourceId": {
+ "value": "[parameters('aiCosmosDbAccountResourceId')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.39.26.7824",
+ "templateHash": "13311296745744941053"
+ }
+ },
+ "parameters": {
+ "location": {
+ "type": "string",
+ "defaultValue": "[resourceGroup().location]",
+ "metadata": {
+ "description": "Azure region of the deployment"
+ }
+ },
+ "tags": {
+ "type": "object",
+ "defaultValue": {},
+ "metadata": {
+ "description": "Tags to add to the resources"
+ }
+ },
+ "aiServicesName": {
+ "type": "string",
+ "metadata": {
+ "description": "AI services name"
+ }
+ },
+ "aiSearchName": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the AI Search resource"
+ }
+ },
+ "enableAzureSearch": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Enable Azure AI Search resource creation"
+ }
+ },
+ "cosmosDbName": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the Cosmos DB account"
+ }
+ },
+ "enableCosmosDb": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Enable Cosmos DB resource creation"
+ }
+ },
+ "storageName": {
+ "type": "string",
+ "metadata": {
+ "description": "Name of the storage account"
+ }
+ },
+ "modelName": {
+ "type": "string",
+ "metadata": {
+ "description": "Model name for deployment"
+ }
+ },
+ "modelFormat": {
+ "type": "string",
+ "metadata": {
+ "description": "Model format for deployment"
+ }
+ },
+ "modelVersion": {
+ "type": "string",
+ "metadata": {
+ "description": "Model version for deployment"
+ }
+ },
+ "modelSkuName": {
+ "type": "string",
+ "metadata": {
+ "description": "Model deployment SKU name"
+ }
+ },
+ "modelCapacity": {
+ "type": "int",
+ "metadata": {
+ "description": "Model deployment capacity"
+ }
+ },
+ "modelDeploymentName": {
+ "type": "string",
+ "defaultValue": "chat",
+ "metadata": {
+ "description": "Name for the model deployment in Azure AI Services"
+ }
+ },
+ "modelLocation": {
+ "type": "string",
+ "metadata": {
+ "description": "Model/AI Resource deployment location"
+ }
+ },
+ "aiServiceAccountResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The AI Service Account full ARM Resource ID. This is an optional field, and if not provided, the resource will be created."
+ }
+ },
+ "aiSearchServiceResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The AI Search Service full ARM Resource ID. This is an optional field, and if not provided, the resource will be created."
+ }
+ },
+ "aiStorageAccountResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The AI Storage Account full ARM Resource ID. This is an optional field, and if not provided, the resource will be created."
+ }
+ },
+ "aiCosmosDbAccountResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The AI Cosmos DB Account full ARM Resource ID. This is an optional field, and if not provided, the resource will be created."
+ }
+ },
+ "sku": {
+ "type": "string",
+ "defaultValue": "Standard_LRS"
+ }
+ },
+ "variables": {
+ "aiServiceExists": "[not(equals(parameters('aiServiceAccountResourceId'), ''))]",
+ "skipAzureSearchCreation": "[or(not(equals(parameters('aiSearchServiceResourceId'), '')), not(parameters('enableAzureSearch')))]",
+ "aiStorageExists": "[not(equals(parameters('aiStorageAccountResourceId'), ''))]",
+ "skipCosmosDbCreation": "[or(not(equals(parameters('aiCosmosDbAccountResourceId'), '')), not(parameters('enableCosmosDb')))]",
+ "canaryRegions": [
+ "eastus2euap",
+ "centraluseuap"
+ ],
+ "cosmosDbRegion": "[if(contains(variables('canaryRegions'), parameters('location')), 'eastus2', parameters('location'))]"
+ },
+ "resources": [
+ {
+ "condition": "[not(variables('aiServiceExists'))]",
+ "type": "Microsoft.CognitiveServices/accounts",
+ "apiVersion": "2025-04-01-preview",
+ "name": "[parameters('aiServicesName')]",
+ "location": "[parameters('modelLocation')]",
+ "sku": {
+ "name": "S0"
+ },
+ "kind": "AIServices",
+ "identity": {
+ "type": "SystemAssigned"
+ },
+ "properties": {
+ "allowProjectManagement": true,
+ "customSubDomainName": "[toLower(format('{0}', parameters('aiServicesName')))]",
+ "networkAcls": {
+ "defaultAction": "Allow",
+ "virtualNetworkRules": [],
+ "ipRules": []
+ },
+ "publicNetworkAccess": "Enabled",
+ "disableLocalAuth": true
+ }
+ },
+ {
+ "condition": "[not(variables('aiServiceExists'))]",
+ "type": "Microsoft.CognitiveServices/accounts/deployments",
+ "apiVersion": "2025-04-01-preview",
+ "name": "[format('{0}/{1}', parameters('aiServicesName'), parameters('modelDeploymentName'))]",
+ "sku": {
+ "capacity": "[parameters('modelCapacity')]",
+ "name": "[parameters('modelSkuName')]"
+ },
+ "properties": {
+ "model": {
+ "name": "[parameters('modelName')]",
+ "format": "[parameters('modelFormat')]",
+ "version": "[parameters('modelVersion')]"
+ }
+ },
+ "dependsOn": [
+ "[resourceId('Microsoft.CognitiveServices/accounts', parameters('aiServicesName'))]"
+ ]
+ },
+ {
+ "condition": "[not(variables('skipAzureSearchCreation'))]",
+ "type": "Microsoft.Search/searchServices",
+ "apiVersion": "2024-06-01-preview",
+ "name": "[parameters('aiSearchName')]",
+ "location": "[parameters('location')]",
+ "tags": "[parameters('tags')]",
+ "identity": {
+ "type": "SystemAssigned"
+ },
+ "properties": {
+ "disableLocalAuth": true,
+ "encryptionWithCmk": {
+ "enforcement": "Unspecified"
+ },
+ "hostingMode": "default",
+ "partitionCount": 1,
+ "publicNetworkAccess": "enabled",
+ "replicaCount": 1,
+ "semanticSearch": "disabled"
+ },
+ "sku": {
+ "name": "standard"
+ }
+ },
+ {
+ "condition": "[not(variables('aiStorageExists'))]",
+ "type": "Microsoft.Storage/storageAccounts",
+ "apiVersion": "2022-05-01",
+ "name": "[parameters('storageName')]",
+ "location": "[parameters('location')]",
+ "kind": "StorageV2",
+ "sku": {
+ "name": "[parameters('sku')]"
+ },
+ "properties": {
+ "minimumTlsVersion": "TLS1_2",
+ "allowBlobPublicAccess": false,
+ "publicNetworkAccess": "Enabled",
+ "networkAcls": {
+ "bypass": "AzureServices",
+ "defaultAction": "Allow",
+ "virtualNetworkRules": []
+ },
+ "allowSharedKeyAccess": false
+ }
+ },
+ {
+ "condition": "[not(variables('skipCosmosDbCreation'))]",
+ "type": "Microsoft.DocumentDB/databaseAccounts",
+ "apiVersion": "2024-11-15",
+ "name": "[parameters('cosmosDbName')]",
+ "location": "[variables('cosmosDbRegion')]",
+ "kind": "GlobalDocumentDB",
+ "properties": {
+ "consistencyPolicy": {
+ "defaultConsistencyLevel": "Session"
+ },
+ "disableLocalAuth": true,
+ "enableAutomaticFailover": false,
+ "enableMultipleWriteLocations": false,
+ "enableFreeTier": false,
+ "locations": [
+ {
+ "locationName": "[parameters('location')]",
+ "failoverPriority": 0,
+ "isZoneRedundant": false
+ }
+ ],
+ "databaseAccountOfferType": "Standard"
+ }
+ }
+ ],
+ "outputs": {
+ "aiServicesName": {
+ "type": "string",
+ "value": "[parameters('aiServicesName')]"
+ },
+ "aiservicesID": {
+ "type": "string",
+ "value": "[resourceId('Microsoft.CognitiveServices/accounts', parameters('aiServicesName'))]"
+ },
+ "aiServiceAccountResourceGroupName": {
+ "type": "string",
+ "value": "[resourceGroup().name]"
+ },
+ "aiServiceAccountSubscriptionId": {
+ "type": "string",
+ "value": "[subscription().subscriptionId]"
+ },
+ "aiSearchName": {
+ "type": "string",
+ "value": "[parameters('aiSearchName')]"
+ },
+ "aisearchID": {
+ "type": "string",
+ "value": "[if(not(variables('skipAzureSearchCreation')), resourceId('Microsoft.Search/searchServices', parameters('aiSearchName')), parameters('aiSearchServiceResourceId'))]"
+ },
+ "aiSearchServiceResourceGroupName": {
+ "type": "string",
+ "value": "[if(not(variables('skipAzureSearchCreation')), resourceGroup().name, '')]"
+ },
+ "aiSearchServiceSubscriptionId": {
+ "type": "string",
+ "value": "[if(not(variables('skipAzureSearchCreation')), subscription().subscriptionId, '')]"
+ },
+ "storageAccountName": {
+ "type": "string",
+ "value": "[parameters('storageName')]"
+ },
+ "storageId": {
+ "type": "string",
+ "value": "[if(not(variables('aiStorageExists')), resourceId('Microsoft.Storage/storageAccounts', parameters('storageName')), parameters('aiStorageAccountResourceId'))]"
+ },
+ "storageAccountResourceGroupName": {
+ "type": "string",
+ "value": "[if(not(variables('aiStorageExists')), resourceGroup().name, '')]"
+ },
+ "storageAccountSubscriptionId": {
+ "type": "string",
+ "value": "[if(not(variables('aiStorageExists')), subscription().subscriptionId, '')]"
+ },
+ "cosmosDbAccountName": {
+ "type": "string",
+ "value": "[parameters('cosmosDbName')]"
+ },
+ "cosmosDbAccountId": {
+ "type": "string",
+ "value": "[if(not(variables('skipCosmosDbCreation')), resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('cosmosDbName')), parameters('aiCosmosDbAccountResourceId'))]"
+ },
+ "cosmosDbAccountResourceGroupName": {
+ "type": "string",
+ "value": "[if(not(variables('skipCosmosDbCreation')), resourceGroup().name, '')]"
+ },
+ "cosmosDbAccountSubscriptionId": {
+ "type": "string",
+ "value": "[if(not(variables('skipCosmosDbCreation')), subscription().subscriptionId, '')]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "[subscriptionResourceId('Microsoft.Resources/resourceGroups', if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName'))))]"
+ ]
+ },
+ {
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2025-04-01",
+ "name": "[format('{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))]",
+ "resourceGroup": "[if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "aiServicesAccountName": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.aiServicesName.value]"
+ },
+ "aiProjectName": {
+ "value": "[format('{0}{1}', variables('projectName'), variables('uniqueSuffix'))]"
+ },
+ "aiProjectFriendlyName": {
+ "value": "[parameters('aiProjectFriendlyName')]"
+ },
+ "aiProjectDescription": {
+ "value": "[parameters('aiProjectDescription')]"
+ },
+ "location": {
+ "value": "[parameters('location')]"
+ },
+ "tags": {
+ "value": "[variables('tags')]"
+ },
+ "enableAzureSearch": {
+ "value": "[parameters('enableAzureSearch')]"
+ },
+ "enableCosmosDb": {
+ "value": "[parameters('enableCosmosDb')]"
+ },
+ "aiSearchName": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.aiSearchName.value]"
+ },
+ "aiSearchSubscriptionId": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.aiSearchServiceSubscriptionId.value]"
+ },
+ "aiSearchResourceGroupName": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.aiSearchServiceResourceGroupName.value]"
+ },
+ "storageAccountName": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.storageAccountName.value]"
+ },
+ "storageAccountSubscriptionId": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.storageAccountSubscriptionId.value]"
+ },
+ "storageAccountResourceGroupName": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.storageAccountResourceGroupName.value]"
+ },
+ "cosmosDbAccountName": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.cosmosDbAccountName.value]"
+ },
+ "cosmosDbAccountSubscriptionId": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.cosmosDbAccountSubscriptionId.value]"
+ },
+ "cosmosDbAccountResourceGroupName": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.cosmosDbAccountResourceGroupName.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.39.26.7824",
+ "templateHash": "2497409799563576473"
+ }
+ },
+ "parameters": {
+ "location": {
+ "type": "string",
+ "metadata": {
+ "description": "Azure region of the deployment"
+ }
+ },
+ "tags": {
+ "type": "object",
+ "metadata": {
+ "description": "Tags to add to the resources"
+ }
+ },
+ "aiServicesAccountName": {
+ "type": "string",
+ "metadata": {
+ "description": "AI Services Foundry account under which the project will be created"
+ }
+ },
+ "aiProjectName": {
+ "type": "string",
+ "metadata": {
+ "description": "AI Project name"
+ }
+ },
+ "aiProjectFriendlyName": {
+ "type": "string",
+ "defaultValue": "[parameters('aiProjectName')]",
+ "metadata": {
+ "description": "AI Project display name"
+ }
+ },
+ "aiProjectDescription": {
+ "type": "string",
+ "metadata": {
+ "description": "AI Project description"
+ }
+ },
+ "enableAzureSearch": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Enable Azure AI Search for vector store and search capabilities"
+ }
+ },
+ "enableCosmosDb": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Enable Cosmos DB for agent thread storage"
+ }
+ },
+ "cosmosDbAccountName": {
+ "type": "string",
+ "metadata": {
+ "description": "Cosmos DB Account for agent thread storage"
+ }
+ },
+ "cosmosDbAccountSubscriptionId": {
+ "type": "string"
+ },
+ "cosmosDbAccountResourceGroupName": {
+ "type": "string"
+ },
+ "storageAccountName": {
+ "type": "string",
+ "metadata": {
+ "description": "Storage Account for agent artifacts"
+ }
+ },
+ "storageAccountSubscriptionId": {
+ "type": "string"
+ },
+ "storageAccountResourceGroupName": {
+ "type": "string"
+ },
+ "aiSearchName": {
+ "type": "string",
+ "metadata": {
+ "description": "AI Search Service for vector store and search"
+ }
+ },
+ "aiSearchSubscriptionId": {
+ "type": "string"
+ },
+ "aiSearchResourceGroupName": {
+ "type": "string"
+ }
+ },
+ "resources": [
+ {
+ "condition": "[parameters('enableCosmosDb')]",
+ "type": "Microsoft.CognitiveServices/accounts/projects/connections",
+ "apiVersion": "2025-04-01-preview",
+ "name": "[format('{0}/{1}/{2}', parameters('aiServicesAccountName'), parameters('aiProjectName'), parameters('cosmosDbAccountName'))]",
+ "properties": {
+ "category": "CosmosDB",
+ "target": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', parameters('cosmosDbAccountSubscriptionId'), parameters('cosmosDbAccountResourceGroupName')), 'Microsoft.DocumentDB/databaseAccounts', parameters('cosmosDbAccountName')), '2024-11-15').documentEndpoint]",
+ "authType": "AAD",
+ "metadata": {
+ "ApiType": "Azure",
+ "ResourceId": "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', parameters('cosmosDbAccountSubscriptionId'), parameters('cosmosDbAccountResourceGroupName')), 'Microsoft.DocumentDB/databaseAccounts', parameters('cosmosDbAccountName'))]",
+ "location": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', parameters('cosmosDbAccountSubscriptionId'), parameters('cosmosDbAccountResourceGroupName')), 'Microsoft.DocumentDB/databaseAccounts', parameters('cosmosDbAccountName')), '2024-11-15', 'full').location]"
+ }
+ },
+ "dependsOn": [
+ "[resourceId('Microsoft.CognitiveServices/accounts/projects', parameters('aiServicesAccountName'), parameters('aiProjectName'))]"
+ ]
+ },
+ {
+ "type": "Microsoft.CognitiveServices/accounts/projects/connections",
+ "apiVersion": "2025-04-01-preview",
+ "name": "[format('{0}/{1}/{2}', parameters('aiServicesAccountName'), parameters('aiProjectName'), parameters('storageAccountName'))]",
+ "properties": {
+ "category": "AzureStorageAccount",
+ "target": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', parameters('storageAccountSubscriptionId'), parameters('storageAccountResourceGroupName')), 'Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2024-01-01').primaryEndpoints.blob]",
+ "authType": "AAD",
+ "metadata": {
+ "ApiType": "Azure",
+ "ResourceId": "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', parameters('storageAccountSubscriptionId'), parameters('storageAccountResourceGroupName')), 'Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]",
+ "location": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', parameters('storageAccountSubscriptionId'), parameters('storageAccountResourceGroupName')), 'Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2024-01-01', 'full').location]"
+ }
+ },
+ "dependsOn": [
+ "[resourceId('Microsoft.CognitiveServices/accounts/projects', parameters('aiServicesAccountName'), parameters('aiProjectName'))]"
+ ]
+ },
+ {
+ "condition": "[parameters('enableAzureSearch')]",
+ "type": "Microsoft.CognitiveServices/accounts/projects/connections",
+ "apiVersion": "2025-04-01-preview",
+ "name": "[format('{0}/{1}/{2}', parameters('aiServicesAccountName'), parameters('aiProjectName'), parameters('aiSearchName'))]",
+ "properties": {
+ "category": "CognitiveSearch",
+ "target": "[format('https://{0}.search.windows.net', parameters('aiSearchName'))]",
+ "authType": "AAD",
+ "metadata": {
+ "ApiType": "Azure",
+ "ResourceId": "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', parameters('aiSearchSubscriptionId'), parameters('aiSearchResourceGroupName')), 'Microsoft.Search/searchServices', parameters('aiSearchName'))]",
+ "location": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', parameters('aiSearchSubscriptionId'), parameters('aiSearchResourceGroupName')), 'Microsoft.Search/searchServices', parameters('aiSearchName')), '2024-06-01-preview', 'full').location]"
+ }
+ },
+ "dependsOn": [
+ "[resourceId('Microsoft.CognitiveServices/accounts/projects', parameters('aiServicesAccountName'), parameters('aiProjectName'))]"
+ ]
+ },
+ {
+ "type": "Microsoft.CognitiveServices/accounts/projects",
+ "apiVersion": "2025-04-01-preview",
+ "name": "[format('{0}/{1}', parameters('aiServicesAccountName'), parameters('aiProjectName'))]",
+ "location": "[parameters('location')]",
+ "tags": "[parameters('tags')]",
+ "identity": {
+ "type": "SystemAssigned"
+ },
+ "properties": {
+ "description": "[parameters('aiProjectDescription')]",
+ "displayName": "[parameters('aiProjectFriendlyName')]"
+ }
+ }
+ ],
+ "outputs": {
+ "aiProjectName": {
+ "type": "string",
+ "value": "[parameters('aiProjectName')]"
+ },
+ "aiProjectResourceId": {
+ "type": "string",
+ "value": "[resourceId('Microsoft.CognitiveServices/accounts/projects', parameters('aiServicesAccountName'), parameters('aiProjectName'))]"
+ },
+ "aiProjectPrincipalId": {
+ "type": "string",
+ "value": "[reference(resourceId('Microsoft.CognitiveServices/accounts/projects', parameters('aiServicesAccountName'), parameters('aiProjectName')), '2025-04-01-preview', 'full').identity.principalId]"
+ },
+ "aiSearchConnection": {
+ "type": "string",
+ "value": "[parameters('aiSearchName')]"
+ },
+ "azureStorageConnection": {
+ "type": "string",
+ "value": "[parameters('storageAccountName')]"
+ },
+ "cosmosDbConnection": {
+ "type": "string",
+ "value": "[parameters('cosmosDbAccountName')]"
+ },
+ "projectWorkspaceId": {
+ "type": "string",
+ "value": "[format('{0}-{1}-{2}-{3}-{4}', substring(reference(resourceId('Microsoft.CognitiveServices/accounts/projects', parameters('aiServicesAccountName'), parameters('aiProjectName')), '2025-04-01-preview').internalId, 0, 8), substring(reference(resourceId('Microsoft.CognitiveServices/accounts/projects', parameters('aiServicesAccountName'), parameters('aiProjectName')), '2025-04-01-preview').internalId, 8, 4), substring(reference(resourceId('Microsoft.CognitiveServices/accounts/projects', parameters('aiServicesAccountName'), parameters('aiProjectName')), '2025-04-01-preview').internalId, 12, 4), substring(reference(resourceId('Microsoft.CognitiveServices/accounts/projects', parameters('aiServicesAccountName'), parameters('aiProjectName')), '2025-04-01-preview').internalId, 16, 4), substring(reference(resourceId('Microsoft.CognitiveServices/accounts/projects', parameters('aiServicesAccountName'), parameters('aiProjectName')), '2025-04-01-preview').internalId, 20, 12))]"
+ },
+ "projectEndpoint": {
+ "type": "string",
+ "value": "[format('https://{0}.services.ai.azure.com/api/projects/{1}', parameters('aiServicesAccountName'), parameters('aiProjectName'))]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix')))]",
+ "[subscriptionResourceId('Microsoft.Resources/resourceGroups', if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName'))))]"
+ ]
+ },
+ {
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2025-04-01",
+ "name": "api",
+ "resourceGroup": "[if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "name": {
+ "value": "[variables('functionAppName')]"
+ },
+ "location": {
+ "value": "[parameters('location')]"
+ },
+ "tags": {
+ "value": "[variables('tags')]"
+ },
+ "applicationInsightsName": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('{0}-appinsights', uniqueString(deployment().name, parameters('location')))), '2025-04-01').outputs.name.value]"
+ },
+ "appServicePlanId": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'appserviceplan'), '2025-04-01').outputs.resourceId.value]"
+ },
+ "runtimeName": {
+ "value": "python"
+ },
+ "runtimeVersion": {
+ "value": "3.11"
+ },
+ "storageAccountName": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'storage'), '2025-04-01').outputs.name.value]"
+ },
+ "enableBlob": {
+ "value": "[variables('storageEndpointConfig').enableBlob]"
+ },
+ "enableQueue": {
+ "value": "[variables('storageEndpointConfig').enableQueue]"
+ },
+ "enableTable": {
+ "value": "[variables('storageEndpointConfig').enableTable]"
+ },
+ "deploymentStorageContainerName": {
+ "value": "[variables('deploymentStorageContainerName')]"
+ },
+ "identityId": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'apiUserAssignedIdentity'), '2025-04-01').outputs.resourceId.value]"
+ },
+ "identityClientId": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'apiUserAssignedIdentity'), '2025-04-01').outputs.clientId.value]"
+ },
+ "appSettings": {
+ "value": {
+ "PROJECT_ENDPOINT": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.projectEndpoint.value]",
+ "MODEL_DEPLOYMENT_NAME": "[parameters('modelDeploymentName')]",
+ "AZURE_OPENAI_ENDPOINT": "[format('https://{0}.openai.azure.com/', reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.aiServicesName.value)]",
+ "AZURE_OPENAI_DEPLOYMENT_NAME": "[parameters('modelDeploymentName')]",
+ "AZURE_CLIENT_ID": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'apiUserAssignedIdentity'), '2025-04-01').outputs.clientId.value]",
+ "STORAGE_CONNECTION__queueServiceUri": "[format('https://{0}.queue.{1}', reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'storage'), '2025-04-01').outputs.name.value, environment().suffixes.storage)]",
+ "STORAGE_CONNECTION__clientId": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'apiUserAssignedIdentity'), '2025-04-01').outputs.clientId.value]",
+ "STORAGE_CONNECTION__credential": "managedidentity",
+ "PROJECT_ENDPOINT__clientId": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'apiUserAssignedIdentity'), '2025-04-01').outputs.clientId.value]"
+ }
+ },
+ "virtualNetworkSubnetId": {
+ "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.39.26.7824",
+ "templateHash": "1404338913501667303"
+ }
+ },
+ "parameters": {
+ "name": {
+ "type": "string"
+ },
+ "location": {
+ "type": "string",
+ "defaultValue": "[resourceGroup().location]",
+ "metadata": {
+ "description": "Primary location for all resources & Flex Consumption Function App"
+ }
+ },
+ "tags": {
+ "type": "object",
+ "defaultValue": {}
+ },
+ "applicationInsightsName": {
+ "type": "string",
+ "defaultValue": ""
+ },
+ "appServicePlanId": {
+ "type": "string"
+ },
+ "appSettings": {
+ "type": "object",
+ "defaultValue": {}
+ },
+ "runtimeName": {
+ "type": "string"
+ },
+ "runtimeVersion": {
+ "type": "string"
+ },
+ "serviceName": {
+ "type": "string",
+ "defaultValue": "api"
+ },
+ "storageAccountName": {
+ "type": "string"
+ },
+ "deploymentStorageContainerName": {
+ "type": "string"
+ },
+ "virtualNetworkSubnetId": {
+ "type": "string",
+ "defaultValue": ""
+ },
+ "instanceMemoryMB": {
+ "type": "int",
+ "defaultValue": 2048
+ },
+ "maximumInstanceCount": {
+ "type": "int",
+ "defaultValue": 100
+ },
+ "identityId": {
+ "type": "string",
+ "defaultValue": ""
+ },
+ "identityClientId": {
+ "type": "string",
+ "defaultValue": ""
+ },
+ "enableBlob": {
+ "type": "bool",
+ "defaultValue": true
+ },
+ "enableQueue": {
+ "type": "bool",
+ "defaultValue": false
+ },
+ "enableTable": {
+ "type": "bool",
+ "defaultValue": false
+ },
+ "enableFile": {
+ "type": "bool",
+ "defaultValue": false
+ },
+ "identityType": {
+ "type": "string",
+ "defaultValue": "UserAssigned",
+ "allowedValues": [
+ "SystemAssigned",
+ "UserAssigned"
+ ]
+ }
+ },
+ "variables": {
+ "applicationInsightsIdentity": "[format('ClientId={0};Authorization=AAD', parameters('identityClientId'))]",
+ "kind": "functionapp"
+ },
+ "resources": [
+ {
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2025-04-01",
+ "name": "[format('{0}-flex-consumption', parameters('serviceName'))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "kind": {
+ "value": "[variables('kind')]"
+ },
+ "name": {
+ "value": "[parameters('name')]"
+ },
+ "location": {
+ "value": "[parameters('location')]"
+ },
+ "tags": {
+ "value": "[union(parameters('tags'), createObject('azd-service-name', parameters('serviceName')))]"
+ },
+ "serverFarmResourceId": {
+ "value": "[parameters('appServicePlanId')]"
+ },
+ "managedIdentities": {
+ "value": {
+ "systemAssigned": "[equals(parameters('identityType'), 'SystemAssigned')]",
+ "userAssignedResourceIds": [
+ "[format('{0}', parameters('identityId'))]"
+ ]
+ }
+ },
+ "functionAppConfig": {
+ "value": {
+ "deployment": {
+ "storage": {
+ "type": "blobContainer",
+ "value": "[format('{0}{1}', reference(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2022-09-01').primaryEndpoints.blob, parameters('deploymentStorageContainerName'))]",
+ "authentication": {
+ "type": "[if(equals(parameters('identityType'), 'SystemAssigned'), 'SystemAssignedIdentity', 'UserAssignedIdentity')]",
+ "userAssignedIdentityResourceId": "[if(equals(parameters('identityType'), 'UserAssigned'), parameters('identityId'), '')]"
+ }
+ }
+ },
+ "scaleAndConcurrency": {
+ "instanceMemoryMB": "[parameters('instanceMemoryMB')]",
+ "maximumInstanceCount": "[parameters('maximumInstanceCount')]"
+ },
+ "runtime": {
+ "name": "[parameters('runtimeName')]",
+ "version": "[parameters('runtimeVersion')]"
+ }
+ }
+ },
+ "siteConfig": {
+ "value": {
+ "alwaysOn": false
+ }
+ },
+ "virtualNetworkSubnetId": "[if(not(empty(parameters('virtualNetworkSubnetId'))), createObject('value', parameters('virtualNetworkSubnetId')), createObject('value', null()))]",
+ "appSettingsKeyValuePairs": {
+ "value": "[union(parameters('appSettings'), if(parameters('enableBlob'), createObject('AzureWebJobsStorage__blobServiceUri', reference(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2022-09-01').primaryEndpoints.blob), createObject()), if(parameters('enableQueue'), createObject('AzureWebJobsStorage__queueServiceUri', reference(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2022-09-01').primaryEndpoints.queue), createObject()), if(parameters('enableTable'), createObject('AzureWebJobsStorage__tableServiceUri', reference(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2022-09-01').primaryEndpoints.table), createObject()), if(parameters('enableFile'), createObject('AzureWebJobsStorage__fileServiceUri', reference(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2022-09-01').primaryEndpoints.file), createObject()), createObject('AzureWebJobsStorage__credential', 'managedidentity', 'AzureWebJobsStorage__clientId', parameters('identityClientId'), 'APPLICATIONINSIGHTS_AUTHENTICATION_STRING', variables('applicationInsightsIdentity'), 'APPLICATIONINSIGHTS_CONNECTION_STRING', reference(resourceId('Microsoft.Insights/components', parameters('applicationInsightsName')), '2020-02-02').ConnectionString))]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "2522527858358792357"
+ },
+ "name": "Web/Function Apps",
+ "description": "This module deploys a Web or Function App."
+ },
+ "definitions": {
+ "privateEndpointOutputType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the private endpoint."
+ }
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the private endpoint."
+ }
+ },
+ "groupId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "The group Id for the private endpoint Group."
+ }
+ },
+ "customDnsConfigs": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "fqdn": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "FQDN that resolves to private endpoint IP address."
+ }
+ },
+ "ipAddresses": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "metadata": {
+ "description": "A list of private IP addresses of the private endpoint."
+ }
+ }
+ }
+ },
+ "metadata": {
+ "description": "The custom DNS configurations of the private endpoint."
+ }
+ },
+ "networkInterfaceResourceIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "metadata": {
+ "description": "The IDs of the network interfaces associated with the private endpoint."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true
+ }
+ },
+ "_1.privateEndpointCustomDnsConfigType": {
+ "type": "object",
+ "properties": {
+ "fqdn": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. FQDN that resolves to private endpoint IP address."
+ }
+ },
+ "ipAddresses": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "metadata": {
+ "description": "Required. A list of private IP addresses of the private endpoint."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ },
+ "_1.privateEndpointIpConfigurationType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the resource that is unique within a resource group."
+ }
+ },
+ "properties": {
+ "type": "object",
+ "properties": {
+ "groupId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The ID of a group obtained from the remote resource that this private endpoint should connect to."
+ }
+ },
+ "memberName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The member name of a group obtained from the remote resource that this private endpoint should connect to."
+ }
+ },
+ "privateIPAddress": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. A private IP address obtained from the private endpoint's subnet."
+ }
+ }
+ },
+ "metadata": {
+ "description": "Required. Properties of private endpoint IP configurations."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ },
+ "_1.privateEndpointPrivateDnsZoneGroupType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of the Private DNS Zone Group."
+ }
+ },
+ "privateDnsZoneGroupConfigs": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of the private DNS Zone Group config."
+ }
+ },
+ "privateDnsZoneResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The resource id of the private DNS zone."
+ }
+ }
+ }
+ },
+ "metadata": {
+ "description": "Required. The private DNS Zone Groups to associate the Private Endpoint. A DNS Zone Group can support up to 5 DNS zones."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ },
+ "diagnosticSettingFullType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of the diagnostic setting."
+ }
+ },
+ "logCategoriesAndGroups": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "category": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of a Diagnostic Log category for a resource type this setting is applied to. Set the specific logs to collect here."
+ }
+ },
+ "categoryGroup": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of a Diagnostic Log category group for a resource type this setting is applied to. Set to `allLogs` to collect all logs."
+ }
+ },
+ "enabled": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable or disable the category explicitly. Default is `true`."
+ }
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of logs that will be streamed. \"allLogs\" includes all possible logs for the resource. Set to `[]` to disable log collection."
+ }
+ },
+ "metricCategories": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "category": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of a Diagnostic Metric category for a resource type this setting is applied to. Set to `AllMetrics` to collect all metrics."
+ }
+ },
+ "enabled": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable or disable the category explicitly. Default is `true`."
+ }
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of metrics that will be streamed. \"allMetrics\" includes all possible metrics for the resource. Set to `[]` to disable metric collection."
+ }
+ },
+ "logAnalyticsDestinationType": {
+ "type": "string",
+ "allowedValues": [
+ "AzureDiagnostics",
+ "Dedicated"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type."
+ }
+ },
+ "workspaceResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic log analytics workspace. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "storageAccountResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic storage account. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "eventHubAuthorizationRuleResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to."
+ }
+ },
+ "eventHubName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of the diagnostic event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "marketplacePartnerResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The full ARM resource ID of the Marketplace resource to which you would like to send Diagnostic Logs."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a diagnostic setting. To be used if both logs & metrics are supported by the resource provider.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ },
+ "lockType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the name of lock."
+ }
+ },
+ "kind": {
+ "type": "string",
+ "allowedValues": [
+ "CanNotDelete",
+ "None",
+ "ReadOnly"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the type of lock."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a lock.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ },
+ "managedIdentityAllType": {
+ "type": "object",
+ "properties": {
+ "systemAssigned": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enables system assigned managed identity on the resource."
+ }
+ },
+ "userAssignedResourceIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The resource ID(s) to assign to the resource. Required if a user assigned identity is used for encryption."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a managed identity configuration. To be used if both a system-assigned & user-assigned identities are supported by the resource provider.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ },
+ "privateEndpointSingleServiceType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of the Private Endpoint."
+ }
+ },
+ "location": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The location to deploy the Private Endpoint to."
+ }
+ },
+ "privateLinkServiceConnectionName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of the private link connection to create."
+ }
+ },
+ "service": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The subresource to deploy the Private Endpoint for. For example \"vault\" for a Key Vault Private Endpoint."
+ }
+ },
+ "subnetResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Resource ID of the subnet where the endpoint needs to be created."
+ }
+ },
+ "resourceGroupResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The resource ID of the Resource Group the Private Endpoint will be created in. If not specified, the Resource Group of the provided Virtual Network Subnet is used."
+ }
+ },
+ "privateDnsZoneGroup": {
+ "$ref": "#/definitions/_1.privateEndpointPrivateDnsZoneGroupType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The private DNS Zone Group to configure for the Private Endpoint."
+ }
+ },
+ "isManualConnection": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. If Manual Private Link Connection is required."
+ }
+ },
+ "manualConnectionRequestMessage": {
+ "type": "string",
+ "nullable": true,
+ "maxLength": 140,
+ "metadata": {
+ "description": "Optional. A message passed to the owner of the remote resource with the manual connection request."
+ }
+ },
+ "customDnsConfigs": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/_1.privateEndpointCustomDnsConfigType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Custom DNS configurations."
+ }
+ },
+ "ipConfigurations": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/_1.privateEndpointIpConfigurationType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. A list of IP configurations of the Private Endpoint. This will be used to map to the first-party Service endpoints."
+ }
+ },
+ "applicationSecurityGroupResourceIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Application security groups in which the Private Endpoint IP configuration is included."
+ }
+ },
+ "customNetworkInterfaceName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The custom name of the network interface attached to the Private Endpoint."
+ }
+ },
+ "lock": {
+ "$ref": "#/definitions/lockType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the type of lock."
+ }
+ },
+ "roleAssignments": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/roleAssignmentType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Array of role assignments to create."
+ }
+ },
+ "tags": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Tags to be applied on all resources/Resource Groups in this deployment."
+ }
+ },
+ "enableTelemetry": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable/Disable usage telemetry for module."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a private endpoint. To be used if the private endpoint's default service / groupId can be assumed (i.e., for services that only have one Private Endpoint type like 'vault' for key vault).",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ },
+ "roleAssignmentType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name (as GUID) of the role assignment. If not provided, a GUID will be generated."
+ }
+ },
+ "roleDefinitionIdOrName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The role to assign. You can provide either the display name of the role definition, the role definition GUID, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'."
+ }
+ },
+ "principalId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The principal ID of the principal (user/group/identity) to assign the role to."
+ }
+ },
+ "principalType": {
+ "type": "string",
+ "allowedValues": [
+ "Device",
+ "ForeignGroup",
+ "Group",
+ "ServicePrincipal",
+ "User"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The principal type of the assigned principal ID."
+ }
+ },
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The description of the role assignment."
+ }
+ },
+ "condition": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase \"foo_storage_container\"."
+ }
+ },
+ "conditionVersion": {
+ "type": "string",
+ "allowedValues": [
+ "2.0"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Version of the condition."
+ }
+ },
+ "delegatedManagedIdentityResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The Resource Id of the delegated managed identity resource."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a role assignment.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ }
+ },
+ "parameters": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of the site."
+ }
+ },
+ "location": {
+ "type": "string",
+ "defaultValue": "[resourceGroup().location]",
+ "metadata": {
+ "description": "Optional. Location for all Resources."
+ }
+ },
+ "kind": {
+ "type": "string",
+ "allowedValues": [
+ "functionapp",
+ "functionapp,linux",
+ "functionapp,workflowapp",
+ "functionapp,workflowapp,linux",
+ "functionapp,linux,container",
+ "functionapp,linux,container,azurecontainerapps",
+ "app,linux",
+ "app",
+ "linux,api",
+ "api",
+ "app,linux,container",
+ "app,container,windows"
+ ],
+ "metadata": {
+ "description": "Required. Type of site to deploy."
+ }
+ },
+ "serverFarmResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The resource ID of the app service plan to use for the site."
+ }
+ },
+ "managedEnvironmentId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Azure Resource Manager ID of the customers selected Managed Environment on which to host this app."
+ }
+ },
+ "httpsOnly": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. Configures a site to accept only HTTPS requests. Issues redirect for HTTP requests."
+ }
+ },
+ "clientAffinityEnabled": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. If client affinity is enabled."
+ }
+ },
+ "appServiceEnvironmentResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The resource ID of the app service environment to use for this resource."
+ }
+ },
+ "managedIdentities": {
+ "$ref": "#/definitions/managedIdentityAllType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The managed identity definition for this resource."
+ }
+ },
+ "keyVaultAccessIdentityResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The resource ID of the assigned identity to be used to access a key vault with."
+ }
+ },
+ "storageAccountRequired": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. Checks if Customer provided storage account is required."
+ }
+ },
+ "virtualNetworkSubnetId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Azure Resource Manager ID of the Virtual network and subnet to be joined by Regional VNET Integration. This must be of the form /subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}."
+ }
+ },
+ "vnetContentShareEnabled": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. To enable accessing content over virtual network."
+ }
+ },
+ "vnetImagePullEnabled": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. To enable pulling image over Virtual Network."
+ }
+ },
+ "vnetRouteAllEnabled": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. Virtual Network Route All enabled. This causes all outbound traffic to have Virtual Network Security Groups and User Defined Routes applied."
+ }
+ },
+ "scmSiteAlsoStopped": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. Stop SCM (KUDU) site when the app is stopped."
+ }
+ },
+ "siteConfig": {
+ "type": "object",
+ "defaultValue": {
+ "alwaysOn": true,
+ "minTlsVersion": "1.2",
+ "ftpsState": "FtpsOnly"
+ },
+ "metadata": {
+ "description": "Optional. The site config object. The defaults are set to the following values: alwaysOn: true, minTlsVersion: '1.2', ftpsState: 'FtpsOnly'."
+ }
+ },
+ "functionAppConfig": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The Function App configuration object."
+ }
+ },
+ "storageAccountResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Required if app of kind functionapp. Resource ID of the storage account to manage triggers and logging function executions."
+ }
+ },
+ "storageAccountUseIdentityAuthentication": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. If the provided storage account requires Identity based authentication ('allowSharedKeyAccess' is set to false). When set to true, the minimum role assignment required for the App Service Managed Identity to the storage account is 'Storage Blob Data Owner'."
+ }
+ },
+ "webConfiguration": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The Site Config, Web settings to deploy."
+ }
+ },
+ "msDeployConfiguration": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The extension MSDeployment configuration."
+ }
+ },
+ "appInsightResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the app insight to leverage for this resource."
+ }
+ },
+ "appSettingsKeyValuePairs": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The app settings-value pairs except for AzureWebJobsStorage, AzureWebJobsDashboard, APPINSIGHTS_INSTRUMENTATIONKEY and APPLICATIONINSIGHTS_CONNECTION_STRING."
+ }
+ },
+ "authSettingV2Configuration": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The auth settings V2 configuration."
+ }
+ },
+ "lock": {
+ "$ref": "#/definitions/lockType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The lock settings of the service."
+ }
+ },
+ "logsConfiguration": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The logs settings configuration."
+ }
+ },
+ "privateEndpoints": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/privateEndpointSingleServiceType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Configuration details for private endpoints. For security reasons, it is recommended to use private endpoints whenever possible."
+ }
+ },
+ "slots": {
+ "type": "array",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Configuration for deployment slots for an app."
+ }
+ },
+ "tags": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Tags of the resource."
+ }
+ },
+ "enableTelemetry": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. Enable/Disable usage telemetry for module."
+ }
+ },
+ "roleAssignments": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/roleAssignmentType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Array of role assignments to create."
+ }
+ },
+ "diagnosticSettings": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/diagnosticSettingFullType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The diagnostic settings of the service."
+ }
+ },
+ "clientCertEnabled": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. To enable client certificate authentication (TLS mutual authentication)."
+ }
+ },
+ "clientCertExclusionPaths": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Client certificate authentication comma-separated exclusion paths."
+ }
+ },
+ "clientCertMode": {
+ "type": "string",
+ "defaultValue": "Optional",
+ "allowedValues": [
+ "Optional",
+ "OptionalInteractiveUser",
+ "Required"
+ ],
+ "metadata": {
+ "description": "Optional. This composes with ClientCertEnabled setting.\n- ClientCertEnabled=false means ClientCert is ignored.\n- ClientCertEnabled=true and ClientCertMode=Required means ClientCert is required.\n- ClientCertEnabled=true and ClientCertMode=Optional means ClientCert is optional or accepted.\n"
+ }
+ },
+ "cloningInfo": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. If specified during app creation, the app is cloned from a source app."
+ }
+ },
+ "containerSize": {
+ "type": "int",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Size of the function container."
+ }
+ },
+ "dailyMemoryTimeQuota": {
+ "type": "int",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Maximum allowed daily memory-time quota (applicable on dynamic apps only)."
+ }
+ },
+ "enabled": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. Setting this value to false disables the app (takes the app offline)."
+ }
+ },
+ "hostNameSslStates": {
+ "type": "array",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Hostname SSL states are used to manage the SSL bindings for app's hostnames."
+ }
+ },
+ "hyperV": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. Hyper-V sandbox."
+ }
+ },
+ "redundancyMode": {
+ "type": "string",
+ "defaultValue": "None",
+ "allowedValues": [
+ "ActiveActive",
+ "Failover",
+ "GeoRedundant",
+ "Manual",
+ "None"
+ ],
+ "metadata": {
+ "description": "Optional. Site redundancy mode."
+ }
+ },
+ "basicPublishingCredentialsPolicies": {
+ "type": "array",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The site publishing credential policy names which are associated with the sites."
+ }
+ },
+ "hybridConnectionRelays": {
+ "type": "array",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Names of hybrid connection relays to connect app with."
+ }
+ },
+ "publicNetworkAccess": {
+ "type": "string",
+ "nullable": true,
+ "allowedValues": [
+ "Enabled",
+ "Disabled"
+ ],
+ "metadata": {
+ "description": "Optional. Whether or not public network access is allowed for this resource. For security reasons it should be disabled. If not specified, it will be disabled by default if private endpoints are set."
+ }
+ },
+ "e2eEncryptionEnabled": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. End to End Encryption Setting."
+ }
+ }
+ },
+ "variables": {
+ "copy": [
+ {
+ "name": "formattedRoleAssignments",
+ "count": "[length(coalesce(parameters('roleAssignments'), createArray()))]",
+ "input": "[union(coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')], createObject('roleDefinitionId', coalesce(tryGet(variables('builtInRoleNames'), coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName), if(contains(coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/'), coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName)))))]"
+ }
+ ],
+ "enableReferencedModulesTelemetry": false,
+ "formattedUserAssignedIdentities": "[reduce(map(coalesce(tryGet(parameters('managedIdentities'), 'userAssignedResourceIds'), createArray()), lambda('id', createObject(format('{0}', lambdaVariables('id')), createObject()))), createObject(), lambda('cur', 'next', union(lambdaVariables('cur'), lambdaVariables('next'))))]",
+ "identity": "[if(not(empty(parameters('managedIdentities'))), createObject('type', if(coalesce(tryGet(parameters('managedIdentities'), 'systemAssigned'), false()), if(not(empty(coalesce(tryGet(parameters('managedIdentities'), 'userAssignedResourceIds'), createObject()))), 'SystemAssigned, UserAssigned', 'SystemAssigned'), if(not(empty(coalesce(tryGet(parameters('managedIdentities'), 'userAssignedResourceIds'), createObject()))), 'UserAssigned', 'None')), 'userAssignedIdentities', if(not(empty(variables('formattedUserAssignedIdentities'))), variables('formattedUserAssignedIdentities'), null())), null())]",
+ "builtInRoleNames": {
+ "App Compliance Automation Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '0f37683f-2463-46b6-9ce7-9b788b988ba2')]",
+ "Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
+ "Owner": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]",
+ "Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'acdd72a7-3385-48ef-bd42-f606fba81ae7')]",
+ "Role Based Access Control Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'f58310d9-a9f6-439a-9e8d-f62e7b41a168')]",
+ "User Access Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '18d7d88d-d35e-4fb5-a5c3-7773c20a72d9')]",
+ "Web Plan Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '2cc479cb-7b4d-49a8-b449-8c00fd0f0a4b')]",
+ "Website Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'de139f84-1756-47ae-9be6-808fbbe84772')]"
+ }
+ },
+ "resources": {
+ "avmTelemetry": {
+ "condition": "[parameters('enableTelemetry')]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2024-03-01",
+ "name": "[format('46d3xbcp.res.web-site.{0}.{1}', replace('0.15.1', '.', '-'), substring(uniqueString(deployment().name, parameters('location')), 0, 4))]",
+ "properties": {
+ "mode": "Incremental",
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "resources": [],
+ "outputs": {
+ "telemetry": {
+ "type": "String",
+ "value": "For more information, see https://aka.ms/avm/TelemetryInfo"
+ }
+ }
+ }
+ }
+ },
+ "app": {
+ "type": "Microsoft.Web/sites",
+ "apiVersion": "2024-04-01",
+ "name": "[parameters('name')]",
+ "location": "[parameters('location')]",
+ "kind": "[parameters('kind')]",
+ "tags": "[parameters('tags')]",
+ "identity": "[variables('identity')]",
+ "properties": {
+ "managedEnvironmentId": "[if(not(empty(parameters('managedEnvironmentId'))), parameters('managedEnvironmentId'), null())]",
+ "serverFarmId": "[parameters('serverFarmResourceId')]",
+ "clientAffinityEnabled": "[parameters('clientAffinityEnabled')]",
+ "httpsOnly": "[parameters('httpsOnly')]",
+ "hostingEnvironmentProfile": "[if(not(empty(parameters('appServiceEnvironmentResourceId'))), createObject('id', parameters('appServiceEnvironmentResourceId')), null())]",
+ "storageAccountRequired": "[parameters('storageAccountRequired')]",
+ "keyVaultReferenceIdentity": "[parameters('keyVaultAccessIdentityResourceId')]",
+ "virtualNetworkSubnetId": "[parameters('virtualNetworkSubnetId')]",
+ "siteConfig": "[parameters('siteConfig')]",
+ "functionAppConfig": "[parameters('functionAppConfig')]",
+ "clientCertEnabled": "[parameters('clientCertEnabled')]",
+ "clientCertExclusionPaths": "[parameters('clientCertExclusionPaths')]",
+ "clientCertMode": "[parameters('clientCertMode')]",
+ "cloningInfo": "[parameters('cloningInfo')]",
+ "containerSize": "[parameters('containerSize')]",
+ "dailyMemoryTimeQuota": "[parameters('dailyMemoryTimeQuota')]",
+ "enabled": "[parameters('enabled')]",
+ "hostNameSslStates": "[parameters('hostNameSslStates')]",
+ "hyperV": "[parameters('hyperV')]",
+ "redundancyMode": "[parameters('redundancyMode')]",
+ "publicNetworkAccess": "[if(not(empty(parameters('publicNetworkAccess'))), parameters('publicNetworkAccess'), if(not(empty(parameters('privateEndpoints'))), 'Disabled', 'Enabled'))]",
+ "vnetContentShareEnabled": "[parameters('vnetContentShareEnabled')]",
+ "vnetImagePullEnabled": "[parameters('vnetImagePullEnabled')]",
+ "vnetRouteAllEnabled": "[parameters('vnetRouteAllEnabled')]",
+ "scmSiteAlsoStopped": "[parameters('scmSiteAlsoStopped')]",
+ "endToEndEncryptionEnabled": "[parameters('e2eEncryptionEnabled')]"
+ }
+ },
+ "app_lock": {
+ "condition": "[and(not(empty(coalesce(parameters('lock'), createObject()))), not(equals(tryGet(parameters('lock'), 'kind'), 'None')))]",
+ "type": "Microsoft.Authorization/locks",
+ "apiVersion": "2020-05-01",
+ "scope": "[format('Microsoft.Web/sites/{0}', parameters('name'))]",
+ "name": "[coalesce(tryGet(parameters('lock'), 'name'), format('lock-{0}', parameters('name')))]",
+ "properties": {
+ "level": "[coalesce(tryGet(parameters('lock'), 'kind'), '')]",
+ "notes": "[if(equals(tryGet(parameters('lock'), 'kind'), 'CanNotDelete'), 'Cannot delete resource or child resources.', 'Cannot delete or modify the resource or child resources.')]"
+ },
+ "dependsOn": [
+ "app"
+ ]
+ },
+ "app_diagnosticSettings": {
+ "copy": {
+ "name": "app_diagnosticSettings",
+ "count": "[length(coalesce(parameters('diagnosticSettings'), createArray()))]"
+ },
+ "type": "Microsoft.Insights/diagnosticSettings",
+ "apiVersion": "2021-05-01-preview",
+ "scope": "[format('Microsoft.Web/sites/{0}', parameters('name'))]",
+ "name": "[coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'name'), format('{0}-diagnosticSettings', parameters('name')))]",
+ "properties": {
+ "copy": [
+ {
+ "name": "metrics",
+ "count": "[length(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics'))))]",
+ "input": {
+ "category": "[coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics')))[copyIndex('metrics')].category]",
+ "enabled": "[coalesce(tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics')))[copyIndex('metrics')], 'enabled'), true())]",
+ "timeGrain": null
+ }
+ },
+ {
+ "name": "logs",
+ "count": "[length(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs'))))]",
+ "input": {
+ "categoryGroup": "[tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'categoryGroup')]",
+ "category": "[tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'category')]",
+ "enabled": "[coalesce(tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'enabled'), true())]"
+ }
+ }
+ ],
+ "storageAccountId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'storageAccountResourceId')]",
+ "workspaceId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'workspaceResourceId')]",
+ "eventHubAuthorizationRuleId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'eventHubAuthorizationRuleResourceId')]",
+ "eventHubName": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'eventHubName')]",
+ "marketplacePartnerId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'marketplacePartnerResourceId')]",
+ "logAnalyticsDestinationType": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logAnalyticsDestinationType')]"
+ },
+ "dependsOn": [
+ "app"
+ ]
+ },
+ "app_roleAssignments": {
+ "copy": {
+ "name": "app_roleAssignments",
+ "count": "[length(coalesce(variables('formattedRoleAssignments'), createArray()))]"
+ },
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Web/sites/{0}', parameters('name'))]",
+ "name": "[coalesce(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'name'), guid(resourceId('Microsoft.Web/sites', parameters('name')), coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].principalId, coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].roleDefinitionId))]",
+ "properties": {
+ "roleDefinitionId": "[coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].roleDefinitionId]",
+ "principalId": "[coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].principalId]",
+ "description": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'description')]",
+ "principalType": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'principalType')]",
+ "condition": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'condition')]",
+ "conditionVersion": "[if(not(empty(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'condition'))), coalesce(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'conditionVersion'), '2.0'), null())]",
+ "delegatedManagedIdentityResourceId": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'delegatedManagedIdentityResourceId')]"
+ },
+ "dependsOn": [
+ "app"
+ ]
+ },
+ "app_appsettings": {
+ "condition": "[or(or(not(empty(parameters('appSettingsKeyValuePairs'))), not(empty(parameters('appInsightResourceId')))), not(empty(parameters('storageAccountResourceId'))))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Site-Config-AppSettings', uniqueString(deployment().name, parameters('location')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "appName": {
+ "value": "[parameters('name')]"
+ },
+ "kind": {
+ "value": "[parameters('kind')]"
+ },
+ "storageAccountResourceId": {
+ "value": "[parameters('storageAccountResourceId')]"
+ },
+ "storageAccountUseIdentityAuthentication": {
+ "value": "[parameters('storageAccountUseIdentityAuthentication')]"
+ },
+ "appInsightResourceId": {
+ "value": "[parameters('appInsightResourceId')]"
+ },
+ "appSettingsKeyValuePairs": {
+ "value": "[parameters('appSettingsKeyValuePairs')]"
+ },
+ "currentAppSettings": "[if(not(empty(resourceId('Microsoft.Web/sites', parameters('name')))), createObject('value', list(format('{0}/config/appsettings', resourceId('Microsoft.Web/sites', parameters('name'))), '2023-12-01').properties), createObject('value', createObject()))]"
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "12262977018813780856"
+ },
+ "name": "Site App Settings",
+ "description": "This module deploys a Site App Setting."
+ },
+ "parameters": {
+ "appName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent site resource. Required if the template is used in a standalone deployment."
+ }
+ },
+ "kind": {
+ "type": "string",
+ "allowedValues": [
+ "functionapp",
+ "functionapp,linux",
+ "functionapp,workflowapp",
+ "functionapp,workflowapp,linux",
+ "functionapp,linux,container",
+ "functionapp,linux,container,azurecontainerapps",
+ "app,linux",
+ "app",
+ "linux,api",
+ "api",
+ "app,linux,container",
+ "app,container,windows"
+ ],
+ "metadata": {
+ "description": "Required. Type of site to deploy."
+ }
+ },
+ "storageAccountResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Required if app of kind functionapp. Resource ID of the storage account to manage triggers and logging function executions."
+ }
+ },
+ "storageAccountUseIdentityAuthentication": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. If the provided storage account requires Identity based authentication ('allowSharedKeyAccess' is set to false). When set to true, the minimum role assignment required for the App Service Managed Identity to the storage account is 'Storage Blob Data Owner'."
+ }
+ },
+ "appInsightResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the app insight to leverage for this resource."
+ }
+ },
+ "appSettingsKeyValuePairs": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The app settings key-value pairs except for AzureWebJobsStorage, AzureWebJobsDashboard, APPINSIGHTS_INSTRUMENTATIONKEY and APPLICATIONINSIGHTS_CONNECTION_STRING."
+ }
+ },
+ "currentAppSettings": {
+ "type": "object",
+ "defaultValue": {},
+ "metadata": {
+ "description": "Optional. The current app settings."
+ }
+ }
+ },
+ "resources": {
+ "app": {
+ "existing": true,
+ "type": "Microsoft.Web/sites",
+ "apiVersion": "2023-12-01",
+ "name": "[parameters('appName')]"
+ },
+ "appInsight": {
+ "condition": "[not(empty(parameters('appInsightResourceId')))]",
+ "existing": true,
+ "type": "Microsoft.Insights/components",
+ "apiVersion": "2020-02-02",
+ "subscriptionId": "[split(parameters('appInsightResourceId'), '/')[2]]",
+ "resourceGroup": "[split(parameters('appInsightResourceId'), '/')[4]]",
+ "name": "[last(split(parameters('appInsightResourceId'), '/'))]"
+ },
+ "storageAccount": {
+ "condition": "[not(empty(parameters('storageAccountResourceId')))]",
+ "existing": true,
+ "type": "Microsoft.Storage/storageAccounts",
+ "apiVersion": "2023-05-01",
+ "subscriptionId": "[split(parameters('storageAccountResourceId'), '/')[2]]",
+ "resourceGroup": "[split(parameters('storageAccountResourceId'), '/')[4]]",
+ "name": "[last(split(parameters('storageAccountResourceId'), '/'))]"
+ },
+ "appSettings": {
+ "type": "Microsoft.Web/sites/config",
+ "apiVersion": "2024-04-01",
+ "name": "[format('{0}/{1}', parameters('appName'), 'appsettings')]",
+ "kind": "[parameters('kind')]",
+ "properties": "[union(coalesce(parameters('currentAppSettings'), createObject()), coalesce(parameters('appSettingsKeyValuePairs'), createObject()), if(and(not(empty(parameters('storageAccountResourceId'))), not(parameters('storageAccountUseIdentityAuthentication'))), createObject('AzureWebJobsStorage', format('DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1};EndpointSuffix={2}', last(split(parameters('storageAccountResourceId'), '/')), listKeys(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(parameters('storageAccountResourceId'), '/')[2], split(parameters('storageAccountResourceId'), '/')[4]), 'Microsoft.Storage/storageAccounts', last(split(parameters('storageAccountResourceId'), '/'))), '2023-05-01').keys[0].value, environment().suffixes.storage)), if(and(not(empty(parameters('storageAccountResourceId'))), parameters('storageAccountUseIdentityAuthentication')), union(createObject('AzureWebJobsStorage__accountName', last(split(parameters('storageAccountResourceId'), '/'))), createObject('AzureWebJobsStorage__blobServiceUri', reference('storageAccount').primaryEndpoints.blob), createObject('AzureWebJobsStorage__queueServiceUri', reference('storageAccount').primaryEndpoints.queue), createObject('AzureWebJobsStorage__tableServiceUri', reference('storageAccount').primaryEndpoints.table)), createObject())), if(not(empty(parameters('appInsightResourceId'))), createObject('APPLICATIONINSIGHTS_CONNECTION_STRING', reference('appInsight').ConnectionString), createObject()))]",
+ "dependsOn": [
+ "appInsight",
+ "storageAccount"
+ ]
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the site config."
+ },
+ "value": "appsettings"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the site config."
+ },
+ "value": "[resourceId('Microsoft.Web/sites/config', parameters('appName'), 'appsettings')]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group the site config was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "app"
+ ]
+ },
+ "app_authsettingsv2": {
+ "condition": "[not(empty(parameters('authSettingV2Configuration')))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Site-Config-AuthSettingsV2', uniqueString(deployment().name, parameters('location')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "appName": {
+ "value": "[parameters('name')]"
+ },
+ "kind": {
+ "value": "[parameters('kind')]"
+ },
+ "authSettingV2Configuration": {
+ "value": "[coalesce(parameters('authSettingV2Configuration'), createObject())]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "1129994114817101549"
+ },
+ "name": "Site Auth Settings V2 Config",
+ "description": "This module deploys a Site Auth Settings V2 Configuration."
+ },
+ "parameters": {
+ "appName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent site resource. Required if the template is used in a standalone deployment."
+ }
+ },
+ "kind": {
+ "type": "string",
+ "allowedValues": [
+ "functionapp",
+ "functionapp,linux",
+ "functionapp,workflowapp",
+ "functionapp,workflowapp,linux",
+ "functionapp,linux,container",
+ "functionapp,linux,container,azurecontainerapps",
+ "app,linux",
+ "app",
+ "linux,api",
+ "api",
+ "app,linux,container",
+ "app,container,windows"
+ ],
+ "metadata": {
+ "description": "Required. Type of site to deploy."
+ }
+ },
+ "authSettingV2Configuration": {
+ "type": "object",
+ "metadata": {
+ "description": "Required. The auth settings V2 configuration."
+ }
+ }
+ },
+ "resources": [
+ {
+ "type": "Microsoft.Web/sites/config",
+ "apiVersion": "2024-04-01",
+ "name": "[format('{0}/{1}', parameters('appName'), 'authsettingsV2')]",
+ "kind": "[parameters('kind')]",
+ "properties": "[parameters('authSettingV2Configuration')]"
+ }
+ ],
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the site config."
+ },
+ "value": "authsettingsV2"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the site config."
+ },
+ "value": "[resourceId('Microsoft.Web/sites/config', parameters('appName'), 'authsettingsV2')]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group the site config was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "app"
+ ]
+ },
+ "app_logssettings": {
+ "condition": "[not(empty(coalesce(parameters('logsConfiguration'), createObject())))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Site-Config-Logs', uniqueString(deployment().name, parameters('location')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "appName": {
+ "value": "[parameters('name')]"
+ },
+ "logsConfiguration": {
+ "value": "[parameters('logsConfiguration')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "17967336872376441757"
+ },
+ "name": "Site logs Config",
+ "description": "This module deploys a Site logs Configuration."
+ },
+ "parameters": {
+ "appName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the parent site resource."
+ }
+ },
+ "logsConfiguration": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The logs settings configuration."
+ }
+ }
+ },
+ "resources": {
+ "app": {
+ "existing": true,
+ "type": "Microsoft.Web/sites",
+ "apiVersion": "2024-04-01",
+ "name": "[parameters('appName')]"
+ },
+ "webSettings": {
+ "type": "Microsoft.Web/sites/config",
+ "apiVersion": "2024-04-01",
+ "name": "[format('{0}/{1}', parameters('appName'), 'logs')]",
+ "kind": "string",
+ "properties": "[parameters('logsConfiguration')]"
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the site config."
+ },
+ "value": "logs"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the site config."
+ },
+ "value": "[resourceId('Microsoft.Web/sites/config', parameters('appName'), 'logs')]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group the site config was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "app",
+ "app_appsettings"
+ ]
+ },
+ "app_websettings": {
+ "condition": "[not(empty(coalesce(parameters('webConfiguration'), createObject())))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Site-Config-Web', uniqueString(deployment().name, parameters('location')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "appName": {
+ "value": "[parameters('name')]"
+ },
+ "webConfiguration": {
+ "value": "[parameters('webConfiguration')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "15058680643544097487"
+ },
+ "name": "Site Web Config",
+ "description": "This module deploys web settings configuration available under sites/config name: web."
+ },
+ "parameters": {
+ "appName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the parent site resource."
+ }
+ },
+ "webConfiguration": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The Site Config, Web settings to deploy."
+ }
+ }
+ },
+ "resources": {
+ "app": {
+ "existing": true,
+ "type": "Microsoft.Web/sites",
+ "apiVersion": "2024-04-01",
+ "name": "[parameters('appName')]"
+ },
+ "webSettings": {
+ "type": "Microsoft.Web/sites/config",
+ "apiVersion": "2024-04-01",
+ "name": "[format('{0}/{1}', parameters('appName'), 'web')]",
+ "kind": "string",
+ "properties": "[parameters('webConfiguration')]"
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the site config."
+ },
+ "value": "web"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the site config."
+ },
+ "value": "[resourceId('Microsoft.Web/sites/config', parameters('appName'), 'web')]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group the site config was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "app"
+ ]
+ },
+ "extension_msdeploy": {
+ "condition": "[not(empty(parameters('msDeployConfiguration')))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Site-Extension-MSDeploy', uniqueString(deployment().name, parameters('location')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "appName": {
+ "value": "[parameters('name')]"
+ },
+ "msDeployConfiguration": {
+ "value": "[coalesce(parameters('msDeployConfiguration'), createObject())]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "14895622660217616811"
+ },
+ "name": "Site Deployment Extension ",
+ "description": "This module deploys a Site extension for MSDeploy."
+ },
+ "parameters": {
+ "appName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the parent site resource."
+ }
+ },
+ "msDeployConfiguration": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Sets the MSDeployment Properties."
+ }
+ }
+ },
+ "resources": {
+ "app": {
+ "existing": true,
+ "type": "Microsoft.Web/sites",
+ "apiVersion": "2024-04-01",
+ "name": "[parameters('appName')]"
+ },
+ "msdeploy": {
+ "type": "Microsoft.Web/sites/extensions",
+ "apiVersion": "2024-04-01",
+ "name": "[format('{0}/{1}', parameters('appName'), 'MSDeploy')]",
+ "kind": "MSDeploy",
+ "properties": "[parameters('msDeployConfiguration')]"
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the MSDeploy Package."
+ },
+ "value": "MSDeploy"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the Site Extension."
+ },
+ "value": "[resourceId('Microsoft.Web/sites/extensions', parameters('appName'), 'MSDeploy')]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group the site config was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "app"
+ ]
+ },
+ "app_slots": {
+ "copy": {
+ "name": "app_slots",
+ "count": "[length(coalesce(parameters('slots'), createArray()))]",
+ "mode": "serial",
+ "batchSize": 1
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Slot-{1}', uniqueString(deployment().name, parameters('location')), coalesce(parameters('slots'), createArray())[copyIndex()].name)]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "name": {
+ "value": "[coalesce(parameters('slots'), createArray())[copyIndex()].name]"
+ },
+ "appName": {
+ "value": "[parameters('name')]"
+ },
+ "location": {
+ "value": "[parameters('location')]"
+ },
+ "kind": {
+ "value": "[parameters('kind')]"
+ },
+ "serverFarmResourceId": {
+ "value": "[parameters('serverFarmResourceId')]"
+ },
+ "httpsOnly": {
+ "value": "[coalesce(tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'httpsOnly'), parameters('httpsOnly'))]"
+ },
+ "appServiceEnvironmentResourceId": {
+ "value": "[parameters('appServiceEnvironmentResourceId')]"
+ },
+ "clientAffinityEnabled": {
+ "value": "[coalesce(tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'clientAffinityEnabled'), parameters('clientAffinityEnabled'))]"
+ },
+ "managedIdentities": {
+ "value": "[coalesce(tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'managedIdentities'), parameters('managedIdentities'))]"
+ },
+ "keyVaultAccessIdentityResourceId": {
+ "value": "[coalesce(tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'keyVaultAccessIdentityResourceId'), parameters('keyVaultAccessIdentityResourceId'))]"
+ },
+ "storageAccountRequired": {
+ "value": "[coalesce(tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'storageAccountRequired'), parameters('storageAccountRequired'))]"
+ },
+ "virtualNetworkSubnetId": {
+ "value": "[coalesce(tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'virtualNetworkSubnetId'), parameters('virtualNetworkSubnetId'))]"
+ },
+ "siteConfig": {
+ "value": "[coalesce(tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'siteConfig'), parameters('siteConfig'))]"
+ },
+ "functionAppConfig": {
+ "value": "[coalesce(tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'functionAppConfig'), parameters('functionAppConfig'))]"
+ },
+ "storageAccountResourceId": {
+ "value": "[coalesce(tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'storageAccountResourceId'), parameters('storageAccountResourceId'))]"
+ },
+ "storageAccountUseIdentityAuthentication": {
+ "value": "[coalesce(tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'storageAccountUseIdentityAuthentication'), parameters('storageAccountUseIdentityAuthentication'))]"
+ },
+ "appInsightResourceId": {
+ "value": "[coalesce(tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'appInsightResourceId'), parameters('appInsightResourceId'))]"
+ },
+ "authSettingV2Configuration": {
+ "value": "[coalesce(tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'authSettingV2Configuration'), parameters('authSettingV2Configuration'))]"
+ },
+ "msDeployConfiguration": {
+ "value": "[coalesce(tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'msDeployConfiguration'), parameters('msDeployConfiguration'))]"
+ },
+ "diagnosticSettings": {
+ "value": "[tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'diagnosticSettings')]"
+ },
+ "roleAssignments": {
+ "value": "[tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'roleAssignments')]"
+ },
+ "appSettingsKeyValuePairs": {
+ "value": "[coalesce(tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'appSettingsKeyValuePairs'), parameters('appSettingsKeyValuePairs'))]"
+ },
+ "basicPublishingCredentialsPolicies": {
+ "value": "[coalesce(tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'basicPublishingCredentialsPolicies'), parameters('basicPublishingCredentialsPolicies'))]"
+ },
+ "lock": {
+ "value": "[coalesce(tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'lock'), parameters('lock'))]"
+ },
+ "privateEndpoints": {
+ "value": "[coalesce(tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'privateEndpoints'), createArray())]"
+ },
+ "tags": {
+ "value": "[coalesce(tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'tags'), parameters('tags'))]"
+ },
+ "clientCertEnabled": {
+ "value": "[tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'clientCertEnabled')]"
+ },
+ "clientCertExclusionPaths": {
+ "value": "[tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'clientCertExclusionPaths')]"
+ },
+ "clientCertMode": {
+ "value": "[tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'clientCertMode')]"
+ },
+ "cloningInfo": {
+ "value": "[tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'cloningInfo')]"
+ },
+ "containerSize": {
+ "value": "[tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'containerSize')]"
+ },
+ "customDomainVerificationId": {
+ "value": "[tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'customDomainVerificationId')]"
+ },
+ "dailyMemoryTimeQuota": {
+ "value": "[tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'dailyMemoryTimeQuota')]"
+ },
+ "enabled": {
+ "value": "[tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'enabled')]"
+ },
+ "hostNameSslStates": {
+ "value": "[tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'hostNameSslStates')]"
+ },
+ "hyperV": {
+ "value": "[tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'hyperV')]"
+ },
+ "publicNetworkAccess": {
+ "value": "[coalesce(tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'publicNetworkAccess'), if(or(not(empty(tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'privateEndpoints'))), not(empty(parameters('privateEndpoints')))), 'Disabled', 'Enabled'))]"
+ },
+ "redundancyMode": {
+ "value": "[tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'redundancyMode')]"
+ },
+ "vnetContentShareEnabled": {
+ "value": "[tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'vnetContentShareEnabled')]"
+ },
+ "vnetImagePullEnabled": {
+ "value": "[tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'vnetImagePullEnabled')]"
+ },
+ "vnetRouteAllEnabled": {
+ "value": "[tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'vnetRouteAllEnabled')]"
+ },
+ "hybridConnectionRelays": {
+ "value": "[tryGet(coalesce(parameters('slots'), createArray())[copyIndex()], 'hybridConnectionRelays')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "4067755327331248181"
+ },
+ "name": "Web/Function App Deployment Slots",
+ "description": "This module deploys a Web or Function App Deployment Slot."
+ },
+ "definitions": {
+ "privateEndpointOutputType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the private endpoint."
+ }
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the private endpoint."
+ }
+ },
+ "groupId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "The group Id for the private endpoint Group."
+ }
+ },
+ "customDnsConfigs": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "fqdn": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "FQDN that resolves to private endpoint IP address."
+ }
+ },
+ "ipAddresses": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "metadata": {
+ "description": "A list of private IP addresses of the private endpoint."
+ }
+ }
+ }
+ },
+ "metadata": {
+ "description": "The custom DNS configurations of the private endpoint."
+ }
+ },
+ "networkInterfaceResourceIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "metadata": {
+ "description": "The IDs of the network interfaces associated with the private endpoint."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true
+ }
+ },
+ "_1.privateEndpointCustomDnsConfigType": {
+ "type": "object",
+ "properties": {
+ "fqdn": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. FQDN that resolves to private endpoint IP address."
+ }
+ },
+ "ipAddresses": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "metadata": {
+ "description": "Required. A list of private IP addresses of the private endpoint."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ },
+ "_1.privateEndpointIpConfigurationType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the resource that is unique within a resource group."
+ }
+ },
+ "properties": {
+ "type": "object",
+ "properties": {
+ "groupId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The ID of a group obtained from the remote resource that this private endpoint should connect to."
+ }
+ },
+ "memberName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The member name of a group obtained from the remote resource that this private endpoint should connect to."
+ }
+ },
+ "privateIPAddress": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. A private IP address obtained from the private endpoint's subnet."
+ }
+ }
+ },
+ "metadata": {
+ "description": "Required. Properties of private endpoint IP configurations."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ },
+ "_1.privateEndpointPrivateDnsZoneGroupType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of the Private DNS Zone Group."
+ }
+ },
+ "privateDnsZoneGroupConfigs": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of the private DNS Zone Group config."
+ }
+ },
+ "privateDnsZoneResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The resource id of the private DNS zone."
+ }
+ }
+ }
+ },
+ "metadata": {
+ "description": "Required. The private DNS Zone Groups to associate the Private Endpoint. A DNS Zone Group can support up to 5 DNS zones."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ },
+ "diagnosticSettingFullType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of the diagnostic setting."
+ }
+ },
+ "logCategoriesAndGroups": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "category": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of a Diagnostic Log category for a resource type this setting is applied to. Set the specific logs to collect here."
+ }
+ },
+ "categoryGroup": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of a Diagnostic Log category group for a resource type this setting is applied to. Set to `allLogs` to collect all logs."
+ }
+ },
+ "enabled": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable or disable the category explicitly. Default is `true`."
+ }
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of logs that will be streamed. \"allLogs\" includes all possible logs for the resource. Set to `[]` to disable log collection."
+ }
+ },
+ "metricCategories": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "category": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of a Diagnostic Metric category for a resource type this setting is applied to. Set to `AllMetrics` to collect all metrics."
+ }
+ },
+ "enabled": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable or disable the category explicitly. Default is `true`."
+ }
+ }
+ }
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of metrics that will be streamed. \"allMetrics\" includes all possible metrics for the resource. Set to `[]` to disable metric collection."
+ }
+ },
+ "logAnalyticsDestinationType": {
+ "type": "string",
+ "allowedValues": [
+ "AzureDiagnostics",
+ "Dedicated"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type."
+ }
+ },
+ "workspaceResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic log analytics workspace. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "storageAccountResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic storage account. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "eventHubAuthorizationRuleResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the diagnostic event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to."
+ }
+ },
+ "eventHubName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Name of the diagnostic event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub."
+ }
+ },
+ "marketplacePartnerResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The full ARM resource ID of the Marketplace resource to which you would like to send Diagnostic Logs."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a diagnostic setting. To be used if both logs & metrics are supported by the resource provider.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ },
+ "lockType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the name of lock."
+ }
+ },
+ "kind": {
+ "type": "string",
+ "allowedValues": [
+ "CanNotDelete",
+ "None",
+ "ReadOnly"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the type of lock."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a lock.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ },
+ "managedIdentityAllType": {
+ "type": "object",
+ "properties": {
+ "systemAssigned": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enables system assigned managed identity on the resource."
+ }
+ },
+ "userAssignedResourceIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The resource ID(s) to assign to the resource. Required if a user assigned identity is used for encryption."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a managed identity configuration. To be used if both a system-assigned & user-assigned identities are supported by the resource provider.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ },
+ "privateEndpointSingleServiceType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of the Private Endpoint."
+ }
+ },
+ "location": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The location to deploy the Private Endpoint to."
+ }
+ },
+ "privateLinkServiceConnectionName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of the private link connection to create."
+ }
+ },
+ "service": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The subresource to deploy the Private Endpoint for. For example \"vault\" for a Key Vault Private Endpoint."
+ }
+ },
+ "subnetResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Resource ID of the subnet where the endpoint needs to be created."
+ }
+ },
+ "resourceGroupResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The resource ID of the Resource Group the Private Endpoint will be created in. If not specified, the Resource Group of the provided Virtual Network Subnet is used."
+ }
+ },
+ "privateDnsZoneGroup": {
+ "$ref": "#/definitions/_1.privateEndpointPrivateDnsZoneGroupType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The private DNS Zone Group to configure for the Private Endpoint."
+ }
+ },
+ "isManualConnection": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. If Manual Private Link Connection is required."
+ }
+ },
+ "manualConnectionRequestMessage": {
+ "type": "string",
+ "nullable": true,
+ "maxLength": 140,
+ "metadata": {
+ "description": "Optional. A message passed to the owner of the remote resource with the manual connection request."
+ }
+ },
+ "customDnsConfigs": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/_1.privateEndpointCustomDnsConfigType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Custom DNS configurations."
+ }
+ },
+ "ipConfigurations": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/_1.privateEndpointIpConfigurationType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. A list of IP configurations of the Private Endpoint. This will be used to map to the first-party Service endpoints."
+ }
+ },
+ "applicationSecurityGroupResourceIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Application security groups in which the Private Endpoint IP configuration is included."
+ }
+ },
+ "customNetworkInterfaceName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The custom name of the network interface attached to the Private Endpoint."
+ }
+ },
+ "lock": {
+ "$ref": "#/definitions/lockType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the type of lock."
+ }
+ },
+ "roleAssignments": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/roleAssignmentType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Array of role assignments to create."
+ }
+ },
+ "tags": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Tags to be applied on all resources/Resource Groups in this deployment."
+ }
+ },
+ "enableTelemetry": {
+ "type": "bool",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Enable/Disable usage telemetry for module."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a private endpoint. To be used if the private endpoint's default service / groupId can be assumed (i.e., for services that only have one Private Endpoint type like 'vault' for key vault).",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ },
+ "roleAssignmentType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name (as GUID) of the role assignment. If not provided, a GUID will be generated."
+ }
+ },
+ "roleDefinitionIdOrName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The role to assign. You can provide either the display name of the role definition, the role definition GUID, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'."
+ }
+ },
+ "principalId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The principal ID of the principal (user/group/identity) to assign the role to."
+ }
+ },
+ "principalType": {
+ "type": "string",
+ "allowedValues": [
+ "Device",
+ "ForeignGroup",
+ "Group",
+ "ServicePrincipal",
+ "User"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The principal type of the assigned principal ID."
+ }
+ },
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The description of the role assignment."
+ }
+ },
+ "condition": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase \"foo_storage_container\"."
+ }
+ },
+ "conditionVersion": {
+ "type": "string",
+ "allowedValues": [
+ "2.0"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Version of the condition."
+ }
+ },
+ "delegatedManagedIdentityResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The Resource Id of the delegated managed identity resource."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a role assignment.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ }
+ },
+ "parameters": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of the slot."
+ }
+ },
+ "appName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent site resource. Required if the template is used in a standalone deployment."
+ }
+ },
+ "location": {
+ "type": "string",
+ "defaultValue": "[resourceGroup().location]",
+ "metadata": {
+ "description": "Optional. Location for all Resources."
+ }
+ },
+ "kind": {
+ "type": "string",
+ "allowedValues": [
+ "functionapp",
+ "functionapp,linux",
+ "functionapp,workflowapp",
+ "functionapp,workflowapp,linux",
+ "functionapp,linux,container",
+ "functionapp,linux,container,azurecontainerapps",
+ "app,linux",
+ "app",
+ "linux,api",
+ "api",
+ "app,linux,container",
+ "app,container,windows"
+ ],
+ "metadata": {
+ "description": "Required. Type of site to deploy."
+ }
+ },
+ "serverFarmResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The resource ID of the app service plan to use for the slot."
+ }
+ },
+ "httpsOnly": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. Configures a slot to accept only HTTPS requests. Issues redirect for HTTP requests."
+ }
+ },
+ "clientAffinityEnabled": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. If client affinity is enabled."
+ }
+ },
+ "appServiceEnvironmentResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The resource ID of the app service environment to use for this resource."
+ }
+ },
+ "managedIdentities": {
+ "$ref": "#/definitions/managedIdentityAllType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The managed identity definition for this resource."
+ }
+ },
+ "keyVaultAccessIdentityResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The resource ID of the assigned identity to be used to access a key vault with."
+ }
+ },
+ "storageAccountRequired": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. Checks if Customer provided storage account is required."
+ }
+ },
+ "virtualNetworkSubnetId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Azure Resource Manager ID of the Virtual network and subnet to be joined by Regional VNET Integration. This must be of the form /subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}."
+ }
+ },
+ "siteConfig": {
+ "type": "object",
+ "defaultValue": {
+ "alwaysOn": true
+ },
+ "metadata": {
+ "description": "Optional. The site config object."
+ }
+ },
+ "functionAppConfig": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The Function App config object."
+ }
+ },
+ "storageAccountResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Required if app of kind functionapp. Resource ID of the storage account to manage triggers and logging function executions."
+ }
+ },
+ "storageAccountUseIdentityAuthentication": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. If the provided storage account requires Identity based authentication ('allowSharedKeyAccess' is set to false). When set to true, the minimum role assignment required for the App Service Managed Identity to the storage account is 'Storage Blob Data Owner'."
+ }
+ },
+ "appInsightResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the app insight to leverage for this resource."
+ }
+ },
+ "appSettingsKeyValuePairs": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The app settings-value pairs except for AzureWebJobsStorage, AzureWebJobsDashboard, APPINSIGHTS_INSTRUMENTATIONKEY and APPLICATIONINSIGHTS_CONNECTION_STRING."
+ }
+ },
+ "authSettingV2Configuration": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The auth settings V2 configuration."
+ }
+ },
+ "msDeployConfiguration": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The extension MSDeployment configuration."
+ }
+ },
+ "lock": {
+ "$ref": "#/definitions/lockType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The lock settings of the service."
+ }
+ },
+ "privateEndpoints": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/privateEndpointSingleServiceType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Configuration details for private endpoints."
+ }
+ },
+ "tags": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Tags of the resource."
+ }
+ },
+ "roleAssignments": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/roleAssignmentType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Array of role assignments to create."
+ }
+ },
+ "diagnosticSettings": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/diagnosticSettingFullType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The diagnostic settings of the service."
+ }
+ },
+ "clientCertEnabled": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. To enable client certificate authentication (TLS mutual authentication)."
+ }
+ },
+ "clientCertExclusionPaths": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Client certificate authentication comma-separated exclusion paths."
+ }
+ },
+ "clientCertMode": {
+ "type": "string",
+ "defaultValue": "Optional",
+ "allowedValues": [
+ "Optional",
+ "OptionalInteractiveUser",
+ "Required"
+ ],
+ "metadata": {
+ "description": "Optional. This composes with ClientCertEnabled setting.
- ClientCertEnabled: false means ClientCert is ignored.- ClientCertEnabled: true and ClientCertMode: Required means ClientCert is required.- ClientCertEnabled: true and ClientCertMode: Optional means ClientCert is optional or accepted."
+ }
+ },
+ "cloningInfo": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. If specified during app creation, the app is cloned from a source app."
+ }
+ },
+ "containerSize": {
+ "type": "int",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Size of the function container."
+ }
+ },
+ "customDomainVerificationId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Unique identifier that verifies the custom domains assigned to the app. Customer will add this ID to a txt record for verification."
+ }
+ },
+ "dailyMemoryTimeQuota": {
+ "type": "int",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Maximum allowed daily memory-time quota (applicable on dynamic apps only)."
+ }
+ },
+ "enabled": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. Setting this value to false disables the app (takes the app offline)."
+ }
+ },
+ "hostNameSslStates": {
+ "type": "array",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Hostname SSL states are used to manage the SSL bindings for app's hostnames."
+ }
+ },
+ "hyperV": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. Hyper-V sandbox."
+ }
+ },
+ "publicNetworkAccess": {
+ "type": "string",
+ "nullable": true,
+ "allowedValues": [
+ "Enabled",
+ "Disabled"
+ ],
+ "metadata": {
+ "description": "Optional. Allow or block all public traffic."
+ }
+ },
+ "redundancyMode": {
+ "type": "string",
+ "defaultValue": "None",
+ "allowedValues": [
+ "ActiveActive",
+ "Failover",
+ "GeoRedundant",
+ "Manual",
+ "None"
+ ],
+ "metadata": {
+ "description": "Optional. Site redundancy mode."
+ }
+ },
+ "basicPublishingCredentialsPolicies": {
+ "type": "array",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The site publishing credential policy names which are associated with the site slot."
+ }
+ },
+ "vnetContentShareEnabled": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. To enable accessing content over virtual network."
+ }
+ },
+ "vnetImagePullEnabled": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. To enable pulling image over Virtual Network."
+ }
+ },
+ "vnetRouteAllEnabled": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. Virtual Network Route All enabled. This causes all outbound traffic to have Virtual Network Security Groups and User Defined Routes applied."
+ }
+ },
+ "hybridConnectionRelays": {
+ "type": "array",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Names of hybrid connection relays to connect app with."
+ }
+ }
+ },
+ "variables": {
+ "copy": [
+ {
+ "name": "formattedRoleAssignments",
+ "count": "[length(coalesce(parameters('roleAssignments'), createArray()))]",
+ "input": "[union(coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')], createObject('roleDefinitionId', coalesce(tryGet(variables('builtInRoleNames'), coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName), if(contains(coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/'), coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName)))))]"
+ }
+ ],
+ "enableReferencedModulesTelemetry": false,
+ "formattedUserAssignedIdentities": "[reduce(map(coalesce(tryGet(parameters('managedIdentities'), 'userAssignedResourceIds'), createArray()), lambda('id', createObject(format('{0}', lambdaVariables('id')), createObject()))), createObject(), lambda('cur', 'next', union(lambdaVariables('cur'), lambdaVariables('next'))))]",
+ "identity": "[if(not(empty(parameters('managedIdentities'))), createObject('type', if(coalesce(tryGet(parameters('managedIdentities'), 'systemAssigned'), false()), if(not(empty(coalesce(tryGet(parameters('managedIdentities'), 'userAssignedResourceIds'), createObject()))), 'SystemAssigned, UserAssigned', 'SystemAssigned'), if(not(empty(coalesce(tryGet(parameters('managedIdentities'), 'userAssignedResourceIds'), createObject()))), 'UserAssigned', null())), 'userAssignedIdentities', if(not(empty(variables('formattedUserAssignedIdentities'))), variables('formattedUserAssignedIdentities'), null())), null())]",
+ "builtInRoleNames": {
+ "App Compliance Automation Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '0f37683f-2463-46b6-9ce7-9b788b988ba2')]",
+ "Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
+ "Owner": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]",
+ "Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'acdd72a7-3385-48ef-bd42-f606fba81ae7')]",
+ "Role Based Access Control Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'f58310d9-a9f6-439a-9e8d-f62e7b41a168')]",
+ "User Access Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '18d7d88d-d35e-4fb5-a5c3-7773c20a72d9')]",
+ "Web Plan Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '2cc479cb-7b4d-49a8-b449-8c00fd0f0a4b')]",
+ "Website Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'de139f84-1756-47ae-9be6-808fbbe84772')]"
+ }
+ },
+ "resources": {
+ "app": {
+ "existing": true,
+ "type": "Microsoft.Web/sites",
+ "apiVersion": "2024-04-01",
+ "name": "[parameters('appName')]"
+ },
+ "slot": {
+ "type": "Microsoft.Web/sites/slots",
+ "apiVersion": "2024-04-01",
+ "name": "[format('{0}/{1}', parameters('appName'), parameters('name'))]",
+ "location": "[parameters('location')]",
+ "kind": "[parameters('kind')]",
+ "tags": "[parameters('tags')]",
+ "identity": "[variables('identity')]",
+ "properties": {
+ "serverFarmId": "[parameters('serverFarmResourceId')]",
+ "clientAffinityEnabled": "[parameters('clientAffinityEnabled')]",
+ "httpsOnly": "[parameters('httpsOnly')]",
+ "hostingEnvironmentProfile": "[if(not(empty(parameters('appServiceEnvironmentResourceId'))), createObject('id', parameters('appServiceEnvironmentResourceId')), null())]",
+ "storageAccountRequired": "[parameters('storageAccountRequired')]",
+ "keyVaultReferenceIdentity": "[parameters('keyVaultAccessIdentityResourceId')]",
+ "virtualNetworkSubnetId": "[parameters('virtualNetworkSubnetId')]",
+ "siteConfig": "[parameters('siteConfig')]",
+ "functionAppConfig": "[parameters('functionAppConfig')]",
+ "clientCertEnabled": "[parameters('clientCertEnabled')]",
+ "clientCertExclusionPaths": "[parameters('clientCertExclusionPaths')]",
+ "clientCertMode": "[parameters('clientCertMode')]",
+ "cloningInfo": "[parameters('cloningInfo')]",
+ "containerSize": "[parameters('containerSize')]",
+ "customDomainVerificationId": "[parameters('customDomainVerificationId')]",
+ "dailyMemoryTimeQuota": "[parameters('dailyMemoryTimeQuota')]",
+ "enabled": "[parameters('enabled')]",
+ "hostNameSslStates": "[parameters('hostNameSslStates')]",
+ "hyperV": "[parameters('hyperV')]",
+ "publicNetworkAccess": "[parameters('publicNetworkAccess')]",
+ "redundancyMode": "[parameters('redundancyMode')]",
+ "vnetContentShareEnabled": "[parameters('vnetContentShareEnabled')]",
+ "vnetImagePullEnabled": "[parameters('vnetImagePullEnabled')]",
+ "vnetRouteAllEnabled": "[parameters('vnetRouteAllEnabled')]"
+ }
+ },
+ "slot_lock": {
+ "condition": "[and(not(empty(coalesce(parameters('lock'), createObject()))), not(equals(tryGet(parameters('lock'), 'kind'), 'None')))]",
+ "type": "Microsoft.Authorization/locks",
+ "apiVersion": "2020-05-01",
+ "scope": "[format('Microsoft.Web/sites/{0}/slots/{1}', parameters('appName'), parameters('name'))]",
+ "name": "[coalesce(tryGet(parameters('lock'), 'name'), format('lock-{0}', parameters('name')))]",
+ "properties": {
+ "level": "[coalesce(tryGet(parameters('lock'), 'kind'), '')]",
+ "notes": "[if(equals(tryGet(parameters('lock'), 'kind'), 'CanNotDelete'), 'Cannot delete resource or child resources.', 'Cannot delete or modify the resource or child resources.')]"
+ },
+ "dependsOn": [
+ "slot"
+ ]
+ },
+ "slot_diagnosticSettings": {
+ "copy": {
+ "name": "slot_diagnosticSettings",
+ "count": "[length(coalesce(parameters('diagnosticSettings'), createArray()))]"
+ },
+ "type": "Microsoft.Insights/diagnosticSettings",
+ "apiVersion": "2021-05-01-preview",
+ "scope": "[format('Microsoft.Web/sites/{0}/slots/{1}', parameters('appName'), parameters('name'))]",
+ "name": "[coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'name'), format('{0}-diagnosticSettings', parameters('name')))]",
+ "properties": {
+ "copy": [
+ {
+ "name": "metrics",
+ "count": "[length(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics'))))]",
+ "input": {
+ "category": "[coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics')))[copyIndex('metrics')].category]",
+ "enabled": "[coalesce(tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'metricCategories'), createArray(createObject('category', 'AllMetrics')))[copyIndex('metrics')], 'enabled'), true())]",
+ "timeGrain": null
+ }
+ },
+ {
+ "name": "logs",
+ "count": "[length(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs'))))]",
+ "input": {
+ "categoryGroup": "[tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'categoryGroup')]",
+ "category": "[tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'category')]",
+ "enabled": "[coalesce(tryGet(coalesce(tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logCategoriesAndGroups'), createArray(createObject('categoryGroup', 'allLogs')))[copyIndex('logs')], 'enabled'), true())]"
+ }
+ }
+ ],
+ "storageAccountId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'storageAccountResourceId')]",
+ "workspaceId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'workspaceResourceId')]",
+ "eventHubAuthorizationRuleId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'eventHubAuthorizationRuleResourceId')]",
+ "eventHubName": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'eventHubName')]",
+ "marketplacePartnerId": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'marketplacePartnerResourceId')]",
+ "logAnalyticsDestinationType": "[tryGet(coalesce(parameters('diagnosticSettings'), createArray())[copyIndex()], 'logAnalyticsDestinationType')]"
+ },
+ "dependsOn": [
+ "slot"
+ ]
+ },
+ "slot_roleAssignments": {
+ "copy": {
+ "name": "slot_roleAssignments",
+ "count": "[length(coalesce(variables('formattedRoleAssignments'), createArray()))]"
+ },
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Web/sites/{0}/slots/{1}', parameters('appName'), parameters('name'))]",
+ "name": "[coalesce(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'name'), guid(resourceId('Microsoft.Web/sites/slots', parameters('appName'), parameters('name')), coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].principalId, coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].roleDefinitionId))]",
+ "properties": {
+ "roleDefinitionId": "[coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].roleDefinitionId]",
+ "principalId": "[coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].principalId]",
+ "description": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'description')]",
+ "principalType": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'principalType')]",
+ "condition": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'condition')]",
+ "conditionVersion": "[if(not(empty(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'condition'))), coalesce(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'conditionVersion'), '2.0'), null())]",
+ "delegatedManagedIdentityResourceId": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'delegatedManagedIdentityResourceId')]"
+ },
+ "dependsOn": [
+ "slot"
+ ]
+ },
+ "slot_appsettings": {
+ "condition": "[or(or(not(empty(parameters('appSettingsKeyValuePairs'))), not(empty(parameters('appInsightResourceId')))), not(empty(parameters('storageAccountResourceId'))))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Slot-{1}-Config-AppSettings', uniqueString(deployment().name, parameters('location')), parameters('name'))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "slotName": {
+ "value": "[parameters('name')]"
+ },
+ "appName": {
+ "value": "[parameters('appName')]"
+ },
+ "kind": {
+ "value": "[parameters('kind')]"
+ },
+ "storageAccountResourceId": {
+ "value": "[parameters('storageAccountResourceId')]"
+ },
+ "storageAccountUseIdentityAuthentication": {
+ "value": "[parameters('storageAccountUseIdentityAuthentication')]"
+ },
+ "appInsightResourceId": {
+ "value": "[parameters('appInsightResourceId')]"
+ },
+ "appSettingsKeyValuePairs": {
+ "value": "[parameters('appSettingsKeyValuePairs')]"
+ },
+ "currentAppSettings": "[if(not(empty(resourceId('Microsoft.Web/sites/slots', parameters('appName'), parameters('name')))), createObject('value', list(format('{0}/config/appsettings', resourceId('Microsoft.Web/sites/slots', parameters('appName'), parameters('name'))), '2023-12-01').properties), createObject('value', createObject()))]"
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "18192409627790392598"
+ },
+ "name": "Site Slot App Settings",
+ "description": "This module deploys a Site Slot App Setting."
+ },
+ "parameters": {
+ "slotName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Slot name to be configured."
+ }
+ },
+ "appName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent site resource. Required if the template is used in a standalone deployment."
+ }
+ },
+ "kind": {
+ "type": "string",
+ "allowedValues": [
+ "functionapp",
+ "functionapp,linux",
+ "functionapp,workflowapp",
+ "functionapp,workflowapp,linux",
+ "functionapp,linux,container",
+ "functionapp,linux,container,azurecontainerapps",
+ "app,linux",
+ "app",
+ "linux,api",
+ "api",
+ "app,linux,container",
+ "app,container,windows"
+ ],
+ "metadata": {
+ "description": "Required. Type of site to deploy."
+ }
+ },
+ "storageAccountResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Required if app of kind functionapp. Resource ID of the storage account to manage triggers and logging function executions."
+ }
+ },
+ "storageAccountUseIdentityAuthentication": {
+ "type": "bool",
+ "defaultValue": false,
+ "metadata": {
+ "description": "Optional. If the provided storage account requires Identity based authentication ('allowSharedKeyAccess' is set to false). When set to true, the minimum role assignment required for the App Service Managed Identity to the storage account is 'Storage Blob Data Owner'."
+ }
+ },
+ "appInsightResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Resource ID of the app insight to leverage for this resource."
+ }
+ },
+ "appSettingsKeyValuePairs": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The app settings key-value pairs except for AzureWebJobsStorage, AzureWebJobsDashboard, APPINSIGHTS_INSTRUMENTATIONKEY and APPLICATIONINSIGHTS_CONNECTION_STRING."
+ }
+ },
+ "currentAppSettings": {
+ "type": "object",
+ "defaultValue": {},
+ "metadata": {
+ "description": "Optional. The current app settings."
+ }
+ }
+ },
+ "resources": {
+ "app::slot": {
+ "existing": true,
+ "type": "Microsoft.Web/sites/slots",
+ "apiVersion": "2024-04-01",
+ "name": "[format('{0}/{1}', parameters('appName'), parameters('slotName'))]"
+ },
+ "app": {
+ "existing": true,
+ "type": "Microsoft.Web/sites",
+ "apiVersion": "2024-04-01",
+ "name": "[parameters('appName')]"
+ },
+ "appInsight": {
+ "condition": "[not(empty(parameters('appInsightResourceId')))]",
+ "existing": true,
+ "type": "Microsoft.Insights/components",
+ "apiVersion": "2020-02-02",
+ "subscriptionId": "[split(parameters('appInsightResourceId'), '/')[2]]",
+ "resourceGroup": "[split(parameters('appInsightResourceId'), '/')[4]]",
+ "name": "[last(split(parameters('appInsightResourceId'), '/'))]"
+ },
+ "storageAccount": {
+ "condition": "[not(empty(parameters('storageAccountResourceId')))]",
+ "existing": true,
+ "type": "Microsoft.Storage/storageAccounts",
+ "apiVersion": "2023-05-01",
+ "subscriptionId": "[split(parameters('storageAccountResourceId'), '/')[2]]",
+ "resourceGroup": "[split(parameters('storageAccountResourceId'), '/')[4]]",
+ "name": "[last(split(parameters('storageAccountResourceId'), '/'))]"
+ },
+ "slotSettings": {
+ "type": "Microsoft.Web/sites/slots/config",
+ "apiVersion": "2024-04-01",
+ "name": "[format('{0}/{1}/{2}', parameters('appName'), parameters('slotName'), 'appsettings')]",
+ "kind": "[parameters('kind')]",
+ "properties": "[union(coalesce(parameters('currentAppSettings'), createObject()), coalesce(parameters('appSettingsKeyValuePairs'), createObject()), if(and(not(empty(parameters('storageAccountResourceId'))), not(parameters('storageAccountUseIdentityAuthentication'))), createObject('AzureWebJobsStorage', format('DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1};EndpointSuffix={2}', last(split(parameters('storageAccountResourceId'), '/')), listKeys(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(parameters('storageAccountResourceId'), '/')[2], split(parameters('storageAccountResourceId'), '/')[4]), 'Microsoft.Storage/storageAccounts', last(split(parameters('storageAccountResourceId'), '/'))), '2023-05-01').keys[0].value, environment().suffixes.storage)), if(and(not(empty(parameters('storageAccountResourceId'))), parameters('storageAccountUseIdentityAuthentication')), union(createObject('AzureWebJobsStorage__accountName', last(split(parameters('storageAccountResourceId'), '/'))), createObject('AzureWebJobsStorage__blobServiceUri', reference('storageAccount').primaryEndpoints.blob)), createObject())), if(not(empty(parameters('appInsightResourceId'))), createObject('APPLICATIONINSIGHTS_CONNECTION_STRING', reference('appInsight').ConnectionString), createObject()))]",
+ "dependsOn": [
+ "appInsight",
+ "storageAccount"
+ ]
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the slot config."
+ },
+ "value": "appsettings"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the slot config."
+ },
+ "value": "[resourceId('Microsoft.Web/sites/slots/config', parameters('appName'), parameters('slotName'), 'appsettings')]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group the slot config was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "slot"
+ ]
+ },
+ "slot_authsettingsv2": {
+ "condition": "[not(empty(parameters('authSettingV2Configuration')))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Slot-{1}-Config-AuthSettingsV2', uniqueString(deployment().name, parameters('location')), parameters('name'))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "slotName": {
+ "value": "[parameters('name')]"
+ },
+ "appName": {
+ "value": "[parameters('appName')]"
+ },
+ "kind": {
+ "value": "[parameters('kind')]"
+ },
+ "authSettingV2Configuration": {
+ "value": "[coalesce(parameters('authSettingV2Configuration'), createObject())]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "4602741618711602070"
+ },
+ "name": "Site Slot Auth Settings V2 Config",
+ "description": "This module deploys a Site Auth Settings V2 Configuration."
+ },
+ "parameters": {
+ "appName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent site resource. Required if the template is used in a standalone deployment."
+ }
+ },
+ "slotName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Slot name to be configured."
+ }
+ },
+ "kind": {
+ "type": "string",
+ "allowedValues": [
+ "functionapp",
+ "functionapp,linux",
+ "functionapp,workflowapp",
+ "functionapp,workflowapp,linux",
+ "functionapp,linux,container",
+ "functionapp,linux,container,azurecontainerapps",
+ "app,linux",
+ "app",
+ "linux,api",
+ "api",
+ "app,linux,container",
+ "app,container,windows"
+ ],
+ "metadata": {
+ "description": "Required. Type of site to deploy."
+ }
+ },
+ "authSettingV2Configuration": {
+ "type": "object",
+ "metadata": {
+ "description": "Required. The auth settings V2 configuration."
+ }
+ }
+ },
+ "resources": [
+ {
+ "type": "Microsoft.Web/sites/slots/config",
+ "apiVersion": "2024-04-01",
+ "name": "[format('{0}/{1}/{2}', parameters('appName'), parameters('slotName'), 'authsettingsV2')]",
+ "kind": "[parameters('kind')]",
+ "properties": "[parameters('authSettingV2Configuration')]"
+ }
+ ],
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the slot config."
+ },
+ "value": "authsettingsV2"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the slot config."
+ },
+ "value": "[resourceId('Microsoft.Web/sites/slots/config', parameters('appName'), parameters('slotName'), 'authsettingsV2')]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group the slot config was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "slot"
+ ]
+ },
+ "slot_basicPublishingCredentialsPolicies": {
+ "copy": {
+ "name": "slot_basicPublishingCredentialsPolicies",
+ "count": "[length(coalesce(parameters('basicPublishingCredentialsPolicies'), createArray()))]"
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Slot-Publish-Cred-{1}', uniqueString(deployment().name, parameters('location')), copyIndex())]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "appName": {
+ "value": "[parameters('appName')]"
+ },
+ "slotName": {
+ "value": "[parameters('name')]"
+ },
+ "name": {
+ "value": "[coalesce(parameters('basicPublishingCredentialsPolicies'), createArray())[copyIndex()].name]"
+ },
+ "allow": {
+ "value": "[tryGet(coalesce(parameters('basicPublishingCredentialsPolicies'), createArray())[copyIndex()], 'allow')]"
+ },
+ "location": {
+ "value": "[parameters('location')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "8803130402255189673"
+ },
+ "name": "Web Site Slot Basic Publishing Credentials Policies",
+ "description": "This module deploys a Web Site Slot Basic Publishing Credentials Policy."
+ },
+ "parameters": {
+ "name": {
+ "type": "string",
+ "allowedValues": [
+ "scm",
+ "ftp"
+ ],
+ "metadata": {
+ "description": "Required. The name of the resource."
+ }
+ },
+ "allow": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. Set to true to enable or false to disable a publishing method."
+ }
+ },
+ "appName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent web site. Required if the template is used in a standalone deployment."
+ }
+ },
+ "slotName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent web site slot. Required if the template is used in a standalone deployment."
+ }
+ },
+ "location": {
+ "type": "string",
+ "defaultValue": "[resourceGroup().location]",
+ "metadata": {
+ "description": "Optional. Location for all Resources."
+ }
+ }
+ },
+ "resources": [
+ {
+ "type": "Microsoft.Web/sites/slots/basicPublishingCredentialsPolicies",
+ "apiVersion": "2024-04-01",
+ "name": "[format('{0}/{1}/{2}', parameters('appName'), parameters('slotName'), parameters('name'))]",
+ "location": "[parameters('location')]",
+ "properties": {
+ "allow": "[parameters('allow')]"
+ }
+ }
+ ],
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the basic publishing credential policy."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the basic publishing credential policy."
+ },
+ "value": "[resourceId('Microsoft.Web/sites/slots/basicPublishingCredentialsPolicies', parameters('appName'), parameters('slotName'), parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the resource group the basic publishing credential policy was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ },
+ "location": {
+ "type": "string",
+ "metadata": {
+ "description": "The location the resource was deployed into."
+ },
+ "value": "[reference(resourceId('Microsoft.Web/sites/slots/basicPublishingCredentialsPolicies', parameters('appName'), parameters('slotName'), parameters('name')), '2024-04-01', 'full').location]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "slot"
+ ]
+ },
+ "slot_hybridConnectionRelays": {
+ "copy": {
+ "name": "slot_hybridConnectionRelays",
+ "count": "[length(coalesce(parameters('hybridConnectionRelays'), createArray()))]"
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Slot-HybridConnectionRelay-{1}', uniqueString(deployment().name, parameters('location')), copyIndex())]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "hybridConnectionResourceId": {
+ "value": "[coalesce(parameters('hybridConnectionRelays'), createArray())[copyIndex()].resourceId]"
+ },
+ "appName": {
+ "value": "[parameters('appName')]"
+ },
+ "slotName": {
+ "value": "[parameters('name')]"
+ },
+ "sendKeyName": {
+ "value": "[tryGet(coalesce(parameters('hybridConnectionRelays'), createArray())[copyIndex()], 'sendKeyName')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "16445776675656358479"
+ },
+ "name": "Web/Function Apps Slot Hybrid Connection Relay",
+ "description": "This module deploys a Site Slot Hybrid Connection Namespace Relay."
+ },
+ "parameters": {
+ "hybridConnectionResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The resource ID of the relay namespace hybrid connection."
+ }
+ },
+ "slotName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the site slot. Required if the template is used in a standalone deployment."
+ }
+ },
+ "appName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent web site. Required if the template is used in a standalone deployment."
+ }
+ },
+ "sendKeyName": {
+ "type": "string",
+ "defaultValue": "defaultSender",
+ "metadata": {
+ "description": "Optional. Name of the authorization rule send key to use."
+ }
+ }
+ },
+ "resources": [
+ {
+ "type": "Microsoft.Web/sites/slots/hybridConnectionNamespaces/relays",
+ "apiVersion": "2024-04-01",
+ "name": "[format('{0}/{1}/{2}/{3}', parameters('appName'), parameters('slotName'), split(parameters('hybridConnectionResourceId'), '/')[8], split(parameters('hybridConnectionResourceId'), '/')[10])]",
+ "properties": {
+ "serviceBusNamespace": "[split(parameters('hybridConnectionResourceId'), '/')[8]]",
+ "serviceBusSuffix": "[split(substring(reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(parameters('hybridConnectionResourceId'), '/')[2], split(parameters('hybridConnectionResourceId'), '/')[4]), 'Microsoft.Relay/namespaces', split(parameters('hybridConnectionResourceId'), '/')[8]), '2021-11-01').serviceBusEndpoint, indexOf(reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(parameters('hybridConnectionResourceId'), '/')[2], split(parameters('hybridConnectionResourceId'), '/')[4]), 'Microsoft.Relay/namespaces', split(parameters('hybridConnectionResourceId'), '/')[8]), '2021-11-01').serviceBusEndpoint, '.servicebus')), ':')[0]]",
+ "relayName": "[split(parameters('hybridConnectionResourceId'), '/')[10]]",
+ "relayArmUri": "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(parameters('hybridConnectionResourceId'), '/')[2], split(parameters('hybridConnectionResourceId'), '/')[4]), 'Microsoft.Relay/namespaces/hybridConnections', split(parameters('hybridConnectionResourceId'), '/')[8], split(parameters('hybridConnectionResourceId'), '/')[10])]",
+ "hostname": "[split(json(reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(parameters('hybridConnectionResourceId'), '/')[2], split(parameters('hybridConnectionResourceId'), '/')[4]), 'Microsoft.Relay/namespaces/hybridConnections', split(parameters('hybridConnectionResourceId'), '/')[8], split(parameters('hybridConnectionResourceId'), '/')[10]), '2021-11-01').userMetadata)[0].value, ':')[0]]",
+ "port": "[int(split(json(reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(parameters('hybridConnectionResourceId'), '/')[2], split(parameters('hybridConnectionResourceId'), '/')[4]), 'Microsoft.Relay/namespaces/hybridConnections', split(parameters('hybridConnectionResourceId'), '/')[8], split(parameters('hybridConnectionResourceId'), '/')[10]), '2021-11-01').userMetadata)[0].value, ':')[1])]",
+ "sendKeyName": "[parameters('sendKeyName')]",
+ "sendKeyValue": "[listKeys(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(parameters('hybridConnectionResourceId'), '/')[2], split(parameters('hybridConnectionResourceId'), '/')[4]), 'Microsoft.Relay/namespaces/hybridConnections/authorizationRules', split(parameters('hybridConnectionResourceId'), '/')[8], split(parameters('hybridConnectionResourceId'), '/')[10], parameters('sendKeyName')), '2021-11-01').primaryKey]"
+ }
+ }
+ ],
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the hybrid connection relay.."
+ },
+ "value": "[format('{0}/{1}/{2}/{3}', parameters('appName'), parameters('slotName'), split(parameters('hybridConnectionResourceId'), '/')[8], split(parameters('hybridConnectionResourceId'), '/')[10])]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the hybrid connection relay."
+ },
+ "value": "[resourceId('Microsoft.Web/sites/slots/hybridConnectionNamespaces/relays', split(format('{0}/{1}/{2}/{3}', parameters('appName'), parameters('slotName'), split(parameters('hybridConnectionResourceId'), '/')[8], split(parameters('hybridConnectionResourceId'), '/')[10]), '/')[0], split(format('{0}/{1}/{2}/{3}', parameters('appName'), parameters('slotName'), split(parameters('hybridConnectionResourceId'), '/')[8], split(parameters('hybridConnectionResourceId'), '/')[10]), '/')[1], split(format('{0}/{1}/{2}/{3}', parameters('appName'), parameters('slotName'), split(parameters('hybridConnectionResourceId'), '/')[8], split(parameters('hybridConnectionResourceId'), '/')[10]), '/')[2], split(format('{0}/{1}/{2}/{3}', parameters('appName'), parameters('slotName'), split(parameters('hybridConnectionResourceId'), '/')[8], split(parameters('hybridConnectionResourceId'), '/')[10]), '/')[3])]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the resource group the resource was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "slot"
+ ]
+ },
+ "slot_extensionMSdeploy": {
+ "condition": "[not(empty(parameters('msDeployConfiguration')))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Site-Extension-MSDeploy', uniqueString(deployment().name, parameters('location')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "appName": {
+ "value": "[parameters('appName')]"
+ },
+ "msDeployConfiguration": {
+ "value": "[coalesce(parameters('msDeployConfiguration'), createObject())]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "14895622660217616811"
+ },
+ "name": "Site Deployment Extension ",
+ "description": "This module deploys a Site extension for MSDeploy."
+ },
+ "parameters": {
+ "appName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the parent site resource."
+ }
+ },
+ "msDeployConfiguration": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Sets the MSDeployment Properties."
+ }
+ }
+ },
+ "resources": {
+ "app": {
+ "existing": true,
+ "type": "Microsoft.Web/sites",
+ "apiVersion": "2024-04-01",
+ "name": "[parameters('appName')]"
+ },
+ "msdeploy": {
+ "type": "Microsoft.Web/sites/extensions",
+ "apiVersion": "2024-04-01",
+ "name": "[format('{0}/{1}', parameters('appName'), 'MSDeploy')]",
+ "kind": "MSDeploy",
+ "properties": "[parameters('msDeployConfiguration')]"
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the MSDeploy Package."
+ },
+ "value": "MSDeploy"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the Site Extension."
+ },
+ "value": "[resourceId('Microsoft.Web/sites/extensions', parameters('appName'), 'MSDeploy')]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group the site config was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ }
+ },
+ "slot_privateEndpoints": {
+ "copy": {
+ "name": "slot_privateEndpoints",
+ "count": "[length(coalesce(parameters('privateEndpoints'), createArray()))]"
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-slot-PrivateEndpoint-{1}', uniqueString(deployment().name, parameters('location')), copyIndex())]",
+ "subscriptionId": "[split(coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'resourceGroupResourceId'), resourceGroup().id), '/')[2]]",
+ "resourceGroup": "[split(coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'resourceGroupResourceId'), resourceGroup().id), '/')[4]]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "name": {
+ "value": "[coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'name'), format('pep-{0}-{1}-{2}', last(split(resourceId('Microsoft.Web/sites', parameters('appName')), '/')), coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'service'), format('sites-{0}', parameters('name'))), copyIndex()))]"
+ },
+ "privateLinkServiceConnections": "[if(not(equals(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'isManualConnection'), true())), createObject('value', createArray(createObject('name', coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'privateLinkServiceConnectionName'), format('{0}-{1}-{2}', last(split(resourceId('Microsoft.Web/sites', parameters('appName')), '/')), coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'service'), format('sites-{0}', parameters('name'))), copyIndex())), 'properties', createObject('privateLinkServiceId', resourceId('Microsoft.Web/sites', parameters('appName')), 'groupIds', createArray(coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'service'), format('sites-{0}', parameters('name')))))))), createObject('value', null()))]",
+ "manualPrivateLinkServiceConnections": "[if(equals(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'isManualConnection'), true()), createObject('value', createArray(createObject('name', coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'privateLinkServiceConnectionName'), format('{0}-{1}-{2}', last(split(resourceId('Microsoft.Web/sites', parameters('appName')), '/')), coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'service'), format('sites-{0}', parameters('name'))), copyIndex())), 'properties', createObject('privateLinkServiceId', resourceId('Microsoft.Web/sites', parameters('appName')), 'groupIds', createArray(coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'service'), format('sites-{0}', parameters('name')))), 'requestMessage', coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'manualConnectionRequestMessage'), 'Manual approval required.'))))), createObject('value', null()))]",
+ "subnetResourceId": {
+ "value": "[coalesce(parameters('privateEndpoints'), createArray())[copyIndex()].subnetResourceId]"
+ },
+ "enableTelemetry": {
+ "value": "[variables('enableReferencedModulesTelemetry')]"
+ },
+ "location": {
+ "value": "[coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'location'), reference(split(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()].subnetResourceId, '/subnets/')[0], '2020-06-01', 'Full').location)]"
+ },
+ "lock": {
+ "value": "[coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'lock'), parameters('lock'))]"
+ },
+ "privateDnsZoneGroup": {
+ "value": "[tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'privateDnsZoneGroup')]"
+ },
+ "roleAssignments": {
+ "value": "[tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'roleAssignments')]"
+ },
+ "tags": {
+ "value": "[coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'tags'), parameters('tags'))]"
+ },
+ "customDnsConfigs": {
+ "value": "[tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'customDnsConfigs')]"
+ },
+ "ipConfigurations": {
+ "value": "[tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'ipConfigurations')]"
+ },
+ "applicationSecurityGroupResourceIds": {
+ "value": "[tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'applicationSecurityGroupResourceIds')]"
+ },
+ "customNetworkInterfaceName": {
+ "value": "[tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'customNetworkInterfaceName')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.13.18514",
+ "templateHash": "15954548978129725136"
+ },
+ "name": "Private Endpoints",
+ "description": "This module deploys a Private Endpoint."
+ },
+ "definitions": {
+ "privateDnsZoneGroupType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of the Private DNS Zone Group."
+ }
+ },
+ "privateDnsZoneGroupConfigs": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/privateDnsZoneGroupConfigType"
+ },
+ "metadata": {
+ "description": "Required. The private DNS zone groups to associate the private endpoint. A DNS zone group can support up to 5 DNS zones."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true
+ }
+ },
+ "ipConfigurationType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the resource that is unique within a resource group."
+ }
+ },
+ "properties": {
+ "type": "object",
+ "properties": {
+ "groupId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The ID of a group obtained from the remote resource that this private endpoint should connect to. If used with private link service connection, this property must be defined as empty string."
+ }
+ },
+ "memberName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The member name of a group obtained from the remote resource that this private endpoint should connect to. If used with private link service connection, this property must be defined as empty string."
+ }
+ },
+ "privateIPAddress": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. A private IP address obtained from the private endpoint's subnet."
+ }
+ }
+ },
+ "metadata": {
+ "description": "Required. Properties of private endpoint IP configurations."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true
+ }
+ },
+ "privateLinkServiceConnectionType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the private link service connection."
+ }
+ },
+ "properties": {
+ "type": "object",
+ "properties": {
+ "groupIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "metadata": {
+ "description": "Required. The ID of a group obtained from the remote resource that this private endpoint should connect to. If used with private link service connection, this property must be defined as empty string array `[]`."
+ }
+ },
+ "privateLinkServiceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The resource id of private link service."
+ }
+ },
+ "requestMessage": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. A message passed to the owner of the remote resource with this connection request. Restricted to 140 chars."
+ }
+ }
+ },
+ "metadata": {
+ "description": "Required. Properties of private link service connection."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true
+ }
+ },
+ "customDnsConfigType": {
+ "type": "object",
+ "properties": {
+ "fqdn": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. FQDN that resolves to private endpoint IP address."
+ }
+ },
+ "ipAddresses": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "metadata": {
+ "description": "Required. A list of private IP addresses of the private endpoint."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true
+ }
+ },
+ "lockType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the name of lock."
+ }
+ },
+ "kind": {
+ "type": "string",
+ "allowedValues": [
+ "CanNotDelete",
+ "None",
+ "ReadOnly"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the type of lock."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a lock.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ },
+ "privateDnsZoneGroupConfigType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of the private DNS zone group config."
+ }
+ },
+ "privateDnsZoneResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The resource id of the private DNS zone."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_imported_from!": {
+ "sourceTemplate": "private-dns-zone-group/main.bicep"
+ }
+ }
+ },
+ "roleAssignmentType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name (as GUID) of the role assignment. If not provided, a GUID will be generated."
+ }
+ },
+ "roleDefinitionIdOrName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The role to assign. You can provide either the display name of the role definition, the role definition GUID, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'."
+ }
+ },
+ "principalId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The principal ID of the principal (user/group/identity) to assign the role to."
+ }
+ },
+ "principalType": {
+ "type": "string",
+ "allowedValues": [
+ "Device",
+ "ForeignGroup",
+ "Group",
+ "ServicePrincipal",
+ "User"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The principal type of the assigned principal ID."
+ }
+ },
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The description of the role assignment."
+ }
+ },
+ "condition": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase \"foo_storage_container\"."
+ }
+ },
+ "conditionVersion": {
+ "type": "string",
+ "allowedValues": [
+ "2.0"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Version of the condition."
+ }
+ },
+ "delegatedManagedIdentityResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The Resource Id of the delegated managed identity resource."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a role assignment.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ }
+ },
+ "parameters": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of the private endpoint resource to create."
+ }
+ },
+ "subnetResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Resource ID of the subnet where the endpoint needs to be created."
+ }
+ },
+ "applicationSecurityGroupResourceIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Application security groups in which the private endpoint IP configuration is included."
+ }
+ },
+ "customNetworkInterfaceName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The custom name of the network interface attached to the private endpoint."
+ }
+ },
+ "ipConfigurations": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ipConfigurationType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. A list of IP configurations of the private endpoint. This will be used to map to the First Party Service endpoints."
+ }
+ },
+ "privateDnsZoneGroup": {
+ "$ref": "#/definitions/privateDnsZoneGroupType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The private DNS zone group to configure for the private endpoint."
+ }
+ },
+ "location": {
+ "type": "string",
+ "defaultValue": "[resourceGroup().location]",
+ "metadata": {
+ "description": "Optional. Location for all Resources."
+ }
+ },
+ "lock": {
+ "$ref": "#/definitions/lockType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The lock settings of the service."
+ }
+ },
+ "roleAssignments": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/roleAssignmentType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Array of role assignments to create."
+ }
+ },
+ "tags": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Tags to be applied on all resources/resource groups in this deployment."
+ }
+ },
+ "customDnsConfigs": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/customDnsConfigType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Custom DNS configurations."
+ }
+ },
+ "manualPrivateLinkServiceConnections": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/privateLinkServiceConnectionType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Conditional. A grouping of information about the connection to the remote resource. Used when the network admin does not have access to approve connections to the remote resource. Required if `privateLinkServiceConnections` is empty."
+ }
+ },
+ "privateLinkServiceConnections": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/privateLinkServiceConnectionType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Conditional. A grouping of information about the connection to the remote resource. Required if `manualPrivateLinkServiceConnections` is empty."
+ }
+ },
+ "enableTelemetry": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. Enable/Disable usage telemetry for module."
+ }
+ }
+ },
+ "variables": {
+ "copy": [
+ {
+ "name": "formattedRoleAssignments",
+ "count": "[length(coalesce(parameters('roleAssignments'), createArray()))]",
+ "input": "[union(coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')], createObject('roleDefinitionId', coalesce(tryGet(variables('builtInRoleNames'), coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName), if(contains(coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/'), coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName)))))]"
+ }
+ ],
+ "builtInRoleNames": {
+ "Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
+ "DNS Resolver Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '0f2ebee7-ffd4-4fc0-b3b7-664099fdad5d')]",
+ "DNS Zone Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'befefa01-2a29-4197-83a8-272ff33ce314')]",
+ "Domain Services Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'eeaeda52-9324-47f6-8069-5d5bade478b2')]",
+ "Domain Services Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '361898ef-9ed1-48c2-849c-a832951106bb')]",
+ "Network Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '4d97b98b-1d4f-4787-a291-c67834d212e7')]",
+ "Owner": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]",
+ "Private DNS Zone Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b12aa53e-6015-4669-85d0-8515ebb3ae7f')]",
+ "Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'acdd72a7-3385-48ef-bd42-f606fba81ae7')]",
+ "Role Based Access Control Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'f58310d9-a9f6-439a-9e8d-f62e7b41a168')]"
+ }
+ },
+ "resources": {
+ "avmTelemetry": {
+ "condition": "[parameters('enableTelemetry')]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2024-03-01",
+ "name": "[format('46d3xbcp.res.network-privateendpoint.{0}.{1}', replace('0.10.1', '.', '-'), substring(uniqueString(deployment().name, parameters('location')), 0, 4))]",
+ "properties": {
+ "mode": "Incremental",
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "resources": [],
+ "outputs": {
+ "telemetry": {
+ "type": "String",
+ "value": "For more information, see https://aka.ms/avm/TelemetryInfo"
+ }
+ }
+ }
+ }
+ },
+ "privateEndpoint": {
+ "type": "Microsoft.Network/privateEndpoints",
+ "apiVersion": "2023-11-01",
+ "name": "[parameters('name')]",
+ "location": "[parameters('location')]",
+ "tags": "[parameters('tags')]",
+ "properties": {
+ "copy": [
+ {
+ "name": "applicationSecurityGroups",
+ "count": "[length(coalesce(parameters('applicationSecurityGroupResourceIds'), createArray()))]",
+ "input": {
+ "id": "[coalesce(parameters('applicationSecurityGroupResourceIds'), createArray())[copyIndex('applicationSecurityGroups')]]"
+ }
+ }
+ ],
+ "customDnsConfigs": "[coalesce(parameters('customDnsConfigs'), createArray())]",
+ "customNetworkInterfaceName": "[coalesce(parameters('customNetworkInterfaceName'), '')]",
+ "ipConfigurations": "[coalesce(parameters('ipConfigurations'), createArray())]",
+ "manualPrivateLinkServiceConnections": "[coalesce(parameters('manualPrivateLinkServiceConnections'), createArray())]",
+ "privateLinkServiceConnections": "[coalesce(parameters('privateLinkServiceConnections'), createArray())]",
+ "subnet": {
+ "id": "[parameters('subnetResourceId')]"
+ }
+ }
+ },
+ "privateEndpoint_lock": {
+ "condition": "[and(not(empty(coalesce(parameters('lock'), createObject()))), not(equals(tryGet(parameters('lock'), 'kind'), 'None')))]",
+ "type": "Microsoft.Authorization/locks",
+ "apiVersion": "2020-05-01",
+ "scope": "[format('Microsoft.Network/privateEndpoints/{0}', parameters('name'))]",
+ "name": "[coalesce(tryGet(parameters('lock'), 'name'), format('lock-{0}', parameters('name')))]",
+ "properties": {
+ "level": "[coalesce(tryGet(parameters('lock'), 'kind'), '')]",
+ "notes": "[if(equals(tryGet(parameters('lock'), 'kind'), 'CanNotDelete'), 'Cannot delete resource or child resources.', 'Cannot delete or modify the resource or child resources.')]"
+ },
+ "dependsOn": [
+ "privateEndpoint"
+ ]
+ },
+ "privateEndpoint_roleAssignments": {
+ "copy": {
+ "name": "privateEndpoint_roleAssignments",
+ "count": "[length(coalesce(variables('formattedRoleAssignments'), createArray()))]"
+ },
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Network/privateEndpoints/{0}', parameters('name'))]",
+ "name": "[coalesce(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'name'), guid(resourceId('Microsoft.Network/privateEndpoints', parameters('name')), coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].principalId, coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].roleDefinitionId))]",
+ "properties": {
+ "roleDefinitionId": "[coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].roleDefinitionId]",
+ "principalId": "[coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].principalId]",
+ "description": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'description')]",
+ "principalType": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'principalType')]",
+ "condition": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'condition')]",
+ "conditionVersion": "[if(not(empty(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'condition'))), coalesce(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'conditionVersion'), '2.0'), null())]",
+ "delegatedManagedIdentityResourceId": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'delegatedManagedIdentityResourceId')]"
+ },
+ "dependsOn": [
+ "privateEndpoint"
+ ]
+ },
+ "privateEndpoint_privateDnsZoneGroup": {
+ "condition": "[not(empty(parameters('privateDnsZoneGroup')))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-PrivateEndpoint-PrivateDnsZoneGroup', uniqueString(deployment().name))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "name": {
+ "value": "[tryGet(parameters('privateDnsZoneGroup'), 'name')]"
+ },
+ "privateEndpointName": {
+ "value": "[parameters('name')]"
+ },
+ "privateDnsZoneConfigs": {
+ "value": "[parameters('privateDnsZoneGroup').privateDnsZoneGroupConfigs]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.13.18514",
+ "templateHash": "5440815542537978381"
+ },
+ "name": "Private Endpoint Private DNS Zone Groups",
+ "description": "This module deploys a Private Endpoint Private DNS Zone Group."
+ },
+ "definitions": {
+ "privateDnsZoneGroupConfigType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of the private DNS zone group config."
+ }
+ },
+ "privateDnsZoneResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The resource id of the private DNS zone."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true
+ }
+ }
+ },
+ "parameters": {
+ "privateEndpointName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent private endpoint. Required if the template is used in a standalone deployment."
+ }
+ },
+ "privateDnsZoneConfigs": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/privateDnsZoneGroupConfigType"
+ },
+ "minLength": 1,
+ "maxLength": 5,
+ "metadata": {
+ "description": "Required. Array of private DNS zone configurations of the private DNS zone group. A DNS zone group can support up to 5 DNS zones."
+ }
+ },
+ "name": {
+ "type": "string",
+ "defaultValue": "default",
+ "metadata": {
+ "description": "Optional. The name of the private DNS zone group."
+ }
+ }
+ },
+ "variables": {
+ "copy": [
+ {
+ "name": "privateDnsZoneConfigsVar",
+ "count": "[length(parameters('privateDnsZoneConfigs'))]",
+ "input": {
+ "name": "[coalesce(tryGet(parameters('privateDnsZoneConfigs')[copyIndex('privateDnsZoneConfigsVar')], 'name'), last(split(parameters('privateDnsZoneConfigs')[copyIndex('privateDnsZoneConfigsVar')].privateDnsZoneResourceId, '/')))]",
+ "properties": {
+ "privateDnsZoneId": "[parameters('privateDnsZoneConfigs')[copyIndex('privateDnsZoneConfigsVar')].privateDnsZoneResourceId]"
+ }
+ }
+ }
+ ]
+ },
+ "resources": {
+ "privateEndpoint": {
+ "existing": true,
+ "type": "Microsoft.Network/privateEndpoints",
+ "apiVersion": "2023-11-01",
+ "name": "[parameters('privateEndpointName')]"
+ },
+ "privateDnsZoneGroup": {
+ "type": "Microsoft.Network/privateEndpoints/privateDnsZoneGroups",
+ "apiVersion": "2023-11-01",
+ "name": "[format('{0}/{1}', parameters('privateEndpointName'), parameters('name'))]",
+ "properties": {
+ "privateDnsZoneConfigs": "[variables('privateDnsZoneConfigsVar')]"
+ }
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the private endpoint DNS zone group."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the private endpoint DNS zone group."
+ },
+ "value": "[resourceId('Microsoft.Network/privateEndpoints/privateDnsZoneGroups', parameters('privateEndpointName'), parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group the private endpoint DNS zone group was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "privateEndpoint"
+ ]
+ }
+ },
+ "outputs": {
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group the private endpoint was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the private endpoint."
+ },
+ "value": "[resourceId('Microsoft.Network/privateEndpoints', parameters('name'))]"
+ },
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the private endpoint."
+ },
+ "value": "[parameters('name')]"
+ },
+ "location": {
+ "type": "string",
+ "metadata": {
+ "description": "The location the resource was deployed into."
+ },
+ "value": "[reference('privateEndpoint', '2023-11-01', 'full').location]"
+ },
+ "customDnsConfigs": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/customDnsConfigType"
+ },
+ "metadata": {
+ "description": "The custom DNS configurations of the private endpoint."
+ },
+ "value": "[reference('privateEndpoint').customDnsConfigs]"
+ },
+ "networkInterfaceResourceIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "metadata": {
+ "description": "The resource IDs of the network interfaces associated with the private endpoint."
+ },
+ "value": "[map(reference('privateEndpoint').networkInterfaces, lambda('nic', lambdaVariables('nic').id))]"
+ },
+ "groupId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "The group Id for the private endpoint Group."
+ },
+ "value": "[coalesce(tryGet(tryGet(tryGet(tryGet(reference('privateEndpoint'), 'manualPrivateLinkServiceConnections'), 0, 'properties'), 'groupIds'), 0), tryGet(tryGet(tryGet(tryGet(reference('privateEndpoint'), 'privateLinkServiceConnections'), 0, 'properties'), 'groupIds'), 0))]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "slot"
+ ]
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the slot."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the slot."
+ },
+ "value": "[resourceId('Microsoft.Web/sites/slots', parameters('appName'), parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group the slot was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ },
+ "systemAssignedMIPrincipalId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "The principal ID of the system assigned identity."
+ },
+ "value": "[tryGet(tryGet(reference('slot', '2024-04-01', 'full'), 'identity'), 'principalId')]"
+ },
+ "location": {
+ "type": "string",
+ "metadata": {
+ "description": "The location the resource was deployed into."
+ },
+ "value": "[reference('slot', '2024-04-01', 'full').location]"
+ },
+ "privateEndpoints": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/privateEndpointOutputType"
+ },
+ "metadata": {
+ "description": "The private endpoints of the slot."
+ },
+ "copy": {
+ "count": "[length(coalesce(parameters('privateEndpoints'), createArray()))]",
+ "input": {
+ "name": "[reference(format('slot_privateEndpoints[{0}]', copyIndex())).outputs.name.value]",
+ "resourceId": "[reference(format('slot_privateEndpoints[{0}]', copyIndex())).outputs.resourceId.value]",
+ "groupId": "[tryGet(tryGet(reference(format('slot_privateEndpoints[{0}]', copyIndex())).outputs, 'groupId'), 'value')]",
+ "customDnsConfigs": "[reference(format('slot_privateEndpoints[{0}]', copyIndex())).outputs.customDnsConfigs.value]",
+ "networkInterfaceResourceIds": "[reference(format('slot_privateEndpoints[{0}]', copyIndex())).outputs.networkInterfaceResourceIds.value]"
+ }
+ }
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "app"
+ ]
+ },
+ "app_basicPublishingCredentialsPolicies": {
+ "copy": {
+ "name": "app_basicPublishingCredentialsPolicies",
+ "count": "[length(coalesce(parameters('basicPublishingCredentialsPolicies'), createArray()))]"
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-Site-Publish-Cred-{1}', uniqueString(deployment().name, parameters('location')), copyIndex())]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "webAppName": {
+ "value": "[parameters('name')]"
+ },
+ "name": {
+ "value": "[coalesce(parameters('basicPublishingCredentialsPolicies'), createArray())[copyIndex()].name]"
+ },
+ "allow": {
+ "value": "[tryGet(coalesce(parameters('basicPublishingCredentialsPolicies'), createArray())[copyIndex()], 'allow')]"
+ },
+ "location": {
+ "value": "[parameters('location')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "7001118912896436334"
+ },
+ "name": "Web Site Basic Publishing Credentials Policies",
+ "description": "This module deploys a Web Site Basic Publishing Credentials Policy."
+ },
+ "parameters": {
+ "name": {
+ "type": "string",
+ "allowedValues": [
+ "scm",
+ "ftp"
+ ],
+ "metadata": {
+ "description": "Required. The name of the resource."
+ }
+ },
+ "allow": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. Set to true to enable or false to disable a publishing method."
+ }
+ },
+ "webAppName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent web site. Required if the template is used in a standalone deployment."
+ }
+ },
+ "location": {
+ "type": "string",
+ "defaultValue": "[resourceGroup().location]",
+ "metadata": {
+ "description": "Optional. Location for all Resources."
+ }
+ }
+ },
+ "resources": [
+ {
+ "type": "Microsoft.Web/sites/basicPublishingCredentialsPolicies",
+ "apiVersion": "2024-04-01",
+ "name": "[format('{0}/{1}', parameters('webAppName'), parameters('name'))]",
+ "location": "[parameters('location')]",
+ "properties": {
+ "allow": "[parameters('allow')]"
+ }
+ }
+ ],
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the basic publishing credential policy."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the basic publishing credential policy."
+ },
+ "value": "[resourceId('Microsoft.Web/sites/basicPublishingCredentialsPolicies', parameters('webAppName'), parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the resource group the basic publishing credential policy was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ },
+ "location": {
+ "type": "string",
+ "metadata": {
+ "description": "The location the resource was deployed into."
+ },
+ "value": "[reference(resourceId('Microsoft.Web/sites/basicPublishingCredentialsPolicies', parameters('webAppName'), parameters('name')), '2024-04-01', 'full').location]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "app"
+ ]
+ },
+ "app_hybridConnectionRelays": {
+ "copy": {
+ "name": "app_hybridConnectionRelays",
+ "count": "[length(coalesce(parameters('hybridConnectionRelays'), createArray()))]"
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-HybridConnectionRelay-{1}', uniqueString(deployment().name, parameters('location')), copyIndex())]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "hybridConnectionResourceId": {
+ "value": "[coalesce(parameters('hybridConnectionRelays'), createArray())[copyIndex()].resourceId]"
+ },
+ "appName": {
+ "value": "[parameters('name')]"
+ },
+ "sendKeyName": {
+ "value": "[tryGet(coalesce(parameters('hybridConnectionRelays'), createArray())[copyIndex()], 'sendKeyName')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.93.31351",
+ "templateHash": "13214417392638890300"
+ },
+ "name": "Web/Function Apps Hybrid Connection Relay",
+ "description": "This module deploys a Site Hybrid Connection Namespace Relay."
+ },
+ "parameters": {
+ "hybridConnectionResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The resource ID of the relay namespace hybrid connection."
+ }
+ },
+ "appName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent web site. Required if the template is used in a standalone deployment."
+ }
+ },
+ "sendKeyName": {
+ "type": "string",
+ "defaultValue": "defaultSender",
+ "metadata": {
+ "description": "Optional. Name of the authorization rule send key to use."
+ }
+ }
+ },
+ "resources": [
+ {
+ "type": "Microsoft.Web/sites/hybridConnectionNamespaces/relays",
+ "apiVersion": "2024-04-01",
+ "name": "[format('{0}/{1}/{2}', parameters('appName'), split(parameters('hybridConnectionResourceId'), '/')[8], split(parameters('hybridConnectionResourceId'), '/')[10])]",
+ "properties": {
+ "serviceBusNamespace": "[split(parameters('hybridConnectionResourceId'), '/')[8]]",
+ "serviceBusSuffix": "[split(substring(reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(parameters('hybridConnectionResourceId'), '/')[2], split(parameters('hybridConnectionResourceId'), '/')[4]), 'Microsoft.Relay/namespaces', split(parameters('hybridConnectionResourceId'), '/')[8]), '2021-11-01').serviceBusEndpoint, indexOf(reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(parameters('hybridConnectionResourceId'), '/')[2], split(parameters('hybridConnectionResourceId'), '/')[4]), 'Microsoft.Relay/namespaces', split(parameters('hybridConnectionResourceId'), '/')[8]), '2021-11-01').serviceBusEndpoint, '.servicebus')), ':')[0]]",
+ "relayName": "[split(parameters('hybridConnectionResourceId'), '/')[10]]",
+ "relayArmUri": "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(parameters('hybridConnectionResourceId'), '/')[2], split(parameters('hybridConnectionResourceId'), '/')[4]), 'Microsoft.Relay/namespaces/hybridConnections', split(parameters('hybridConnectionResourceId'), '/')[8], split(parameters('hybridConnectionResourceId'), '/')[10])]",
+ "hostname": "[split(json(reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(parameters('hybridConnectionResourceId'), '/')[2], split(parameters('hybridConnectionResourceId'), '/')[4]), 'Microsoft.Relay/namespaces/hybridConnections', split(parameters('hybridConnectionResourceId'), '/')[8], split(parameters('hybridConnectionResourceId'), '/')[10]), '2021-11-01').userMetadata)[0].value, ':')[0]]",
+ "port": "[int(split(json(reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(parameters('hybridConnectionResourceId'), '/')[2], split(parameters('hybridConnectionResourceId'), '/')[4]), 'Microsoft.Relay/namespaces/hybridConnections', split(parameters('hybridConnectionResourceId'), '/')[8], split(parameters('hybridConnectionResourceId'), '/')[10]), '2021-11-01').userMetadata)[0].value, ':')[1])]",
+ "sendKeyName": "[parameters('sendKeyName')]",
+ "sendKeyValue": "[listKeys(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(parameters('hybridConnectionResourceId'), '/')[2], split(parameters('hybridConnectionResourceId'), '/')[4]), 'Microsoft.Relay/namespaces/hybridConnections/authorizationRules', split(parameters('hybridConnectionResourceId'), '/')[8], split(parameters('hybridConnectionResourceId'), '/')[10], parameters('sendKeyName')), '2021-11-01').primaryKey]"
+ }
+ }
+ ],
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the hybrid connection relay.."
+ },
+ "value": "[format('{0}/{1}/{2}', parameters('appName'), split(parameters('hybridConnectionResourceId'), '/')[8], split(parameters('hybridConnectionResourceId'), '/')[10])]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the hybrid connection relay."
+ },
+ "value": "[resourceId('Microsoft.Web/sites/hybridConnectionNamespaces/relays', split(format('{0}/{1}/{2}', parameters('appName'), split(parameters('hybridConnectionResourceId'), '/')[8], split(parameters('hybridConnectionResourceId'), '/')[10]), '/')[0], split(format('{0}/{1}/{2}', parameters('appName'), split(parameters('hybridConnectionResourceId'), '/')[8], split(parameters('hybridConnectionResourceId'), '/')[10]), '/')[1], split(format('{0}/{1}/{2}', parameters('appName'), split(parameters('hybridConnectionResourceId'), '/')[8], split(parameters('hybridConnectionResourceId'), '/')[10]), '/')[2])]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the resource group the resource was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "app"
+ ]
+ },
+ "app_privateEndpoints": {
+ "copy": {
+ "name": "app_privateEndpoints",
+ "count": "[length(coalesce(parameters('privateEndpoints'), createArray()))]"
+ },
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-app-PrivateEndpoint-{1}', uniqueString(deployment().name, parameters('location')), copyIndex())]",
+ "subscriptionId": "[split(coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'resourceGroupResourceId'), resourceGroup().id), '/')[2]]",
+ "resourceGroup": "[split(coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'resourceGroupResourceId'), resourceGroup().id), '/')[4]]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "name": {
+ "value": "[coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'name'), format('pep-{0}-{1}-{2}', last(split(resourceId('Microsoft.Web/sites', parameters('name')), '/')), coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'service'), 'sites'), copyIndex()))]"
+ },
+ "privateLinkServiceConnections": "[if(not(equals(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'isManualConnection'), true())), createObject('value', createArray(createObject('name', coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'privateLinkServiceConnectionName'), format('{0}-{1}-{2}', last(split(resourceId('Microsoft.Web/sites', parameters('name')), '/')), coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'service'), 'sites'), copyIndex())), 'properties', createObject('privateLinkServiceId', resourceId('Microsoft.Web/sites', parameters('name')), 'groupIds', createArray(coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'service'), 'sites')))))), createObject('value', null()))]",
+ "manualPrivateLinkServiceConnections": "[if(equals(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'isManualConnection'), true()), createObject('value', createArray(createObject('name', coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'privateLinkServiceConnectionName'), format('{0}-{1}-{2}', last(split(resourceId('Microsoft.Web/sites', parameters('name')), '/')), coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'service'), 'sites'), copyIndex())), 'properties', createObject('privateLinkServiceId', resourceId('Microsoft.Web/sites', parameters('name')), 'groupIds', createArray(coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'service'), 'sites')), 'requestMessage', coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'manualConnectionRequestMessage'), 'Manual approval required.'))))), createObject('value', null()))]",
+ "subnetResourceId": {
+ "value": "[coalesce(parameters('privateEndpoints'), createArray())[copyIndex()].subnetResourceId]"
+ },
+ "enableTelemetry": {
+ "value": "[variables('enableReferencedModulesTelemetry')]"
+ },
+ "location": {
+ "value": "[coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'location'), reference(split(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()].subnetResourceId, '/subnets/')[0], '2020-06-01', 'Full').location)]"
+ },
+ "lock": {
+ "value": "[coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'lock'), parameters('lock'))]"
+ },
+ "privateDnsZoneGroup": {
+ "value": "[tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'privateDnsZoneGroup')]"
+ },
+ "roleAssignments": {
+ "value": "[tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'roleAssignments')]"
+ },
+ "tags": {
+ "value": "[coalesce(tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'tags'), parameters('tags'))]"
+ },
+ "customDnsConfigs": {
+ "value": "[tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'customDnsConfigs')]"
+ },
+ "ipConfigurations": {
+ "value": "[tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'ipConfigurations')]"
+ },
+ "applicationSecurityGroupResourceIds": {
+ "value": "[tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'applicationSecurityGroupResourceIds')]"
+ },
+ "customNetworkInterfaceName": {
+ "value": "[tryGet(coalesce(parameters('privateEndpoints'), createArray())[copyIndex()], 'customNetworkInterfaceName')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.13.18514",
+ "templateHash": "15954548978129725136"
+ },
+ "name": "Private Endpoints",
+ "description": "This module deploys a Private Endpoint."
+ },
+ "definitions": {
+ "privateDnsZoneGroupType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of the Private DNS Zone Group."
+ }
+ },
+ "privateDnsZoneGroupConfigs": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/privateDnsZoneGroupConfigType"
+ },
+ "metadata": {
+ "description": "Required. The private DNS zone groups to associate the private endpoint. A DNS zone group can support up to 5 DNS zones."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true
+ }
+ },
+ "ipConfigurationType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the resource that is unique within a resource group."
+ }
+ },
+ "properties": {
+ "type": "object",
+ "properties": {
+ "groupId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The ID of a group obtained from the remote resource that this private endpoint should connect to. If used with private link service connection, this property must be defined as empty string."
+ }
+ },
+ "memberName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The member name of a group obtained from the remote resource that this private endpoint should connect to. If used with private link service connection, this property must be defined as empty string."
+ }
+ },
+ "privateIPAddress": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. A private IP address obtained from the private endpoint's subnet."
+ }
+ }
+ },
+ "metadata": {
+ "description": "Required. Properties of private endpoint IP configurations."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true
+ }
+ },
+ "privateLinkServiceConnectionType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The name of the private link service connection."
+ }
+ },
+ "properties": {
+ "type": "object",
+ "properties": {
+ "groupIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "metadata": {
+ "description": "Required. The ID of a group obtained from the remote resource that this private endpoint should connect to. If used with private link service connection, this property must be defined as empty string array `[]`."
+ }
+ },
+ "privateLinkServiceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The resource id of private link service."
+ }
+ },
+ "requestMessage": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. A message passed to the owner of the remote resource with this connection request. Restricted to 140 chars."
+ }
+ }
+ },
+ "metadata": {
+ "description": "Required. Properties of private link service connection."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true
+ }
+ },
+ "customDnsConfigType": {
+ "type": "object",
+ "properties": {
+ "fqdn": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. FQDN that resolves to private endpoint IP address."
+ }
+ },
+ "ipAddresses": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "metadata": {
+ "description": "Required. A list of private IP addresses of the private endpoint."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true
+ }
+ },
+ "lockType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the name of lock."
+ }
+ },
+ "kind": {
+ "type": "string",
+ "allowedValues": [
+ "CanNotDelete",
+ "None",
+ "ReadOnly"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Specify the type of lock."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a lock.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ },
+ "privateDnsZoneGroupConfigType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of the private DNS zone group config."
+ }
+ },
+ "privateDnsZoneResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The resource id of the private DNS zone."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_imported_from!": {
+ "sourceTemplate": "private-dns-zone-group/main.bicep"
+ }
+ }
+ },
+ "roleAssignmentType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name (as GUID) of the role assignment. If not provided, a GUID will be generated."
+ }
+ },
+ "roleDefinitionIdOrName": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The role to assign. You can provide either the display name of the role definition, the role definition GUID, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'."
+ }
+ },
+ "principalId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The principal ID of the principal (user/group/identity) to assign the role to."
+ }
+ },
+ "principalType": {
+ "type": "string",
+ "allowedValues": [
+ "Device",
+ "ForeignGroup",
+ "Group",
+ "ServicePrincipal",
+ "User"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The principal type of the assigned principal ID."
+ }
+ },
+ "description": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The description of the role assignment."
+ }
+ },
+ "condition": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase \"foo_storage_container\"."
+ }
+ },
+ "conditionVersion": {
+ "type": "string",
+ "allowedValues": [
+ "2.0"
+ ],
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Version of the condition."
+ }
+ },
+ "delegatedManagedIdentityResourceId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The Resource Id of the delegated managed identity resource."
+ }
+ }
+ },
+ "metadata": {
+ "description": "An AVM-aligned type for a role assignment.",
+ "__bicep_imported_from!": {
+ "sourceTemplate": "br:mcr.microsoft.com/bicep/avm/utl/types/avm-common-types:0.5.1"
+ }
+ }
+ }
+ },
+ "parameters": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Name of the private endpoint resource to create."
+ }
+ },
+ "subnetResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. Resource ID of the subnet where the endpoint needs to be created."
+ }
+ },
+ "applicationSecurityGroupResourceIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Application security groups in which the private endpoint IP configuration is included."
+ }
+ },
+ "customNetworkInterfaceName": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The custom name of the network interface attached to the private endpoint."
+ }
+ },
+ "ipConfigurations": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ipConfigurationType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. A list of IP configurations of the private endpoint. This will be used to map to the First Party Service endpoints."
+ }
+ },
+ "privateDnsZoneGroup": {
+ "$ref": "#/definitions/privateDnsZoneGroupType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The private DNS zone group to configure for the private endpoint."
+ }
+ },
+ "location": {
+ "type": "string",
+ "defaultValue": "[resourceGroup().location]",
+ "metadata": {
+ "description": "Optional. Location for all Resources."
+ }
+ },
+ "lock": {
+ "$ref": "#/definitions/lockType",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The lock settings of the service."
+ }
+ },
+ "roleAssignments": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/roleAssignmentType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Array of role assignments to create."
+ }
+ },
+ "tags": {
+ "type": "object",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Tags to be applied on all resources/resource groups in this deployment."
+ }
+ },
+ "customDnsConfigs": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/customDnsConfigType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. Custom DNS configurations."
+ }
+ },
+ "manualPrivateLinkServiceConnections": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/privateLinkServiceConnectionType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Conditional. A grouping of information about the connection to the remote resource. Used when the network admin does not have access to approve connections to the remote resource. Required if `privateLinkServiceConnections` is empty."
+ }
+ },
+ "privateLinkServiceConnections": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/privateLinkServiceConnectionType"
+ },
+ "nullable": true,
+ "metadata": {
+ "description": "Conditional. A grouping of information about the connection to the remote resource. Required if `manualPrivateLinkServiceConnections` is empty."
+ }
+ },
+ "enableTelemetry": {
+ "type": "bool",
+ "defaultValue": true,
+ "metadata": {
+ "description": "Optional. Enable/Disable usage telemetry for module."
+ }
+ }
+ },
+ "variables": {
+ "copy": [
+ {
+ "name": "formattedRoleAssignments",
+ "count": "[length(coalesce(parameters('roleAssignments'), createArray()))]",
+ "input": "[union(coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')], createObject('roleDefinitionId', coalesce(tryGet(variables('builtInRoleNames'), coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName), if(contains(coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName, '/providers/Microsoft.Authorization/roleDefinitions/'), coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', coalesce(parameters('roleAssignments'), createArray())[copyIndex('formattedRoleAssignments')].roleDefinitionIdOrName)))))]"
+ }
+ ],
+ "builtInRoleNames": {
+ "Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
+ "DNS Resolver Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '0f2ebee7-ffd4-4fc0-b3b7-664099fdad5d')]",
+ "DNS Zone Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'befefa01-2a29-4197-83a8-272ff33ce314')]",
+ "Domain Services Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'eeaeda52-9324-47f6-8069-5d5bade478b2')]",
+ "Domain Services Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '361898ef-9ed1-48c2-849c-a832951106bb')]",
+ "Network Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '4d97b98b-1d4f-4787-a291-c67834d212e7')]",
+ "Owner": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]",
+ "Private DNS Zone Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b12aa53e-6015-4669-85d0-8515ebb3ae7f')]",
+ "Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'acdd72a7-3385-48ef-bd42-f606fba81ae7')]",
+ "Role Based Access Control Administrator": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'f58310d9-a9f6-439a-9e8d-f62e7b41a168')]"
+ }
+ },
+ "resources": {
+ "avmTelemetry": {
+ "condition": "[parameters('enableTelemetry')]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2024-03-01",
+ "name": "[format('46d3xbcp.res.network-privateendpoint.{0}.{1}', replace('0.10.1', '.', '-'), substring(uniqueString(deployment().name, parameters('location')), 0, 4))]",
+ "properties": {
+ "mode": "Incremental",
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "resources": [],
+ "outputs": {
+ "telemetry": {
+ "type": "String",
+ "value": "For more information, see https://aka.ms/avm/TelemetryInfo"
+ }
+ }
+ }
+ }
+ },
+ "privateEndpoint": {
+ "type": "Microsoft.Network/privateEndpoints",
+ "apiVersion": "2023-11-01",
+ "name": "[parameters('name')]",
+ "location": "[parameters('location')]",
+ "tags": "[parameters('tags')]",
+ "properties": {
+ "copy": [
+ {
+ "name": "applicationSecurityGroups",
+ "count": "[length(coalesce(parameters('applicationSecurityGroupResourceIds'), createArray()))]",
+ "input": {
+ "id": "[coalesce(parameters('applicationSecurityGroupResourceIds'), createArray())[copyIndex('applicationSecurityGroups')]]"
+ }
+ }
+ ],
+ "customDnsConfigs": "[coalesce(parameters('customDnsConfigs'), createArray())]",
+ "customNetworkInterfaceName": "[coalesce(parameters('customNetworkInterfaceName'), '')]",
+ "ipConfigurations": "[coalesce(parameters('ipConfigurations'), createArray())]",
+ "manualPrivateLinkServiceConnections": "[coalesce(parameters('manualPrivateLinkServiceConnections'), createArray())]",
+ "privateLinkServiceConnections": "[coalesce(parameters('privateLinkServiceConnections'), createArray())]",
+ "subnet": {
+ "id": "[parameters('subnetResourceId')]"
+ }
+ }
+ },
+ "privateEndpoint_lock": {
+ "condition": "[and(not(empty(coalesce(parameters('lock'), createObject()))), not(equals(tryGet(parameters('lock'), 'kind'), 'None')))]",
+ "type": "Microsoft.Authorization/locks",
+ "apiVersion": "2020-05-01",
+ "scope": "[format('Microsoft.Network/privateEndpoints/{0}', parameters('name'))]",
+ "name": "[coalesce(tryGet(parameters('lock'), 'name'), format('lock-{0}', parameters('name')))]",
+ "properties": {
+ "level": "[coalesce(tryGet(parameters('lock'), 'kind'), '')]",
+ "notes": "[if(equals(tryGet(parameters('lock'), 'kind'), 'CanNotDelete'), 'Cannot delete resource or child resources.', 'Cannot delete or modify the resource or child resources.')]"
+ },
+ "dependsOn": [
+ "privateEndpoint"
+ ]
+ },
+ "privateEndpoint_roleAssignments": {
+ "copy": {
+ "name": "privateEndpoint_roleAssignments",
+ "count": "[length(coalesce(variables('formattedRoleAssignments'), createArray()))]"
+ },
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Network/privateEndpoints/{0}', parameters('name'))]",
+ "name": "[coalesce(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'name'), guid(resourceId('Microsoft.Network/privateEndpoints', parameters('name')), coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].principalId, coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].roleDefinitionId))]",
+ "properties": {
+ "roleDefinitionId": "[coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].roleDefinitionId]",
+ "principalId": "[coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()].principalId]",
+ "description": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'description')]",
+ "principalType": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'principalType')]",
+ "condition": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'condition')]",
+ "conditionVersion": "[if(not(empty(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'condition'))), coalesce(tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'conditionVersion'), '2.0'), null())]",
+ "delegatedManagedIdentityResourceId": "[tryGet(coalesce(variables('formattedRoleAssignments'), createArray())[copyIndex()], 'delegatedManagedIdentityResourceId')]"
+ },
+ "dependsOn": [
+ "privateEndpoint"
+ ]
+ },
+ "privateEndpoint_privateDnsZoneGroup": {
+ "condition": "[not(empty(parameters('privateDnsZoneGroup')))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2022-09-01",
+ "name": "[format('{0}-PrivateEndpoint-PrivateDnsZoneGroup', uniqueString(deployment().name))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "name": {
+ "value": "[tryGet(parameters('privateDnsZoneGroup'), 'name')]"
+ },
+ "privateEndpointName": {
+ "value": "[parameters('name')]"
+ },
+ "privateDnsZoneConfigs": {
+ "value": "[parameters('privateDnsZoneGroup').privateDnsZoneGroupConfigs]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "languageVersion": "2.0",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.33.13.18514",
+ "templateHash": "5440815542537978381"
+ },
+ "name": "Private Endpoint Private DNS Zone Groups",
+ "description": "This module deploys a Private Endpoint Private DNS Zone Group."
+ },
+ "definitions": {
+ "privateDnsZoneGroupConfigType": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "Optional. The name of the private DNS zone group config."
+ }
+ },
+ "privateDnsZoneResourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "Required. The resource id of the private DNS zone."
+ }
+ }
+ },
+ "metadata": {
+ "__bicep_export!": true
+ }
+ }
+ },
+ "parameters": {
+ "privateEndpointName": {
+ "type": "string",
+ "metadata": {
+ "description": "Conditional. The name of the parent private endpoint. Required if the template is used in a standalone deployment."
+ }
+ },
+ "privateDnsZoneConfigs": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/privateDnsZoneGroupConfigType"
+ },
+ "minLength": 1,
+ "maxLength": 5,
+ "metadata": {
+ "description": "Required. Array of private DNS zone configurations of the private DNS zone group. A DNS zone group can support up to 5 DNS zones."
+ }
+ },
+ "name": {
+ "type": "string",
+ "defaultValue": "default",
+ "metadata": {
+ "description": "Optional. The name of the private DNS zone group."
+ }
+ }
+ },
+ "variables": {
+ "copy": [
+ {
+ "name": "privateDnsZoneConfigsVar",
+ "count": "[length(parameters('privateDnsZoneConfigs'))]",
+ "input": {
+ "name": "[coalesce(tryGet(parameters('privateDnsZoneConfigs')[copyIndex('privateDnsZoneConfigsVar')], 'name'), last(split(parameters('privateDnsZoneConfigs')[copyIndex('privateDnsZoneConfigsVar')].privateDnsZoneResourceId, '/')))]",
+ "properties": {
+ "privateDnsZoneId": "[parameters('privateDnsZoneConfigs')[copyIndex('privateDnsZoneConfigsVar')].privateDnsZoneResourceId]"
+ }
+ }
+ }
+ ]
+ },
+ "resources": {
+ "privateEndpoint": {
+ "existing": true,
+ "type": "Microsoft.Network/privateEndpoints",
+ "apiVersion": "2023-11-01",
+ "name": "[parameters('privateEndpointName')]"
+ },
+ "privateDnsZoneGroup": {
+ "type": "Microsoft.Network/privateEndpoints/privateDnsZoneGroups",
+ "apiVersion": "2023-11-01",
+ "name": "[format('{0}/{1}', parameters('privateEndpointName'), parameters('name'))]",
+ "properties": {
+ "privateDnsZoneConfigs": "[variables('privateDnsZoneConfigsVar')]"
+ }
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the private endpoint DNS zone group."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the private endpoint DNS zone group."
+ },
+ "value": "[resourceId('Microsoft.Network/privateEndpoints/privateDnsZoneGroups', parameters('privateEndpointName'), parameters('name'))]"
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group the private endpoint DNS zone group was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "privateEndpoint"
+ ]
+ }
+ },
+ "outputs": {
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group the private endpoint was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the private endpoint."
+ },
+ "value": "[resourceId('Microsoft.Network/privateEndpoints', parameters('name'))]"
+ },
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the private endpoint."
+ },
+ "value": "[parameters('name')]"
+ },
+ "location": {
+ "type": "string",
+ "metadata": {
+ "description": "The location the resource was deployed into."
+ },
+ "value": "[reference('privateEndpoint', '2023-11-01', 'full').location]"
+ },
+ "customDnsConfigs": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/customDnsConfigType"
+ },
+ "metadata": {
+ "description": "The custom DNS configurations of the private endpoint."
+ },
+ "value": "[reference('privateEndpoint').customDnsConfigs]"
+ },
+ "networkInterfaceResourceIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "metadata": {
+ "description": "The resource IDs of the network interfaces associated with the private endpoint."
+ },
+ "value": "[map(reference('privateEndpoint').networkInterfaces, lambda('nic', lambdaVariables('nic').id))]"
+ },
+ "groupId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "The group Id for the private endpoint Group."
+ },
+ "value": "[coalesce(tryGet(tryGet(tryGet(tryGet(reference('privateEndpoint'), 'manualPrivateLinkServiceConnections'), 0, 'properties'), 'groupIds'), 0), tryGet(tryGet(tryGet(tryGet(reference('privateEndpoint'), 'privateLinkServiceConnections'), 0, 'properties'), 'groupIds'), 0))]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "app"
+ ]
+ }
+ },
+ "outputs": {
+ "name": {
+ "type": "string",
+ "metadata": {
+ "description": "The name of the site."
+ },
+ "value": "[parameters('name')]"
+ },
+ "resourceId": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource ID of the site."
+ },
+ "value": "[resourceId('Microsoft.Web/sites', parameters('name'))]"
+ },
+ "slots": {
+ "type": "array",
+ "metadata": {
+ "description": "The list of the slots."
+ },
+ "copy": {
+ "count": "[length(coalesce(parameters('slots'), createArray()))]",
+ "input": "[format('{0}-Slot-{1}', uniqueString(deployment().name, parameters('location')), coalesce(parameters('slots'), createArray())[copyIndex()].name)]"
+ }
+ },
+ "slotResourceIds": {
+ "type": "array",
+ "metadata": {
+ "description": "The list of the slot resource ids."
+ },
+ "copy": {
+ "count": "[length(coalesce(parameters('slots'), createArray()))]",
+ "input": "[reference(format('app_slots[{0}]', copyIndex())).outputs.resourceId.value]"
+ }
+ },
+ "resourceGroupName": {
+ "type": "string",
+ "metadata": {
+ "description": "The resource group the site was deployed into."
+ },
+ "value": "[resourceGroup().name]"
+ },
+ "systemAssignedMIPrincipalId": {
+ "type": "string",
+ "nullable": true,
+ "metadata": {
+ "description": "The principal ID of the system assigned identity."
+ },
+ "value": "[tryGet(tryGet(reference('app', '2024-04-01', 'full'), 'identity'), 'principalId')]"
+ },
+ "slotSystemAssignedMIPrincipalIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "metadata": {
+ "description": "The principal ID of the system assigned identity of slots."
+ },
+ "copy": {
+ "count": "[length(coalesce(parameters('slots'), createArray()))]",
+ "input": "[coalesce(tryGet(tryGet(reference(format('app_slots[{0}]', copyIndex())).outputs, 'systemAssignedMIPrincipalId'), 'value'), '')]"
+ }
+ },
+ "location": {
+ "type": "string",
+ "metadata": {
+ "description": "The location the resource was deployed into."
+ },
+ "value": "[reference('app', '2024-04-01', 'full').location]"
+ },
+ "defaultHostname": {
+ "type": "string",
+ "metadata": {
+ "description": "Default hostname of the app."
+ },
+ "value": "[reference('app').defaultHostName]"
+ },
+ "customDomainVerificationId": {
+ "type": "string",
+ "metadata": {
+ "description": "Unique identifier that verifies the custom domains assigned to the app. Customer will add this ID to a txt record for verification."
+ },
+ "value": "[reference('app').customDomainVerificationId]"
+ },
+ "privateEndpoints": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/privateEndpointOutputType"
+ },
+ "metadata": {
+ "description": "The private endpoints of the site."
+ },
+ "copy": {
+ "count": "[length(coalesce(parameters('privateEndpoints'), createArray()))]",
+ "input": {
+ "name": "[reference(format('app_privateEndpoints[{0}]', copyIndex())).outputs.name.value]",
+ "resourceId": "[reference(format('app_privateEndpoints[{0}]', copyIndex())).outputs.resourceId.value]",
+ "groupId": "[tryGet(tryGet(reference(format('app_privateEndpoints[{0}]', copyIndex())).outputs, 'groupId'), 'value')]",
+ "customDnsConfigs": "[reference(format('app_privateEndpoints[{0}]', copyIndex())).outputs.customDnsConfigs.value]",
+ "networkInterfaceResourceIds": "[reference(format('app_privateEndpoints[{0}]', copyIndex())).outputs.networkInterfaceResourceIds.value]"
+ }
+ }
+ },
+ "slotPrivateEndpoints": {
+ "type": "array",
+ "metadata": {
+ "description": "The private endpoints of the slots."
+ },
+ "copy": {
+ "count": "[length(coalesce(parameters('slots'), createArray()))]",
+ "input": "[reference(format('app_slots[{0}]', copyIndex())).outputs.privateEndpoints.value]"
+ }
+ },
+ "outboundIpAddresses": {
+ "type": "string",
+ "metadata": {
+ "description": "The outbound IP addresses of the app."
+ },
+ "value": "[reference('app').outboundIpAddresses]"
+ }
+ }
+ }
+ }
+ }
+ ],
+ "outputs": {
+ "SERVICE_API_NAME": {
+ "type": "string",
+ "value": "[reference(resourceId('Microsoft.Resources/deployments', format('{0}-flex-consumption', parameters('serviceName'))), '2025-04-01').outputs.name.value]"
+ },
+ "SERVICE_API_IDENTITY_PRINCIPAL_ID": {
+ "type": "string",
+ "value": "[if(equals(parameters('identityType'), 'SystemAssigned'), coalesce(tryGet(tryGet(reference(resourceId('Microsoft.Resources/deployments', format('{0}-flex-consumption', parameters('serviceName'))), '2025-04-01').outputs, 'systemAssignedMIPrincipalId'), 'value'), ''), '')]"
+ }
+ }
+ }
+ },
+ "dependsOn": [
+ "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix')))]",
+ "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('{0}{1}deployment', variables('projectName'), variables('uniqueSuffix')))]",
+ "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'apiUserAssignedIdentity')]",
+ "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'appserviceplan')]",
+ "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('{0}-appinsights', uniqueString(deployment().name, parameters('location'))))]",
+ "[subscriptionResourceId('Microsoft.Resources/resourceGroups', if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName'))))]",
+ "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'storage')]"
+ ]
+ },
+ {
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2025-04-01",
+ "name": "[format('aiprojectroleassignments{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))]",
+ "resourceGroup": "[if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "aiProjectPrincipalId": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.aiProjectPrincipalId.value]"
+ },
+ "userPrincipalId": {
+ "value": "[parameters('principalId')]"
+ },
+ "allowUserIdentityPrincipal": {
+ "value": "[not(empty(parameters('principalId')))]"
+ },
+ "aiServicesName": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.aiServicesName.value]"
+ },
+ "aiSearchName": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.aiSearchName.value]"
+ },
+ "aiCosmosDbName": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.cosmosDbAccountName.value]"
+ },
+ "aiStorageAccountName": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.storageAccountName.value]"
+ },
+ "integrationStorageAccountName": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'storage'), '2025-04-01').outputs.name.value]"
+ },
+ "functionAppManagedIdentityPrincipalId": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'apiUserAssignedIdentity'), '2025-04-01').outputs.principalId.value]"
+ },
+ "allowFunctionAppIdentityPrincipal": {
+ "value": true
+ },
+ "enableAzureSearch": {
+ "value": "[parameters('enableAzureSearch')]"
+ },
+ "enableCosmosDb": {
+ "value": "[parameters('enableCosmosDb')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.39.26.7824",
+ "templateHash": "6119076529866252902"
+ }
+ },
+ "parameters": {
+ "aiProjectPrincipalId": {
+ "type": "string"
+ },
+ "aiProjectPrincipalType": {
+ "type": "string",
+ "defaultValue": "ServicePrincipal"
+ },
+ "userPrincipalId": {
+ "type": "string",
+ "defaultValue": ""
+ },
+ "allowUserIdentityPrincipal": {
+ "type": "bool",
+ "defaultValue": false
+ },
+ "aiServicesName": {
+ "type": "string"
+ },
+ "aiSearchName": {
+ "type": "string"
+ },
+ "aiCosmosDbName": {
+ "type": "string"
+ },
+ "aiStorageAccountName": {
+ "type": "string"
+ },
+ "integrationStorageAccountName": {
+ "type": "string"
+ },
+ "functionAppManagedIdentityPrincipalId": {
+ "type": "string",
+ "defaultValue": ""
+ },
+ "allowFunctionAppIdentityPrincipal": {
+ "type": "bool",
+ "defaultValue": true
+ },
+ "enableAzureSearch": {
+ "type": "bool",
+ "defaultValue": false
+ },
+ "enableCosmosDb": {
+ "type": "bool",
+ "defaultValue": false
+ }
+ },
+ "variables": {
+ "cognitiveServicesContributorRoleDefinitionId": "25fbc0a9-bd7c-42a3-aa1a-3b75d497ee68",
+ "cognitiveServicesOpenAIUserRoleDefinitionId": "5e0bd9bd-7b93-4f28-af87-19fc36ad61bd",
+ "cognitiveServicesUserRoleDefinitionId": "a97b65f3-24c7-4388-baec-2e87135dc908",
+ "searchIndexDataContributorRoleDefinitionId": "8ebe5a00-799e-43f5-93ac-243d3dce84a7",
+ "searchServiceContributorRoleDefinitionId": "7ca78c08-252a-4471-8644-bb5ff32d4ba0",
+ "storageBlobDataContributorRoleDefinitionId": "ba92f5b4-2d11-453d-a403-e96b0029c9fe",
+ "cosmosDbOperatorRoleDefinitionId": "230815da-be43-4aae-9cb4-875f7bd000aa",
+ "storageQueueDataContributorRoleDefinitionId": "974c5e8b-45b9-4653-ba55-5f855dd0fb88"
+ },
+ "resources": [
+ {
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.CognitiveServices/accounts/{0}', parameters('aiServicesName'))]",
+ "name": "[guid(resourceId('Microsoft.CognitiveServices/accounts', parameters('aiServicesName')), variables('cognitiveServicesContributorRoleDefinitionId'), parameters('aiProjectPrincipalId'))]",
+ "properties": {
+ "principalId": "[parameters('aiProjectPrincipalId')]",
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('cognitiveServicesContributorRoleDefinitionId'))]",
+ "principalType": "[parameters('aiProjectPrincipalType')]"
+ }
+ },
+ {
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.CognitiveServices/accounts/{0}', parameters('aiServicesName'))]",
+ "name": "[guid(parameters('aiProjectPrincipalId'), variables('cognitiveServicesOpenAIUserRoleDefinitionId'), resourceId('Microsoft.CognitiveServices/accounts', parameters('aiServicesName')))]",
+ "properties": {
+ "principalId": "[parameters('aiProjectPrincipalId')]",
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('cognitiveServicesOpenAIUserRoleDefinitionId'))]",
+ "principalType": "[parameters('aiProjectPrincipalType')]"
+ }
+ },
+ {
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.CognitiveServices/accounts/{0}', parameters('aiServicesName'))]",
+ "name": "[guid(parameters('aiProjectPrincipalId'), variables('cognitiveServicesUserRoleDefinitionId'), resourceId('Microsoft.CognitiveServices/accounts', parameters('aiServicesName')))]",
+ "properties": {
+ "principalId": "[parameters('aiProjectPrincipalId')]",
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('cognitiveServicesUserRoleDefinitionId'))]",
+ "principalType": "[parameters('aiProjectPrincipalType')]"
+ }
+ },
+ {
+ "condition": "[and(parameters('allowUserIdentityPrincipal'), not(empty(parameters('userPrincipalId'))))]",
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.CognitiveServices/accounts/{0}', parameters('aiServicesName'))]",
+ "name": "[guid(resourceId('Microsoft.CognitiveServices/accounts', parameters('aiServicesName')), variables('cognitiveServicesContributorRoleDefinitionId'), parameters('userPrincipalId'))]",
+ "properties": {
+ "principalId": "[parameters('userPrincipalId')]",
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('cognitiveServicesContributorRoleDefinitionId'))]",
+ "principalType": "User"
+ }
+ },
+ {
+ "condition": "[and(parameters('allowUserIdentityPrincipal'), not(empty(parameters('userPrincipalId'))))]",
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.CognitiveServices/accounts/{0}', parameters('aiServicesName'))]",
+ "name": "[guid(parameters('userPrincipalId'), variables('cognitiveServicesOpenAIUserRoleDefinitionId'), resourceId('Microsoft.CognitiveServices/accounts', parameters('aiServicesName')))]",
+ "properties": {
+ "principalId": "[parameters('userPrincipalId')]",
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('cognitiveServicesOpenAIUserRoleDefinitionId'))]",
+ "principalType": "User"
+ }
+ },
+ {
+ "condition": "[and(parameters('allowUserIdentityPrincipal'), not(empty(parameters('userPrincipalId'))))]",
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.CognitiveServices/accounts/{0}', parameters('aiServicesName'))]",
+ "name": "[guid(parameters('userPrincipalId'), variables('cognitiveServicesUserRoleDefinitionId'), resourceId('Microsoft.CognitiveServices/accounts', parameters('aiServicesName')))]",
+ "properties": {
+ "principalId": "[parameters('userPrincipalId')]",
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('cognitiveServicesUserRoleDefinitionId'))]",
+ "principalType": "User"
+ }
+ },
+ {
+ "condition": "[parameters('enableAzureSearch')]",
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Search/searchServices/{0}', parameters('aiSearchName'))]",
+ "name": "[guid(parameters('aiProjectPrincipalId'), variables('searchIndexDataContributorRoleDefinitionId'), resourceId('Microsoft.Search/searchServices', parameters('aiSearchName')))]",
+ "properties": {
+ "principalId": "[parameters('aiProjectPrincipalId')]",
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('searchIndexDataContributorRoleDefinitionId'))]",
+ "principalType": "[parameters('aiProjectPrincipalType')]"
+ }
+ },
+ {
+ "condition": "[parameters('enableAzureSearch')]",
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Search/searchServices/{0}', parameters('aiSearchName'))]",
+ "name": "[guid(parameters('aiProjectPrincipalId'), variables('searchServiceContributorRoleDefinitionId'), resourceId('Microsoft.Search/searchServices', parameters('aiSearchName')))]",
+ "properties": {
+ "principalId": "[parameters('aiProjectPrincipalId')]",
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('searchServiceContributorRoleDefinitionId'))]",
+ "principalType": "[parameters('aiProjectPrincipalType')]"
+ }
+ },
+ {
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Storage/storageAccounts/{0}', parameters('aiStorageAccountName'))]",
+ "name": "[guid(parameters('aiProjectPrincipalId'), variables('storageBlobDataContributorRoleDefinitionId'), resourceId('Microsoft.Storage/storageAccounts', parameters('aiStorageAccountName')))]",
+ "properties": {
+ "principalId": "[parameters('aiProjectPrincipalId')]",
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('storageBlobDataContributorRoleDefinitionId'))]",
+ "principalType": "[parameters('aiProjectPrincipalType')]"
+ }
+ },
+ {
+ "condition": "[parameters('enableCosmosDb')]",
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.DocumentDB/databaseAccounts/{0}', parameters('aiCosmosDbName'))]",
+ "name": "[guid(parameters('aiProjectPrincipalId'), variables('cosmosDbOperatorRoleDefinitionId'), resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('aiCosmosDbName')))]",
+ "properties": {
+ "principalId": "[parameters('aiProjectPrincipalId')]",
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('cosmosDbOperatorRoleDefinitionId'))]",
+ "principalType": "[parameters('aiProjectPrincipalType')]"
+ }
+ },
+ {
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Storage/storageAccounts/{0}', parameters('integrationStorageAccountName'))]",
+ "name": "[guid(resourceId('Microsoft.Storage/storageAccounts', parameters('integrationStorageAccountName')), parameters('aiProjectPrincipalId'), variables('storageQueueDataContributorRoleDefinitionId'))]",
+ "properties": {
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('storageQueueDataContributorRoleDefinitionId'))]",
+ "principalId": "[parameters('aiProjectPrincipalId')]",
+ "principalType": "[parameters('aiProjectPrincipalType')]"
+ }
+ },
+ {
+ "condition": "[and(parameters('allowUserIdentityPrincipal'), not(empty(parameters('userPrincipalId'))))]",
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Storage/storageAccounts/{0}', parameters('integrationStorageAccountName'))]",
+ "name": "[guid(resourceId('Microsoft.Storage/storageAccounts', parameters('integrationStorageAccountName')), parameters('userPrincipalId'), variables('storageQueueDataContributorRoleDefinitionId'))]",
+ "properties": {
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('storageQueueDataContributorRoleDefinitionId'))]",
+ "principalId": "[parameters('userPrincipalId')]",
+ "principalType": "User"
+ }
+ },
+ {
+ "condition": "[and(parameters('allowFunctionAppIdentityPrincipal'), not(empty(parameters('functionAppManagedIdentityPrincipalId'))))]",
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.CognitiveServices/accounts/{0}', parameters('aiServicesName'))]",
+ "name": "[guid(resourceId('Microsoft.CognitiveServices/accounts', parameters('aiServicesName')), variables('cognitiveServicesContributorRoleDefinitionId'), parameters('functionAppManagedIdentityPrincipalId'))]",
+ "properties": {
+ "principalId": "[parameters('functionAppManagedIdentityPrincipalId')]",
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('cognitiveServicesContributorRoleDefinitionId'))]",
+ "principalType": "ServicePrincipal"
+ }
+ },
+ {
+ "condition": "[and(parameters('allowFunctionAppIdentityPrincipal'), not(empty(parameters('functionAppManagedIdentityPrincipalId'))))]",
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.CognitiveServices/accounts/{0}', parameters('aiServicesName'))]",
+ "name": "[guid(parameters('functionAppManagedIdentityPrincipalId'), variables('cognitiveServicesOpenAIUserRoleDefinitionId'), resourceId('Microsoft.CognitiveServices/accounts', parameters('aiServicesName')))]",
+ "properties": {
+ "principalId": "[parameters('functionAppManagedIdentityPrincipalId')]",
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('cognitiveServicesOpenAIUserRoleDefinitionId'))]",
+ "principalType": "ServicePrincipal"
+ }
+ },
+ {
+ "condition": "[and(parameters('allowFunctionAppIdentityPrincipal'), not(empty(parameters('functionAppManagedIdentityPrincipalId'))))]",
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.CognitiveServices/accounts/{0}', parameters('aiServicesName'))]",
+ "name": "[guid(parameters('functionAppManagedIdentityPrincipalId'), variables('cognitiveServicesUserRoleDefinitionId'), resourceId('Microsoft.CognitiveServices/accounts', parameters('aiServicesName')))]",
+ "properties": {
+ "principalId": "[parameters('functionAppManagedIdentityPrincipalId')]",
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('cognitiveServicesUserRoleDefinitionId'))]",
+ "principalType": "ServicePrincipal"
+ }
+ }
+ ]
+ }
+ },
+ "dependsOn": [
+ "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix')))]",
+ "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('{0}{1}deployment', variables('projectName'), variables('uniqueSuffix')))]",
+ "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'apiUserAssignedIdentity')]",
+ "[subscriptionResourceId('Microsoft.Resources/resourceGroups', if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName'))))]",
+ "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'storage')]"
+ ]
+ },
+ {
+ "condition": "[and(parameters('enableAzureSearch'), parameters('enableCosmosDb'))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2025-04-01",
+ "name": "[format('capabilityhost{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))]",
+ "resourceGroup": "[if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "aiServicesAccountName": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.aiServicesName.value]"
+ },
+ "projectName": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.aiProjectName.value]"
+ },
+ "aiSearchConnection": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.aiSearchConnection.value]"
+ },
+ "azureStorageConnection": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.azureStorageConnection.value]"
+ },
+ "cosmosDbConnection": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.cosmosDbConnection.value]"
+ },
+ "accountCapHost": {
+ "value": "[format('{0}{1}', parameters('accountCapabilityHostName'), variables('uniqueSuffix'))]"
+ },
+ "projectCapHost": {
+ "value": "[format('{0}{1}', parameters('projectCapabilityHostName'), variables('uniqueSuffix'))]"
+ },
+ "enableAzureSearch": {
+ "value": "[parameters('enableAzureSearch')]"
+ },
+ "enableCosmosDb": {
+ "value": "[parameters('enableCosmosDb')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.39.26.7824",
+ "templateHash": "2768605354121564364"
+ }
+ },
+ "parameters": {
+ "cosmosDbConnection": {
+ "type": "string"
+ },
+ "azureStorageConnection": {
+ "type": "string"
+ },
+ "aiSearchConnection": {
+ "type": "string"
+ },
+ "projectName": {
+ "type": "string"
+ },
+ "aiServicesAccountName": {
+ "type": "string"
+ },
+ "projectCapHost": {
+ "type": "string"
+ },
+ "accountCapHost": {
+ "type": "string"
+ },
+ "enableAzureSearch": {
+ "type": "bool",
+ "defaultValue": false
+ },
+ "enableCosmosDb": {
+ "type": "bool",
+ "defaultValue": false
+ }
+ },
+ "resources": [
+ {
+ "type": "Microsoft.CognitiveServices/accounts/capabilityHosts",
+ "apiVersion": "2025-04-01-preview",
+ "name": "[format('{0}/{1}', parameters('aiServicesAccountName'), parameters('accountCapHost'))]",
+ "properties": {
+ "capabilityHostKind": "Agents"
+ }
+ },
+ {
+ "type": "Microsoft.CognitiveServices/accounts/projects/capabilityHosts",
+ "apiVersion": "2025-04-01-preview",
+ "name": "[format('{0}/{1}/{2}', parameters('aiServicesAccountName'), parameters('projectName'), parameters('projectCapHost'))]",
+ "properties": "[union(createObject('capabilityHostKind', 'Agents', 'storageConnections', createArray(format('{0}', parameters('azureStorageConnection')))), if(parameters('enableAzureSearch'), createObject('vectorStoreConnections', createArray(format('{0}', parameters('aiSearchConnection')))), createObject()), if(parameters('enableCosmosDb'), createObject('threadStorageConnections', createArray(format('{0}', parameters('cosmosDbConnection')))), createObject()))]",
+ "dependsOn": [
+ "[resourceId('Microsoft.CognitiveServices/accounts/capabilityHosts', parameters('aiServicesAccountName'), parameters('accountCapHost'))]"
+ ]
+ }
+ ]
+ }
+ },
+ "dependsOn": [
+ "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix')))]",
+ "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('{0}{1}deployment', variables('projectName'), variables('uniqueSuffix')))]",
+ "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('aiprojectroleassignments{0}{1}deployment', variables('projectName'), variables('uniqueSuffix')))]",
+ "[subscriptionResourceId('Microsoft.Resources/resourceGroups', if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName'))))]"
+ ]
+ },
+ {
+ "condition": "[and(parameters('enableAzureSearch'), parameters('enableCosmosDb'))]",
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2025-04-01",
+ "name": "[format('postcaphostra{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))]",
+ "resourceGroup": "[if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "aiProjectPrincipalId": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.aiProjectPrincipalId.value]"
+ },
+ "aiProjectWorkspaceId": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.projectWorkspaceId.value]"
+ },
+ "aiStorageAccountName": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.storageAccountName.value]"
+ },
+ "cosmosDbAccountName": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.cosmosDbAccountName.value]"
+ },
+ "enableCosmosDb": {
+ "value": "[parameters('enableCosmosDb')]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.39.26.7824",
+ "templateHash": "17790749319453876621"
+ }
+ },
+ "parameters": {
+ "aiProjectPrincipalId": {
+ "type": "string"
+ },
+ "aiProjectPrincipalType": {
+ "type": "string",
+ "defaultValue": "ServicePrincipal"
+ },
+ "aiProjectWorkspaceId": {
+ "type": "string"
+ },
+ "aiStorageAccountName": {
+ "type": "string"
+ },
+ "cosmosDbAccountName": {
+ "type": "string"
+ },
+ "enableCosmosDb": {
+ "type": "bool",
+ "defaultValue": false
+ }
+ },
+ "variables": {
+ "storageBlobDataOwnerRoleDefinitionId": "b7e6dc6d-f1e8-4753-8033-0f276bb0955b",
+ "conditionStr": "[format('((!(ActionMatches{{''Microsoft.Storage/storageAccounts/blobServices/containers/blobs/tags/read''}}) AND !(ActionMatches{{''Microsoft.Storage/storageAccounts/blobServices/containers/blobs/filter/action''}}) AND !(ActionMatches{{''Microsoft.Storage/storageAccounts/blobServices/containers/blobs/tags/write''}}) ) OR (@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:name] StringStartsWithIgnoreCase ''{0}'' AND @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:name] StringLikeIgnoreCase ''*-azureml-agent''))', parameters('aiProjectWorkspaceId'))]",
+ "userThreadName": "[format('{0}-thread-message-store', parameters('aiProjectWorkspaceId'))]",
+ "systemThreadName": "[format('{0}-system-thread-message-store', parameters('aiProjectWorkspaceId'))]",
+ "entityStoreName": "[format('{0}-agent-entity-store', parameters('aiProjectWorkspaceId'))]",
+ "roleDefinitionId": "[if(parameters('enableCosmosDb'), resourceId('Microsoft.DocumentDB/databaseAccounts/sqlRoleDefinitions', parameters('cosmosDbAccountName'), '00000000-0000-0000-0000-000000000002'), '')]",
+ "scopeSystemContainer": "[if(parameters('enableCosmosDb'), format('{0}/dbs/enterprise_memory/colls/{1}', resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('cosmosDbAccountName')), variables('systemThreadName')), '')]",
+ "scopeUserContainer": "[if(parameters('enableCosmosDb'), format('{0}/dbs/enterprise_memory/colls/{1}', resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('cosmosDbAccountName')), variables('userThreadName')), '')]",
+ "scopeEntityContainer": "[if(parameters('enableCosmosDb'), format('{0}/dbs/enterprise_memory/colls/{1}', resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('cosmosDbAccountName')), variables('entityStoreName')), '')]"
+ },
+ "resources": [
+ {
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Storage/storageAccounts/{0}', parameters('aiStorageAccountName'))]",
+ "name": "[guid(resourceId('Microsoft.Storage/storageAccounts', parameters('aiStorageAccountName')), parameters('aiProjectPrincipalId'), variables('storageBlobDataOwnerRoleDefinitionId'), parameters('aiProjectWorkspaceId'))]",
+ "properties": {
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('storageBlobDataOwnerRoleDefinitionId'))]",
+ "principalId": "[parameters('aiProjectPrincipalId')]",
+ "principalType": "[parameters('aiProjectPrincipalType')]",
+ "conditionVersion": "2.0",
+ "condition": "[variables('conditionStr')]"
+ }
+ },
+ {
+ "condition": "[parameters('enableCosmosDb')]",
+ "type": "Microsoft.DocumentDB/databaseAccounts/sqlRoleAssignments",
+ "apiVersion": "2022-05-15",
+ "name": "[format('{0}/{1}', parameters('cosmosDbAccountName'), guid(parameters('aiProjectWorkspaceId'), resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers', parameters('cosmosDbAccountName'), 'enterprise_memory', variables('userThreadName')), variables('roleDefinitionId'), parameters('aiProjectPrincipalId')))]",
+ "properties": {
+ "principalId": "[parameters('aiProjectPrincipalId')]",
+ "roleDefinitionId": "[variables('roleDefinitionId')]",
+ "scope": "[variables('scopeUserContainer')]"
+ }
+ },
+ {
+ "condition": "[parameters('enableCosmosDb')]",
+ "type": "Microsoft.DocumentDB/databaseAccounts/sqlRoleAssignments",
+ "apiVersion": "2022-05-15",
+ "name": "[format('{0}/{1}', parameters('cosmosDbAccountName'), guid(parameters('aiProjectWorkspaceId'), resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers', parameters('cosmosDbAccountName'), 'enterprise_memory', variables('systemThreadName')), variables('roleDefinitionId'), parameters('aiProjectPrincipalId')))]",
+ "properties": {
+ "principalId": "[parameters('aiProjectPrincipalId')]",
+ "roleDefinitionId": "[variables('roleDefinitionId')]",
+ "scope": "[variables('scopeSystemContainer')]"
+ }
+ },
+ {
+ "condition": "[parameters('enableCosmosDb')]",
+ "type": "Microsoft.DocumentDB/databaseAccounts/sqlRoleAssignments",
+ "apiVersion": "2022-05-15",
+ "name": "[format('{0}/{1}', parameters('cosmosDbAccountName'), guid(parameters('aiProjectWorkspaceId'), resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers', parameters('cosmosDbAccountName'), 'enterprise_memory', variables('entityStoreName')), variables('roleDefinitionId'), parameters('aiProjectPrincipalId')))]",
+ "properties": {
+ "principalId": "[parameters('aiProjectPrincipalId')]",
+ "roleDefinitionId": "[variables('roleDefinitionId')]",
+ "scope": "[variables('scopeEntityContainer')]"
+ }
+ }
+ ]
+ }
+ },
+ "dependsOn": [
+ "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix')))]",
+ "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('{0}{1}deployment', variables('projectName'), variables('uniqueSuffix')))]",
+ "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('capabilityhost{0}{1}deployment', variables('projectName'), variables('uniqueSuffix')))]",
+ "[subscriptionResourceId('Microsoft.Resources/resourceGroups', if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName'))))]"
+ ]
+ },
+ {
+ "type": "Microsoft.Resources/deployments",
+ "apiVersion": "2025-04-01",
+ "name": "rbacAssignments",
+ "resourceGroup": "[if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))]",
+ "properties": {
+ "expressionEvaluationOptions": {
+ "scope": "inner"
+ },
+ "mode": "Incremental",
+ "parameters": {
+ "storageAccountName": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'storage'), '2025-04-01').outputs.name.value]"
+ },
+ "appInsightsName": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('{0}-appinsights', uniqueString(deployment().name, parameters('location')))), '2025-04-01').outputs.name.value]"
+ },
+ "managedIdentityPrincipalId": {
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'apiUserAssignedIdentity'), '2025-04-01').outputs.principalId.value]"
+ },
+ "userIdentityPrincipalId": {
+ "value": "[parameters('principalId')]"
+ },
+ "enableBlob": {
+ "value": "[variables('storageEndpointConfig').enableBlob]"
+ },
+ "enableQueue": {
+ "value": "[variables('storageEndpointConfig').enableQueue]"
+ },
+ "enableTable": {
+ "value": "[variables('storageEndpointConfig').enableTable]"
+ },
+ "allowUserIdentityPrincipal": {
+ "value": "[variables('storageEndpointConfig').allowUserIdentityPrincipal]"
+ }
+ },
+ "template": {
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.39.26.7824",
+ "templateHash": "4035339322027531390"
+ }
+ },
+ "parameters": {
+ "storageAccountName": {
+ "type": "string"
+ },
+ "appInsightsName": {
+ "type": "string"
+ },
+ "managedIdentityPrincipalId": {
+ "type": "string"
+ },
+ "userIdentityPrincipalId": {
+ "type": "string",
+ "defaultValue": ""
+ },
+ "allowUserIdentityPrincipal": {
+ "type": "bool",
+ "defaultValue": false
+ },
+ "enableBlob": {
+ "type": "bool",
+ "defaultValue": true
+ },
+ "enableQueue": {
+ "type": "bool",
+ "defaultValue": false
+ },
+ "enableTable": {
+ "type": "bool",
+ "defaultValue": false
+ }
+ },
+ "variables": {
+ "storageRoleDefinitionId": "b7e6dc6d-f1e8-4753-8033-0f276bb0955b",
+ "queueRoleDefinitionId": "974c5e8b-45b9-4653-ba55-5f855dd0fb88",
+ "tableRoleDefinitionId": "0a9a7e1f-b9d0-4cc4-a60d-0319b160aaa3",
+ "monitoringRoleDefinitionId": "3913510d-42f4-4e42-8a64-420c390055eb"
+ },
+ "resources": [
+ {
+ "condition": "[parameters('enableBlob')]",
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Storage/storageAccounts/{0}', parameters('storageAccountName'))]",
+ "name": "[guid(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), parameters('managedIdentityPrincipalId'), variables('storageRoleDefinitionId'))]",
+ "properties": {
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('storageRoleDefinitionId'))]",
+ "principalId": "[parameters('managedIdentityPrincipalId')]",
+ "principalType": "ServicePrincipal"
+ }
+ },
+ {
+ "condition": "[and(and(parameters('enableBlob'), parameters('allowUserIdentityPrincipal')), not(empty(parameters('userIdentityPrincipalId'))))]",
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Storage/storageAccounts/{0}', parameters('storageAccountName'))]",
+ "name": "[guid(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), parameters('userIdentityPrincipalId'), variables('storageRoleDefinitionId'))]",
+ "properties": {
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('storageRoleDefinitionId'))]",
+ "principalId": "[parameters('userIdentityPrincipalId')]",
+ "principalType": "User"
+ }
+ },
+ {
+ "condition": "[parameters('enableQueue')]",
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Storage/storageAccounts/{0}', parameters('storageAccountName'))]",
+ "name": "[guid(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), parameters('managedIdentityPrincipalId'), variables('queueRoleDefinitionId'))]",
+ "properties": {
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('queueRoleDefinitionId'))]",
+ "principalId": "[parameters('managedIdentityPrincipalId')]",
+ "principalType": "ServicePrincipal"
+ }
+ },
+ {
+ "condition": "[and(and(parameters('enableQueue'), parameters('allowUserIdentityPrincipal')), not(empty(parameters('userIdentityPrincipalId'))))]",
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Storage/storageAccounts/{0}', parameters('storageAccountName'))]",
+ "name": "[guid(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), parameters('userIdentityPrincipalId'), variables('queueRoleDefinitionId'))]",
+ "properties": {
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('queueRoleDefinitionId'))]",
+ "principalId": "[parameters('userIdentityPrincipalId')]",
+ "principalType": "User"
+ }
+ },
+ {
+ "condition": "[parameters('enableTable')]",
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Storage/storageAccounts/{0}', parameters('storageAccountName'))]",
+ "name": "[guid(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), parameters('managedIdentityPrincipalId'), variables('tableRoleDefinitionId'))]",
+ "properties": {
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('tableRoleDefinitionId'))]",
+ "principalId": "[parameters('managedIdentityPrincipalId')]",
+ "principalType": "ServicePrincipal"
+ }
+ },
+ {
+ "condition": "[and(and(parameters('enableTable'), parameters('allowUserIdentityPrincipal')), not(empty(parameters('userIdentityPrincipalId'))))]",
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Storage/storageAccounts/{0}', parameters('storageAccountName'))]",
+ "name": "[guid(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), parameters('userIdentityPrincipalId'), variables('tableRoleDefinitionId'))]",
+ "properties": {
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('tableRoleDefinitionId'))]",
+ "principalId": "[parameters('userIdentityPrincipalId')]",
+ "principalType": "User"
+ }
+ },
+ {
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Insights/components/{0}', parameters('appInsightsName'))]",
+ "name": "[guid(resourceId('Microsoft.Insights/components', parameters('appInsightsName')), parameters('managedIdentityPrincipalId'), variables('monitoringRoleDefinitionId'))]",
+ "properties": {
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('monitoringRoleDefinitionId'))]",
+ "principalId": "[parameters('managedIdentityPrincipalId')]",
+ "principalType": "ServicePrincipal"
+ }
+ },
+ {
+ "condition": "[and(parameters('allowUserIdentityPrincipal'), not(empty(parameters('userIdentityPrincipalId'))))]",
+ "type": "Microsoft.Authorization/roleAssignments",
+ "apiVersion": "2022-04-01",
+ "scope": "[format('Microsoft.Insights/components/{0}', parameters('appInsightsName'))]",
+ "name": "[guid(resourceId('Microsoft.Insights/components', parameters('appInsightsName')), parameters('userIdentityPrincipalId'), variables('monitoringRoleDefinitionId'))]",
+ "properties": {
+ "roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', variables('monitoringRoleDefinitionId'))]",
+ "principalId": "[parameters('userIdentityPrincipalId')]",
+ "principalType": "User"
+ }
+ }
+ ]
+ }
+ },
+ "dependsOn": [
+ "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'apiUserAssignedIdentity')]",
+ "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('{0}-appinsights', uniqueString(deployment().name, parameters('location'))))]",
+ "[subscriptionResourceId('Microsoft.Resources/resourceGroups', if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName'))))]",
+ "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'storage')]"
+ ]
+ }
+ ],
+ "outputs": {
+ "APPLICATIONINSIGHTS_CONNECTION_STRING": {
+ "type": "string",
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('{0}-appinsights', uniqueString(deployment().name, parameters('location')))), '2025-04-01').outputs.connectionString.value]"
+ },
+ "AZURE_LOCATION": {
+ "type": "string",
+ "value": "[parameters('location')]"
+ },
+ "AZURE_TENANT_ID": {
+ "type": "string",
+ "value": "[tenant().tenantId]"
+ },
+ "SERVICE_API_NAME": {
+ "type": "string",
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'api'), '2025-04-01').outputs.SERVICE_API_NAME.value]"
+ },
+ "SERVICE_API_URI": {
+ "type": "string",
+ "value": "[format('https://{0}.azurewebsites.net', reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'api'), '2025-04-01').outputs.SERVICE_API_NAME.value)]"
+ },
+ "AZURE_FUNCTION_APP_NAME": {
+ "type": "string",
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'api'), '2025-04-01').outputs.SERVICE_API_NAME.value]"
+ },
+ "RESOURCE_GROUP": {
+ "type": "string",
+ "value": "[if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))]"
+ },
+ "STORAGE_ACCOUNT_NAME": {
+ "type": "string",
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'storage'), '2025-04-01').outputs.name.value]"
+ },
+ "AI_SERVICES_NAME": {
+ "type": "string",
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.aiServicesName.value]"
+ },
+ "PROJECT_ENDPOINT": {
+ "type": "string",
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.projectEndpoint.value]"
+ },
+ "MODEL_DEPLOYMENT_NAME": {
+ "type": "string",
+ "value": "[parameters('modelDeploymentName')]"
+ },
+ "AZURE_OPENAI_ENDPOINT": {
+ "type": "string",
+ "value": "[format('https://{0}.openai.azure.com/', reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', format('dependencies{0}{1}deployment', variables('projectName'), variables('uniqueSuffix'))), '2025-04-01').outputs.aiServicesName.value)]"
+ },
+ "AZURE_OPENAI_DEPLOYMENT_NAME": {
+ "type": "string",
+ "value": "[parameters('modelDeploymentName')]"
+ },
+ "AZURE_CLIENT_ID": {
+ "type": "string",
+ "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'apiUserAssignedIdentity'), '2025-04-01').outputs.clientId.value]"
+ },
+ "STORAGE_CONNECTION__queueServiceUri": {
+ "type": "string",
+ "value": "[format('https://{0}.queue.{1}', reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, if(not(empty(parameters('resourceGroupName'))), parameters('resourceGroupName'), format('{0}{1}', variables('abbrs').resourcesResourceGroups, parameters('environmentName')))), 'Microsoft.Resources/deployments', 'storage'), '2025-04-01').outputs.name.value, environment().suffixes.storage)]"
+ }
+ }
+}
\ No newline at end of file
diff --git a/infra/deploybutton/azuredeploy.parameters.json b/infra/deploybutton/azuredeploy.parameters.json
new file mode 100644
index 0000000..3fb76ed
--- /dev/null
+++ b/infra/deploybutton/azuredeploy.parameters.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
+ "contentVersion": "1.0.0.0",
+ "parameters": {
+ "environmentName": {
+ "value": "simple-agent"
+ },
+ "location": {
+ "value": "eastus"
+ }
+ }
+}
diff --git a/infra/main.bicep b/infra/main.bicep
new file mode 100644
index 0000000..f61c78e
--- /dev/null
+++ b/infra/main.bicep
@@ -0,0 +1,397 @@
+targetScope = 'subscription'
+
+@minLength(1)
+@maxLength(64)
+@description('Name of the the environment which is used to generate a short unique hash used in all resources.')
+param environmentName string
+
+@minLength(1)
+@description('Primary location for all resources & Flex Consumption Function App')
+@metadata({
+ azd: {
+ type: 'location'
+ }
+})
+param location string = 'eastus2'
+
+param vnetEnabled bool = false
+param apiServiceName string = ''
+param apiUserAssignedIdentityName string = ''
+param applicationInsightsName string = ''
+param appServicePlanName string = ''
+param logAnalyticsName string = ''
+param resourceGroupName string = ''
+param storageAccountName string = ''
+@description('Id of the user identity to be used for testing and debugging. This is not required in production. Leave empty if not needed.')
+param principalId string = ''
+
+@description('Name for the AI project resources.')
+param aiProjectName string = 'simple-agent'
+
+@description('Friendly name for your Azure AI resource')
+param aiProjectFriendlyName string = 'Simple AI Agent Project'
+
+@description('Description of your Azure AI resource displayed in AI studio')
+param aiProjectDescription string = 'This is a simple AI agent project for Azure Functions.'
+
+@description('Enable Azure AI Search for vector store and search capabilities')
+param enableAzureSearch bool = false
+
+@description('Name of the Azure AI Search account')
+param aiSearchName string = 'agent-ai-search'
+
+@description('Enable Cosmos DB for agent thread storage')
+param enableCosmosDb bool = false
+
+@description('Name for capabilityHost.')
+param accountCapabilityHostName string = 'caphostacc'
+
+@description('Name for capabilityHost.')
+param projectCapabilityHostName string = 'caphostproj'
+
+@description('Name of the Azure AI Services account')
+param aiServicesName string = 'agent-ai-services'
+
+@description('Model name for deployment')
+param modelName string = 'gpt-4.1-mini'
+
+@description('Model format for deployment')
+param modelFormat string = 'OpenAI'
+
+@description('Model version for deployment')
+param modelVersion string = '2025-04-14'
+
+@description('Model deployment SKU name')
+param modelSkuName string = 'GlobalStandard'
+
+@description('Model deployment capacity')
+param modelCapacity int = 50
+
+@description('Name for the model deployment in Azure AI Services')
+param modelDeploymentName string = 'chat'
+
+@description('Name of the Cosmos DB account for agent thread storage')
+param cosmosDbName string = 'agent-ai-cosmos'
+
+@description('The AI Service Account full ARM Resource ID. This is an optional field, and if not provided, the resource will be created.')
+param aiServiceAccountResourceId string = ''
+
+@description('The Ai Search Service full ARM Resource ID. This is an optional field, and if not provided, the resource will be created.')
+param aiSearchServiceResourceId string = ''
+
+@description('The Ai Storage Account full ARM Resource ID. This is an optional field, and if not provided, the resource will be created.')
+param aiStorageAccountResourceId string = ''
+
+@description('The Cosmos DB Account full ARM Resource ID. This is an optional field, and if not provided, the resource will be created.')
+param aiCosmosDbAccountResourceId string = ''
+
+var abbrs = loadJsonContent('./abbreviations.json')
+var resourceToken = toLower(uniqueString(subscription().id, environmentName, location))
+var tags = { 'azd-env-name': environmentName }
+var functionAppName = !empty(apiServiceName) ? apiServiceName : '${abbrs.webSitesFunctions}api-${resourceToken}'
+var deploymentStorageContainerName = 'app-package-${take(functionAppName, 32)}-${take(toLower(uniqueString(functionAppName, resourceToken)), 7)}'
+var projectName = toLower('${aiProjectName}')
+
+// Create a short, unique suffix, that will be unique to each resource group
+var uniqueSuffix = toLower(uniqueString(subscription().id, environmentName, location))
+
+// Organize resources in a resource group
+resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
+ name: !empty(resourceGroupName) ? resourceGroupName : '${abbrs.resourcesResourceGroups}${environmentName}'
+ location: location
+ tags: tags
+}
+
+// User assigned managed identity to be used by the function app to reach storage and other dependencies
+module apiUserAssignedIdentity 'br/public:avm/res/managed-identity/user-assigned-identity:0.4.1' = {
+ name: 'apiUserAssignedIdentity'
+ scope: rg
+ params: {
+ location: location
+ tags: tags
+ name: !empty(apiUserAssignedIdentityName) ? apiUserAssignedIdentityName : '${abbrs.managedIdentityUserAssignedIdentities}api-${resourceToken}'
+ }
+}
+
+// Create an App Service Plan to group applications under the same payment plan and SKU
+module appServicePlan 'br/public:avm/res/web/serverfarm:0.1.1' = {
+ name: 'appserviceplan'
+ scope: rg
+ params: {
+ name: !empty(appServicePlanName) ? appServicePlanName : '${abbrs.webServerFarms}${resourceToken}'
+ sku: {
+ name: 'FC1'
+ tier: 'FlexConsumption'
+ }
+ reserved: true
+ location: location
+ tags: tags
+ }
+}
+
+// Monitor application with Azure Monitor - Log Analytics and Application Insights
+module logAnalytics 'br/public:avm/res/operational-insights/workspace:0.11.1' = {
+ name: '${uniqueString(deployment().name, location)}-loganalytics'
+ scope: rg
+ params: {
+ name: !empty(logAnalyticsName) ? logAnalyticsName : '${abbrs.operationalInsightsWorkspaces}${resourceToken}'
+ location: location
+ tags: tags
+ dataRetention: 30
+ }
+}
+
+module monitoring 'br/public:avm/res/insights/component:0.6.0' = {
+ name: '${uniqueString(deployment().name, location)}-appinsights'
+ scope: rg
+ params: {
+ name: !empty(applicationInsightsName) ? applicationInsightsName : '${abbrs.insightsComponents}${resourceToken}'
+ location: location
+ tags: tags
+ workspaceResourceId: logAnalytics.outputs.resourceId
+ disableLocalAuth: true
+ }
+}
+
+// Backing storage for Azure functions backend API
+module storage 'br/public:avm/res/storage/storage-account:0.8.3' = {
+ name: 'storage'
+ scope: rg
+ params: {
+ name: !empty(storageAccountName) ? storageAccountName : '${abbrs.storageStorageAccounts}${resourceToken}'
+ allowBlobPublicAccess: false
+ allowSharedKeyAccess: false // Disable local authentication methods as per policy
+ dnsEndpointType: 'Standard'
+ publicNetworkAccess: vnetEnabled ? 'Disabled' : 'Enabled'
+ // When vNet is enabled, restrict access but allow Azure services
+ networkAcls: vnetEnabled ? {
+ defaultAction: 'Deny'
+ bypass: 'AzureServices' // Allow Azure services including AI Agent service
+ } : {
+ defaultAction: 'Allow'
+ bypass: 'AzureServices'
+ }
+ blobServices: {
+ containers: [{name: deploymentStorageContainerName}]
+ }
+ queueServices: {
+ queues: [
+ { name: 'input' }
+ { name: 'output' }
+ ]
+ }
+ minimumTlsVersion: 'TLS1_2' // Enforcing TLS 1.2 for better security
+ location: location
+ tags: tags
+ }
+}
+
+// Dependent resources for the Azure AI workspace
+module aiDependencies './agent/standard-dependent-resources.bicep' = {
+ name: 'dependencies${projectName}${uniqueSuffix}deployment'
+ scope: rg
+ params: {
+ location: location
+ storageName: 'stai${uniqueSuffix}'
+ aiServicesName: '${aiServicesName}${uniqueSuffix}'
+ aiSearchName: '${aiSearchName}${uniqueSuffix}'
+ cosmosDbName: '${cosmosDbName}${uniqueSuffix}'
+ tags: tags
+ enableAzureSearch: enableAzureSearch
+ enableCosmosDb: enableCosmosDb
+
+ // Model deployment parameters
+ modelName: modelName
+ modelFormat: modelFormat
+ modelVersion: modelVersion
+ modelSkuName: modelSkuName
+ modelCapacity: modelCapacity
+ modelDeploymentName: modelDeploymentName
+ modelLocation: location
+
+ aiServiceAccountResourceId: aiServiceAccountResourceId
+ aiSearchServiceResourceId: aiSearchServiceResourceId
+ aiStorageAccountResourceId: aiStorageAccountResourceId
+ aiCosmosDbAccountResourceId: aiCosmosDbAccountResourceId
+ }
+}
+
+module aiProject './agent/standard-ai-project.bicep' = {
+ name: '${projectName}${uniqueSuffix}deployment'
+ scope: rg
+ params: {
+ // workspace organization
+ aiServicesAccountName: aiDependencies.outputs.aiServicesName
+ aiProjectName: '${projectName}${uniqueSuffix}'
+ aiProjectFriendlyName: aiProjectFriendlyName
+ aiProjectDescription: aiProjectDescription
+ location: location
+ tags: tags
+ enableAzureSearch: enableAzureSearch
+ enableCosmosDb: enableCosmosDb
+
+ // dependent resources
+ aiSearchName: aiDependencies.outputs.aiSearchName
+ aiSearchSubscriptionId: aiDependencies.outputs.aiSearchServiceSubscriptionId
+ aiSearchResourceGroupName: aiDependencies.outputs.aiSearchServiceResourceGroupName
+ storageAccountName: aiDependencies.outputs.storageAccountName
+ storageAccountSubscriptionId: aiDependencies.outputs.storageAccountSubscriptionId
+ storageAccountResourceGroupName: aiDependencies.outputs.storageAccountResourceGroupName
+ cosmosDbAccountName: aiDependencies.outputs.cosmosDbAccountName
+ cosmosDbAccountSubscriptionId: aiDependencies.outputs.cosmosDbAccountSubscriptionId
+ cosmosDbAccountResourceGroupName: aiDependencies.outputs.cosmosDbAccountResourceGroupName
+ }
+}
+
+module api './app/api.bicep' = {
+ name: 'api'
+ scope: rg
+ params: {
+ name: functionAppName
+ location: location
+ tags: tags
+ applicationInsightsName: monitoring.outputs.name
+ appServicePlanId: appServicePlan.outputs.resourceId
+ runtimeName: 'python'
+ runtimeVersion: '3.11'
+ storageAccountName: storage.outputs.name
+ enableBlob: storageEndpointConfig.enableBlob
+ enableQueue: storageEndpointConfig.enableQueue
+ enableTable: storageEndpointConfig.enableTable
+ deploymentStorageContainerName: deploymentStorageContainerName
+ identityId: apiUserAssignedIdentity.outputs.resourceId
+ identityClientId: apiUserAssignedIdentity.outputs.clientId
+ appSettings: {
+ PROJECT_ENDPOINT: aiProject.outputs.projectEndpoint
+ MODEL_DEPLOYMENT_NAME: modelDeploymentName
+ AZURE_OPENAI_ENDPOINT: 'https://${aiDependencies.outputs.aiServicesName}.openai.azure.com/'
+ AZURE_OPENAI_DEPLOYMENT_NAME: modelDeploymentName
+ AZURE_CLIENT_ID: apiUserAssignedIdentity.outputs.clientId
+ STORAGE_CONNECTION__queueServiceUri: 'https://${storage.outputs.name}.queue.${environment().suffixes.storage}'
+ STORAGE_CONNECTION__clientId: apiUserAssignedIdentity.outputs.clientId
+ STORAGE_CONNECTION__credential: 'managedidentity'
+ PROJECT_ENDPOINT__clientId: apiUserAssignedIdentity.outputs.clientId
+ }
+ virtualNetworkSubnetId: ''
+ }
+}
+
+module projectRoleAssignments './agent/standard-ai-project-role-assignments.bicep' = {
+ name: 'aiprojectroleassignments${projectName}${uniqueSuffix}deployment'
+ scope: rg
+ params: {
+ aiProjectPrincipalId: aiProject.outputs.aiProjectPrincipalId
+ userPrincipalId: principalId
+ allowUserIdentityPrincipal: !empty(principalId) // Enable user identity role assignments
+ aiServicesName: aiDependencies.outputs.aiServicesName
+ aiSearchName: aiDependencies.outputs.aiSearchName
+ aiCosmosDbName: aiDependencies.outputs.cosmosDbAccountName
+ aiStorageAccountName: aiDependencies.outputs.storageAccountName
+ integrationStorageAccountName: storage.outputs.name
+ functionAppManagedIdentityPrincipalId: apiUserAssignedIdentity.outputs.principalId
+ allowFunctionAppIdentityPrincipal: true // Enable function app identity role assignments
+ enableAzureSearch: enableAzureSearch
+ enableCosmosDb: enableCosmosDb
+ }
+}
+
+module aiProjectCapabilityHost './agent/standard-ai-project-capability-host.bicep' = if (enableAzureSearch && enableCosmosDb) {
+ name: 'capabilityhost${projectName}${uniqueSuffix}deployment'
+ scope: rg
+ params: {
+ aiServicesAccountName: aiDependencies.outputs.aiServicesName
+ projectName: aiProject.outputs.aiProjectName
+ aiSearchConnection: aiProject.outputs.aiSearchConnection
+ azureStorageConnection: aiProject.outputs.azureStorageConnection
+ cosmosDbConnection: aiProject.outputs.cosmosDbConnection
+
+ accountCapHost: '${accountCapabilityHostName}${uniqueSuffix}'
+ projectCapHost: '${projectCapabilityHostName}${uniqueSuffix}'
+ enableAzureSearch: enableAzureSearch
+ enableCosmosDb: enableCosmosDb
+ }
+ dependsOn: [ projectRoleAssignments ]
+}
+
+module postCapabilityHostCreationRoleAssignments './agent/post-capability-host-role-assignments.bicep' = if (enableAzureSearch && enableCosmosDb) {
+ name: 'postcaphostra${projectName}${uniqueSuffix}deployment'
+ scope: rg
+ params: {
+ aiProjectPrincipalId: aiProject.outputs.aiProjectPrincipalId
+ aiProjectWorkspaceId: aiProject.outputs.projectWorkspaceId
+ aiStorageAccountName: aiDependencies.outputs.storageAccountName
+ cosmosDbAccountName: aiDependencies.outputs.cosmosDbAccountName
+ enableCosmosDb: enableCosmosDb
+ }
+ dependsOn: [ aiProjectCapabilityHost ]
+}
+
+// Define the configuration object locally to pass to the modules
+var storageEndpointConfig = {
+ enableBlob: true // Required for AzureWebJobsStorage, .zip deployment, Event Hubs trigger and Timer trigger checkpointing
+ enableQueue: true // Required for Durable Functions and MCP trigger
+ enableTable: false // Required for Durable Functions and OpenAI triggers and bindings
+ enableFiles: false // Not required, used in legacy scenarios
+ allowUserIdentityPrincipal: !empty(principalId) // Allow interactive user identity to access for testing and debugging
+}
+
+// Consolidated Role Assignments
+module rbac 'app/rbac.bicep' = {
+ name: 'rbacAssignments'
+ scope: rg
+ params: {
+ storageAccountName: storage.outputs.name
+ appInsightsName: monitoring.outputs.name
+ managedIdentityPrincipalId: apiUserAssignedIdentity.outputs.principalId
+ userIdentityPrincipalId: principalId
+ enableBlob: storageEndpointConfig.enableBlob
+ enableQueue: storageEndpointConfig.enableQueue
+ enableTable: storageEndpointConfig.enableTable
+ allowUserIdentityPrincipal: storageEndpointConfig.allowUserIdentityPrincipal
+ }
+}
+
+// Virtual Network & private endpoint to blob storage (disabled for now)
+// module serviceVirtualNetwork 'app/vnet.bicep' = if (vnetEnabled) {
+// name: 'serviceVirtualNetwork'
+// scope: rg
+// params: {
+// location: location
+// tags: tags
+// vNetName: !empty(vNetName) ? vNetName : '${abbrs.networkVirtualNetworks}${resourceToken}'
+// }
+// }
+
+// module storagePrivateEndpoint 'app/storage-PrivateEndpoint.bicep' = if (vnetEnabled) {
+// name: 'servicePrivateEndpoint'
+// scope: rg
+// params: {
+// location: location
+// tags: tags
+// virtualNetworkName: !empty(vNetName) ? vNetName : '${abbrs.networkVirtualNetworks}${resourceToken}'
+// subnetName: serviceVirtualNetwork.outputs.peSubnetName
+// resourceName: storage.outputs.name
+// enableBlob: storageEndpointConfig.enableBlob
+// enableQueue: storageEndpointConfig.enableQueue
+// enableTable: storageEndpointConfig.enableTable
+// }
+// }
+
+// App outputs
+output APPLICATIONINSIGHTS_CONNECTION_STRING string = monitoring.outputs.connectionString
+output AZURE_LOCATION string = location
+output AZURE_TENANT_ID string = tenant().tenantId
+output SERVICE_API_NAME string = api.outputs.SERVICE_API_NAME
+output SERVICE_API_URI string = 'https://${api.outputs.SERVICE_API_NAME}.azurewebsites.net'
+output AZURE_FUNCTION_APP_NAME string = api.outputs.SERVICE_API_NAME
+output RESOURCE_GROUP string = rg.name
+output STORAGE_ACCOUNT_NAME string = storage.outputs.name
+output AI_SERVICES_NAME string = aiDependencies.outputs.aiServicesName
+
+// AI Foundry outputs
+output PROJECT_ENDPOINT string = aiProject.outputs.projectEndpoint
+output MODEL_DEPLOYMENT_NAME string = modelDeploymentName
+output AZURE_OPENAI_ENDPOINT string = 'https://${aiDependencies.outputs.aiServicesName}.openai.azure.com/'
+output AZURE_OPENAI_DEPLOYMENT_NAME string = modelDeploymentName
+output AZURE_CLIENT_ID string = apiUserAssignedIdentity.outputs.clientId
+output STORAGE_CONNECTION__queueServiceUri string = 'https://${storage.outputs.name}.queue.${environment().suffixes.storage}'
diff --git a/infra/main.parameters.json b/infra/main.parameters.json
new file mode 100644
index 0000000..8f7787b
--- /dev/null
+++ b/infra/main.parameters.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
+ "contentVersion": "1.0.0.0",
+ "parameters": {
+ "environmentName": {
+ "value": "${AZURE_ENV_NAME}"
+ },
+ "location": {
+ "value": "${AZURE_LOCATION}"
+ }
+ }
+}
\ No newline at end of file
diff --git a/infra/scripts/addclientip.ps1 b/infra/scripts/addclientip.ps1
new file mode 100644
index 0000000..fc74142
--- /dev/null
+++ b/infra/scripts/addclientip.ps1
@@ -0,0 +1,42 @@
+$ErrorActionPreference = "Stop"
+
+$output = azd env get-values
+
+# Parse the output to get the resource names and the resource group
+foreach ($line in $output) {
+ if ($line -match "STORAGE_ACCOUNT_NAME"){
+ $StorageAccount = ($line -split "=")[1] -replace '"',''
+ }
+ if ($line -match "RESOURCE_GROUP"){
+ $ResourceGroup = ($line -split "=")[1] -replace '"',''
+ }
+}
+
+# Read the config.json file to see if vnet is enabled
+$ConfigFolder = ($ResourceGroup -split '-' | Select-Object -Skip 1) -join '-'
+$jsonContent = Get-Content -Path ".azure\$ConfigFolder\config.json" -Raw | ConvertFrom-Json
+
+# Check for either skipVnet or vnetEnabled parameters
+$vnetDisabled = $false
+if ($jsonContent.infra.parameters.PSObject.Properties.Name -contains "skipVnet") {
+ $vnetDisabled = $jsonContent.infra.parameters.skipVnet -eq $true
+} elseif ($jsonContent.infra.parameters.PSObject.Properties.Name -contains "vnetEnabled") {
+ $vnetDisabled = $jsonContent.infra.parameters.vnetEnabled -eq $false
+}
+
+if ($vnetDisabled) {
+ Write-Output "VNet is not enabled. Skipping adding the client IP to the network rule of the storage account"
+}
+else {
+ Write-Output "VNet is enabled. Adding the client IP to the network rule of the Azure Functions storage account"
+ # Get the client IP
+ $ClientIP = Invoke-RestMethod -Uri 'https://api.ipify.org'
+
+ # First, ensure the storage account allows access from selected networks (not completely disabled)
+ Write-Output "Configuring storage account to allow access from selected networks..."
+ az storage account update --name $StorageAccount --resource-group $ResourceGroup --public-network-access Enabled | Out-Null
+
+ # Add the client IP to the network rules
+ az storage account network-rule add --resource-group $ResourceGroup --account-name $StorageAccount --ip-address $ClientIP | Out-Null
+ Write-Output "Client IP $ClientIP added to the network rule of the Azure Functions storage account"
+}
\ No newline at end of file
diff --git a/infra/scripts/addclientip.sh b/infra/scripts/addclientip.sh
new file mode 100755
index 0000000..f1847ed
--- /dev/null
+++ b/infra/scripts/addclientip.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+set -e
+
+output=$(azd env get-values)
+
+# Parse the output to get the resource names and the resource group
+while IFS= read -r line; do
+ if [[ $line == STORAGE_ACCOUNT_NAME* ]]; then
+ StorageAccount=$(echo "$line" | cut -d'=' -f2 | tr -d '"')
+ elif [[ $line == RESOURCE_GROUP* ]]; then
+ ResourceGroup=$(echo "$line" | cut -d'=' -f2 | tr -d '"')
+ fi
+done <<< "$output"
+
+# Read the config.json file to see if vnet is enabled
+ConfigFolder=$(echo "$ResourceGroup" | cut -d'-' -f2-)
+configFile=".azure/$ConfigFolder/config.json"
+
+vnetDisabled=false
+if [[ -f "$configFile" ]]; then
+ jsonContent=$(cat "$configFile")
+
+ # Check for skipVnet parameter first
+ if echo "$jsonContent" | grep -q '"skipVnet"'; then
+ skipVnet=$(echo "$jsonContent" | grep '"skipVnet"' | sed 's/.*"skipVnet":\s*\([^,}]*\).*/\1/' | tr -d ' ')
+ if echo "$skipVnet" | grep -iq "true"; then
+ vnetDisabled=true
+ fi
+ # Check for vnetEnabled parameter
+ elif echo "$jsonContent" | grep -q '"vnetEnabled"'; then
+ vnetEnabled=$(echo "$jsonContent" | grep '"vnetEnabled"' | sed 's/.*"vnetEnabled":\s*\([^,}]*\).*/\1/' | tr -d ' ')
+ if echo "$vnetEnabled" | grep -iq "false"; then
+ vnetDisabled=true
+ fi
+ fi
+else
+ echo "Config file $configFile not found. Assuming VNet is enabled."
+ vnetDisabled=false
+fi
+
+if [ "$vnetDisabled" = true ]; then
+ echo "VNet is not enabled. Skipping adding the client IP to the network rule of the Azure Functions storage account"
+else
+ echo "VNet is enabled. Adding the client IP to the network rule of the Azure Functions storage account"
+
+ # Get the client IP
+ ClientIP=$(curl -s https://api.ipify.org)
+
+ # First, ensure the storage account allows access from selected networks (not completely disabled)
+ echo "Configuring storage account to allow access from selected networks..."
+ az storage account update --name "$StorageAccount" --resource-group "$ResourceGroup" --public-network-access Enabled > /dev/null
+
+ # Add the client IP to the network rules
+ az storage account network-rule add --resource-group "$ResourceGroup" --account-name "$StorageAccount" --ip-address "$ClientIP" > /dev/null
+ echo "Client IP $ClientIP added to the network rule of the Azure Functions storage account"
+fi
\ No newline at end of file
diff --git a/infra/scripts/createlocalsettings.ps1 b/infra/scripts/createlocalsettings.ps1
new file mode 100644
index 0000000..f09e8ad
--- /dev/null
+++ b/infra/scripts/createlocalsettings.ps1
@@ -0,0 +1,30 @@
+$ErrorActionPreference = "Stop"
+
+if (-not (Test-Path ".\local.settings.json")) {
+
+ $output = azd env get-values
+
+ # Parse the output to get the endpoint values
+ foreach ($line in $output) {
+ if ($line -match "PROJECT_ENDPOINT"){
+ $AIProjectEndpoint = ($line -split "=")[1] -replace '"',''
+ }
+ if ($line -match "STORAGE_CONNECTION__queueServiceUri"){
+ $StorageConnectionQueue = ($line -split "=")[1] -replace '"',''
+ }
+ if ($line -match "MODEL_DEPLOYMENT_NAME"){
+ $ModelDeploymentName = ($line -split "=")[1] -replace '"',''
+ }
+ }
+
+ @{
+ "IsEncrypted" = "false";
+ "Values" = @{
+ "AzureWebJobsStorage" = "UseDevelopmentStorage=true";
+ "FUNCTIONS_WORKER_RUNTIME" = "python";
+ "PROJECT_ENDPOINT" = "$AIProjectEndpoint";
+ "MODEL_DEPLOYMENT_NAME" = "$ModelDeploymentName";
+ "STORAGE_CONNECTION__queueServiceUri" = "$StorageConnectionQueue";
+ }
+ } | ConvertTo-Json | Out-File -FilePath ".\local.settings.json" -Encoding ascii
+}
\ No newline at end of file
diff --git a/infra/scripts/createlocalsettings.sh b/infra/scripts/createlocalsettings.sh
new file mode 100755
index 0000000..842ee79
--- /dev/null
+++ b/infra/scripts/createlocalsettings.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+set -e
+
+if [ ! -f "./local.settings.json" ]; then
+
+ output=$(azd env get-values)
+
+ # Initialize variables
+ AIProjectEndpoint=""
+ StorageConnectionQueue=""
+ ModelDeploymentName=""
+
+ # Parse the output to get the endpoint URLs
+ while IFS= read -r line; do
+ if [[ $line == *"PROJECT_ENDPOINT"* ]]; then
+ AIProjectEndpoint=$(echo "$line" | cut -d '=' -f 2 | tr -d '"')
+ fi
+ if [[ $line == *"STORAGE_CONNECTION__queueServiceUri"* ]]; then
+ StorageConnectionQueue=$(echo "$line" | cut -d '=' -f 2 | tr -d '"')
+ fi
+ if [[ $line == *"MODEL_DEPLOYMENT_NAME"* ]]; then
+ ModelDeploymentName=$(echo "$line" | cut -d '=' -f 2 | tr -d '"')
+ fi
+ done <<< "$output"
+
+ cat < ./local.settings.json
+{
+ "IsEncrypted": "false",
+ "Values": {
+ "AzureWebJobsStorage": "UseDevelopmentStorage=true",
+ "FUNCTIONS_WORKER_RUNTIME": "python",
+ "PROJECT_ENDPOINT": "$AIProjectEndpoint",
+ "MODEL_DEPLOYMENT_NAME": "$ModelDeploymentName",
+ "STORAGE_CONNECTION__queueServiceUri": "$StorageConnectionQueue"
+ }
+}
+EOF
+
+fi
\ No newline at end of file
diff --git a/infra/scripts/setuplocalenvironment.ps1 b/infra/scripts/setuplocalenvironment.ps1
new file mode 100644
index 0000000..0103257
--- /dev/null
+++ b/infra/scripts/setuplocalenvironment.ps1
@@ -0,0 +1,3 @@
+$ErrorActionPreference = "Stop"
+.\infra\scripts\createlocalsettings.ps1
+.\infra\scripts\addclientip.ps1
\ No newline at end of file
diff --git a/infra/scripts/setuplocalenvironment.sh b/infra/scripts/setuplocalenvironment.sh
new file mode 100755
index 0000000..96bffee
--- /dev/null
+++ b/infra/scripts/setuplocalenvironment.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+set -e
+./infra/scripts/createlocalsettings.sh
+./infra/scripts/addclientip.sh
\ No newline at end of file