Skip to content

Commit f1b779d

Browse files
Merge pull request #647 from microsoft/dev
fix: merging dev to main
2 parents f0b7702 + f059215 commit f1b779d

File tree

17 files changed

+12733
-15624
lines changed

17 files changed

+12733
-15624
lines changed

documents/DeploymentGuide.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ Once you've opened the project in [Codespaces](#github-codespaces), [Dev Contain
223223
5. Once the deployment has completed successfully, open the [Azure Portal](https://portal.azure.com/), go to the deployed resource group, find the App Service, and get the app URL from `Default domain`.
224224
225225
6. If you are done trying out the application, you can delete the resources by running `azd down`.
226+
> **Note:** If you deployed with `enableRedundancy=true` and Log Analytics workspace replication is enabled, you must first disable replication before running `azd down` else resource group delete will fail. Follow the steps in [Handling Log Analytics Workspace Deletion with Replication Enabled](./LogAnalyticsReplicationDisable.md), wait until replication returns `false`, then run `azd down`.
226227
227228
### 🛠️ Troubleshooting
228229
If you encounter any issues during the deployment process, please refer [troubleshooting](../documents/TroubleShootingSteps.md) document for detailed steps and solutions
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# 🛠 Handling Log Analytics Workspace Deletion with Replication Enabled
2+
3+
If redundancy (replication) is enabled for your Log Analytics workspace, you must disable it before deleting the workspace or resource group. Otherwise, deletion will fail.
4+
5+
## ✅ Steps to Disable Replication Before Deletion
6+
Run the following Azure CLI command. Note: This operation may take about 5 minutes to complete.
7+
8+
```bash
9+
az resource update --ids "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{logAnalyticsName}" --set properties.replication.enabled=false
10+
```
11+
12+
Replace:
13+
- `{subscriptionId}` → Your Azure subscription ID
14+
- `{resourceGroupName}` → The name of your resource group
15+
- `{logAnalyticsName}` → The name of your Log Analytics workspace
16+
17+
Optional: Verify replication disabled (should output `false`):
18+
```bash
19+
az resource show --ids "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{logAnalyticsName}" --query properties.replication.enabled -o tsv
20+
```
21+
22+
## ✅ After Disabling Replication
23+
You can safely delete:
24+
- The Log Analytics workspace (manual)
25+
- The resource group (manual), or
26+
- All provisioned resources via `azd down`
27+
28+
Return to: [Deployment Guide](./DeploymentGuide.md)

infra/main.bicep

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -506,11 +506,11 @@ module userAssignedIdentity 'br/public:avm/res/managed-identity/user-assigned-id
506506

507507
// ========== SQL Operations User Assigned Identity ========== //
508508
// Dedicated identity for backend SQL operations with limited permissions (db_datareader, db_datawriter)
509-
var sqlUserAssignedIdentityResourceName = 'id-sql-${solutionSuffix}'
510-
module sqlUserAssignedIdentity 'br/public:avm/res/managed-identity/user-assigned-identity:0.4.1' = {
511-
name: take('avm.res.managed-identity.user-assigned-identity.${sqlUserAssignedIdentityResourceName}', 64)
509+
var backendUserAssignedIdentityResourceName = 'id-backend-${solutionSuffix}'
510+
module backendUserAssignedIdentity 'br/public:avm/res/managed-identity/user-assigned-identity:0.4.1' = {
511+
name: take('avm.res.managed-identity.user-assigned-identity.${backendUserAssignedIdentityResourceName}', 64)
512512
params: {
513-
name: sqlUserAssignedIdentityResourceName
513+
name: backendUserAssignedIdentityResourceName
514514
location: location
515515
tags: tags
516516
enableTelemetry: enableTelemetry
@@ -767,6 +767,11 @@ module aiFoundryAiServices 'modules/ai-services.bicep' = if (aiFoundryAIservices
767767
principalId: userAssignedIdentity.outputs.principalId
768768
principalType: 'ServicePrincipal'
769769
}
770+
{
771+
roleDefinitionIdOrName: '53ca6127-db72-4b80-b1b0-d745d6d5456d' // Azure AI User
772+
principalId: backendUserAssignedIdentity.outputs.principalId
773+
principalType: 'ServicePrincipal'
774+
}
770775
{
771776
roleDefinitionIdOrName: '64702f94-c441-49e6-a78b-ef80e0188fee' // Azure AI Developer
772777
principalId: userAssignedIdentity.outputs.principalId
@@ -777,6 +782,16 @@ module aiFoundryAiServices 'modules/ai-services.bicep' = if (aiFoundryAIservices
777782
principalId: userAssignedIdentity.outputs.principalId
778783
principalType: 'ServicePrincipal'
779784
}
785+
{
786+
roleDefinitionIdOrName: '64702f94-c441-49e6-a78b-ef80e0188fee' // Azure AI Developer
787+
principalId: backendUserAssignedIdentity.outputs.principalId
788+
principalType: 'ServicePrincipal'
789+
}
790+
{
791+
roleDefinitionIdOrName: '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd' // Cognitive Services OpenAI User
792+
principalId: backendUserAssignedIdentity.outputs.principalId
793+
principalType: 'ServicePrincipal'
794+
}
780795
]
781796
// WAF aligned configuration for Monitoring
782797
diagnosticSettings: enableMonitoring ? [{ workspaceResourceId: logAnalyticsWorkspaceResourceId }] : null
@@ -946,6 +961,11 @@ module searchSearchServices 'br/public:avm/res/search/search-service:0.11.1' = {
946961
principalId: userAssignedIdentity.outputs.principalId
947962
principalType: 'ServicePrincipal'
948963
}
964+
{
965+
roleDefinitionIdOrName: '1407120a-92aa-4202-b7e9-c0e197c71c8f'
966+
principalId: backendUserAssignedIdentity.outputs.principalId
967+
principalType: 'ServicePrincipal'
968+
}
949969
{
950970
roleDefinitionIdOrName: '1407120a-92aa-4202-b7e9-c0e197c71c8f' // Search Index Data Reader
951971
principalId: !useExistingAiFoundryAiProject ? aiFoundryAiServices.outputs.aiProjectInfo.aiprojectSystemAssignedMIPrincipalId : existingAiFoundryAiServicesProject!.identity.principalId
@@ -1182,7 +1202,7 @@ module cosmosDb 'br/public:avm/res/document-db/database-account:0.15.0' = {
11821202
'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/*'
11831203
'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/items/*'
11841204
]
1185-
assignments: [{ principalId: userAssignedIdentity.outputs.principalId }]
1205+
assignments: [{ principalId: backendUserAssignedIdentity.outputs.principalId }]
11861206
}
11871207
]
11881208
// WAF aligned configuration for Monitoring
@@ -1278,6 +1298,7 @@ module sqlDBModule 'br/public:avm/res/sql/server:0.20.1' = {
12781298
systemAssigned: true
12791299
userAssignedResourceIds: [
12801300
userAssignedIdentity.outputs.resourceId
1301+
backendUserAssignedIdentity.outputs.resourceId
12811302
]
12821303
}
12831304
primaryUserAssignedIdentityResourceId: userAssignedIdentity.outputs.resourceId
@@ -1396,8 +1417,8 @@ module createSqlUserAndRole 'br/public:avm/res/resources/deployment-script:0.5.1
13961417
[
13971418
'-SqlServerName \'${sqlServerResourceName}\''
13981419
'-SqlDatabaseName \'${sqlDbModuleName}\''
1399-
'-ClientId \'${sqlUserAssignedIdentity.outputs.clientId}\''
1400-
'-DisplayName \'${sqlUserAssignedIdentity.outputs.name}\''
1420+
'-ClientId \'${backendUserAssignedIdentity.outputs.clientId}\''
1421+
'-DisplayName \'${backendUserAssignedIdentity.outputs.name}\''
14011422
'-DatabaseRoles \'${join(databaseRoles, ',')}\''
14021423
],
14031424
' '
@@ -1513,7 +1534,7 @@ module webSiteBackend 'modules/web-sites.bicep' = {
15131534
managedIdentities: {
15141535
systemAssigned: true
15151536
userAssignedResourceIds: [
1516-
userAssignedIdentity.outputs.resourceId
1537+
backendUserAssignedIdentity.outputs.resourceId
15171538
]
15181539
}
15191540
siteConfig: {
@@ -1539,7 +1560,7 @@ module webSiteBackend 'modules/web-sites.bicep' = {
15391560
AZURE_COSMOSDB_ENABLE_FEEDBACK: 'True'
15401561
SQLDB_DATABASE: 'sqldb-${solutionSuffix}'
15411562
SQLDB_SERVER: '${sqlDBModule.outputs.name }${environment().suffixes.sqlServerHostname}'
1542-
SQLDB_USER_MID: sqlUserAssignedIdentity.outputs.clientId
1563+
SQLDB_USER_MID: backendUserAssignedIdentity.outputs.clientId
15431564
AZURE_AI_SEARCH_ENDPOINT: 'https://${aiSearchName}.search.windows.net'
15441565
AZURE_AI_SEARCH_INDEX: 'call_transcripts_index'
15451566
AZURE_AI_SEARCH_CONNECTION_NAME: aiSearchName
@@ -1549,7 +1570,7 @@ module webSiteBackend 'modules/web-sites.bicep' = {
15491570
DUMMY_TEST: 'True'
15501571
SOLUTION_NAME: solutionSuffix
15511572
APP_ENV: 'Prod'
1552-
AZURE_CLIENT_ID: userAssignedIdentity.outputs.clientId
1573+
AZURE_CLIENT_ID: backendUserAssignedIdentity.outputs.clientId
15531574
}
15541575
// WAF aligned configuration for Monitoring
15551576
applicationInsightResourceId: enableMonitoring ? applicationInsights!.outputs.resourceId : null
@@ -1628,10 +1649,10 @@ output AZURE_AI_FOUNDRY_NAME string = !empty(existingAIServicesName) ? existingA
16281649
output AZURE_AI_PROJECT_NAME string = !empty(existingAIProjectName) ? existingAIProjectName : aiFoundryAiServices.outputs.aiProjectInfo.name
16291650

16301651
@description('Contains Azure AI Search service name.')
1631-
output AZURE_AI_SEARCH_NAME string = !empty(existingAIServicesName) ? existingAIServicesName : aiFoundryAiServicesResourceName
1652+
output AZURE_AI_SEARCH_NAME string = aiSearchName
16321653

16331654
@description('Contains Azure AI Search endpoint URL.')
1634-
output AZURE_AI_SEARCH_ENDPOINT string = 'https://${aiFoundryAiServices.outputs.name}.search.windows.net'
1655+
output AZURE_AI_SEARCH_ENDPOINT string = 'https://${aiSearchName}.search.windows.net'
16351656

16361657
@description('Contains Azure AI Search index name.')
16371658
output AZURE_AI_SEARCH_INDEX string = 'call_transcripts_index'
@@ -1682,10 +1703,10 @@ output REACT_APP_LAYOUT_CONFIG string = reactAppLayoutConfig
16821703
output SQLDB_DATABASE string = 'sqldb-${solutionSuffix}'
16831704

16841705
@description('Contains SQL server name.')
1685-
output SQLDB_SERVER string = sqlDBModule.outputs.name
1706+
output SQLDB_SERVER string = '${sqlDBModule.outputs.name }${environment().suffixes.sqlServerHostname}'
16861707

16871708
@description('Contains SQL database user managed identity client ID.')
1688-
output SQLDB_USER_MID string = sqlUserAssignedIdentity.outputs.clientId
1709+
output SQLDB_USER_MID string = backendUserAssignedIdentity.outputs.clientId
16891710

16901711
@description('Contains AI project client usage setting.')
16911712
output USE_AI_PROJECT_CLIENT string = 'False'

0 commit comments

Comments
 (0)