Skip to content

Commit 47c7ca0

Browse files
Priyanka-MicrosoftPrajwal-MicrosoftAjitPadhi-MicrosoftThanusree-MicrosoftCopilot
authored
fix: merging dev changes to main (#787)
* feat: Implementation of Configurable Logging Control via Flag (#756) * Implementation of Configurable Logging Control via Flag * bicep updated * updated bicep * updated custom bicep * Fix typo in CustomizingAzdParameters.md (#772) * Update src/App/app.py fixed blank string issue Co-authored-by: Copilot <[email protected]> * feat: Add Troubleshooting Guide for Log Analytics Workspace Deletion Issues (#758) * Add files via upload * Update deployment guide with replication note Added note about disabling replication before deleting resources. * Fix typo in LogAnalyticsReplicationDisable.md * Fix formatting of note in Deployment Guide --------- Co-authored-by: Harsh-Microsoft <[email protected]> * Update CosmosDB parameters for improved redundancy and location handling and resolved sql server redeployment issue * update main.json * Update infra/main.bicep Co-authored-by: Copilot <[email protected]> * Update infra/main.bicep Co-authored-by: Copilot <[email protected]> * resolved copilot comments --------- Co-authored-by: Prajwal-Microsoft <[email protected]> Co-authored-by: AjitPadhi-Microsoft <[email protected]> Co-authored-by: Thanusree-Microsoft <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Harsh-Microsoft <[email protected]> Co-authored-by: Abdul-Microsoft <[email protected]>
1 parent 7201305 commit 47c7ca0

File tree

7 files changed

+989
-305
lines changed

7 files changed

+989
-305
lines changed

docs/CustomizingAzdParameters.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ By default this template will use the environment name as the prefix to prevent
1010
| Name | Type | Default Value | Purpose |
1111
| -----------------------------| ------- | ------------------- | ---------------------------------------------------------------------------------------------------- |
1212
| `AZURE_ENV_NAME` | string | `azdtemp` | Used as a prefix for all resource names to ensure uniqueness across environments. |
13-
| `AZURE_ENV_COSMOS_LOCATION` | string | `eastus2` | Location of the Cosmos DB instance. Choose from (allowed values: `swedencentral`, `australiaeast`). |
13+
| `AZURE_ENV_COSMOS_LOCATION` | string | `Same as resource group location` | Primary location for the Cosmos DB instance. When enabling redundancy, verify the region supports zone redundancy. [Check supported regions](https://learn.microsoft.com/en-us/azure/reliability/regions-list). |
14+
| `AZURE_ENV_COSMOS_SECONDARY_LOCATION` | string | `canadacentral` | Secondary failover location for Cosmos DB when enableRedundancy is true. [Check supported regions](https://learn.microsoft.com/en-us/azure/reliability/regions-list). |
1415
| `AZURE_ENV_MODEL_DEPLOYMENT_TYPE` | string | `GlobalStandard` | Change the Model Deployment Type (allowed values: Standard, GlobalStandard). |
1516
| `AZURE_ENV_MODEL_NAME` | string | `gpt-4o-mini` | Set the GPT model name (allowed values: `gpt-4o`). |
1617
| `AZURE_ENV_MODEL_VERSION` | string | `2025-01-01-preview` | Set the Azure OpenAI API version (allowed values: 2024-08-06). |

docs/DeploymentGuide.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ Once you've opened the project in [Codespaces](#github-codespaces), [Dev Contain
236236
5. Once the deployment is complete, please follow the [Import Sample Data](#post-deployment-steps) instructions under **Post Deployment Steps** to load the sample data correctly.
237237
6. 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`.
238238
7. Test the app locally with the sample question with any selected client: _Show latest asset value by asset type?_. For more sample questions you can test in the application, see [Sample Questions](SampleQuestions.md).
239-
8. You can now delete the resources by running `azd down`, if you are done trying out the application.
239+
8. You can now delete the resources by running `azd down`, if you are done trying out the application.
240+
> **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`.
240241
241242
### Publishing Local Build Container to Azure Container Registry
242243
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 is 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: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ param solutionName string = 'clientadvisor'
1010
param existingLogAnalyticsWorkspaceId string = ''
1111

1212
@description('Optional. CosmosDB Location')
13-
param cosmosLocation string = 'eastus2'
13+
param cosmosLocation string = resourceGroup().location
14+
15+
@description('Optional. Secondary CosmosDB Location for high availability and failover scenarios. Not all Azure regions support zone redundancy for Cosmos DB. See https://learn.microsoft.com/azure/cosmos-db/high-availability#azure-regions-and-zone-redundancy for supported regions.')
16+
param secondaryCosmosLocation string = 'canadacentral'
1417

1518
@minLength(1)
1619
@description('Optional. GPT model deployment type:')
@@ -231,30 +234,13 @@ var replicaLocation = replicaRegionPairs[resourceGroup().location]
231234
@description('Optional. The tags to apply to all deployed Azure resources.')
232235
param tags resourceInput<'Microsoft.Resources/resourceGroups@2025-04-01'>.tags = {}
233236

234-
// Region pairs list based on article in [Azure Database for MySQL Flexible Server - Azure Regions](https://learn.microsoft.com/azure/mysql/flexible-server/overview#azure-regions) for supported high availability regions for CosmosDB.
235-
var cosmosDbZoneRedundantHaRegionPairs = {
236-
australiaeast: 'uksouth' //'southeastasia'
237-
centralus: 'eastus2'
238-
eastasia: 'southeastasia'
239-
eastus: 'centralus'
240-
eastus2: 'centralus'
241-
japaneast: 'australiaeast'
242-
northeurope: 'westeurope'
243-
southeastasia: 'eastasia'
244-
uksouth: 'westeurope'
245-
westeurope: 'northeurope'
246-
}
247-
248237
var allTags = union(
249238
{
250239
'azd-env-name': solutionName
251240
},
252241
tags
253242
)
254243

255-
// Paired location calculated based on 'location' parameter. This location will be used by applicable resources if `enableScalability` is set to `true`
256-
var cosmosDbHaLocation = cosmosDbZoneRedundantHaRegionPairs[resourceGroup().location]
257-
258244
// Extracts subscription, resource group, and workspace name from the resource ID when using an existing Log Analytics workspace
259245
var useExistingLogAnalytics = !empty(existingLogAnalyticsWorkspaceId)
260246

@@ -557,7 +543,7 @@ module keyvault 'br/public:avm/res/key-vault/vault:0.12.1' = {
557543
name: keyVaultName
558544
location: solutionLocation
559545
tags: tags
560-
sku: 'standard'
546+
sku: enableScalability ? 'premium' : 'standard'
561547
publicNetworkAccess: enablePrivateNetworking ? 'Disabled' : 'Enabled'
562548
networkAcls: {
563549
defaultAction: 'Allow'
@@ -843,12 +829,12 @@ module cosmosDb 'br/public:avm/res/document-db/database-account:0.15.0' = {
843829
{
844830
failoverPriority: 0
845831
isZoneRedundant: true
846-
locationName: solutionLocation
832+
locationName: cosmosLocation
847833
}
848834
{
849835
failoverPriority: 1
850836
isZoneRedundant: true
851-
locationName: cosmosDbHaLocation
837+
locationName: secondaryCosmosLocation
852838
}
853839
]
854840
: [
@@ -1014,22 +1000,6 @@ module sqlDBModule 'br/public:avm/res/sql/server:0.20.1' = {
10141000
]
10151001
}
10161002
primaryUserAssignedIdentityResourceId: userAssignedIdentity.outputs.resourceId
1017-
privateEndpoints: enablePrivateNetworking
1018-
? [
1019-
{
1020-
privateDnsZoneGroup: {
1021-
privateDnsZoneGroupConfigs: [
1022-
{
1023-
privateDnsZoneResourceId: avmPrivateDnsZones[dnsZoneIndex.sqlServer]!.outputs.resourceId
1024-
}
1025-
]
1026-
}
1027-
service: 'sqlServer'
1028-
subnetResourceId: virtualNetwork!.outputs.pepsSubnetResourceId
1029-
tags: tags
1030-
}
1031-
]
1032-
: []
10331003
firewallRules: (!enablePrivateNetworking) ? [
10341004
{
10351005
endIpAddress: '255.255.255.255'
@@ -1045,6 +1015,34 @@ module sqlDBModule 'br/public:avm/res/sql/server:0.20.1' = {
10451015
tags: tags
10461016
}
10471017
}
1018+
// ========== SQL Server Private Endpoint (separated) ========== //
1019+
module sqlDbPrivateEndpoint 'br/public:avm/res/network/private-endpoint:0.11.1' = if (enablePrivateNetworking) {
1020+
name: take('avm.res.network.private-endpoint.sql-${solutionSuffix}', 64)
1021+
params: {
1022+
name: 'pep-sql-${solutionSuffix}'
1023+
location: solutionLocation
1024+
tags: tags
1025+
enableTelemetry: enableTelemetry
1026+
subnetResourceId: virtualNetwork!.outputs.pepsSubnetResourceId
1027+
customNetworkInterfaceName: 'nic-sql-${solutionSuffix}'
1028+
privateLinkServiceConnections: [
1029+
{
1030+
name: 'pl-sqlserver-${solutionSuffix}'
1031+
properties: {
1032+
privateLinkServiceId: sqlDBModule.outputs.resourceId
1033+
groupIds: ['sqlServer']
1034+
}
1035+
}
1036+
]
1037+
privateDnsZoneGroup: {
1038+
privateDnsZoneGroupConfigs: [
1039+
{
1040+
privateDnsZoneResourceId: avmPrivateDnsZones[dnsZoneIndex.sqlServer]!.outputs.resourceId
1041+
}
1042+
]
1043+
}
1044+
}
1045+
}
10481046

10491047
// ========== Frontend server farm ========== //
10501048
// WAF best practices for Web Application Services: https://learn.microsoft.com/en-us/azure/well-architected/service-guides/app-service-web-apps
@@ -1062,11 +1060,11 @@ module webServerFarm 'br/public:avm/res/web/serverfarm:0.5.0' = {
10621060
// WAF aligned configuration for Monitoring
10631061
diagnosticSettings: enableMonitoring ? [{ workspaceResourceId: logAnalyticsWorkspaceResourceId }] : null
10641062
// WAF aligned configuration for Scalability
1065-
skuName: enableScalability || enableRedundancy ? 'P1v3' : 'B3'
1063+
skuName: 'B3'
10661064
// skuCapacity: enableScalability ? 3 : 1
10671065
skuCapacity: 1 // skuCapacity set to 1 (not 3) due to multiple agents created per type during WAF deployment
10681066
// WAF aligned configuration for Redundancy
1069-
zoneRedundant: enableRedundancy ? true : false
1067+
zoneRedundant: false // zone redundancy requires a minimum of 2 instances; as we are keeping skuCapacity to 1, setting zoneRedundant to false
10701068
}
10711069
}
10721070

@@ -1218,7 +1216,7 @@ module searchService 'br/public:avm/res/search/search-service:0.11.1' = {
12181216
]
12191217
partitionCount: 1
12201218
replicaCount: 1
1221-
sku: 'standard'
1219+
sku: enableScalability ? 'standard' : 'basic'
12221220
semanticSearch: 'free'
12231221
// Use the deployment tags provided to the template
12241222
tags: tags

0 commit comments

Comments
 (0)