Skip to content

Commit a85f0ea

Browse files
authored
Resolve principalId inside diagnostic module to avoid cross-scope reference error (#762)
### Summary & Motivation Resolve `principalId` inside the diagnostics module to eliminate the cross-scope `reference()` error during deployment. This fixes [this cloud infrastructure error](https://github.com/platformplatform/PlatformPlatform/actions/runs/16051114349/job/45293755354). - Remove the `principalId` parameter from the diagnostics module interface. - Retrieve the `principalId` internally within the module, ensuring all references stay within the same scope. - Update calling templates to reflect the revised module signature. ### Checklist - [x] I have added tests, or done manual regression tests - [x] I have updated the documentation, if necessary
2 parents 595a70a + 7c51cc5 commit a85f0ea

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

cloud-infrastructure/cluster/main-cluster.bicep

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ module microsoftSqlDerverDiagnosticConfiguration '../modules/microsoft-sql-serve
120120
params: {
121121
diagnosticStorageAccountName: diagnosticStorageAccountName
122122
microsoftSqlServerName: resourceGroupName
123-
principalId: microsoftSqlServer.outputs.principalId
124123
dianosticStorageAccountBlobEndpoint: diagnosticStorageAccount.outputs.blobEndpoint
125124
dianosticStorageAccountSubscriptionId: subscription().subscriptionId
126125
}

cloud-infrastructure/modules/microsoft-sql-server-diagnostic.bicep

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
param diagnosticStorageAccountName string
22
param microsoftSqlServerName string
3-
param principalId string
43
param dianosticStorageAccountSubscriptionId string
54
param dianosticStorageAccountBlobEndpoint string
65

7-
module diagnosticStorageBlobDataContributorRoleAssignment 'role-assignments-storage-blob-data-contributor.bicep' = if (principalId != '') {
6+
resource existingMicrosoftSqlServer 'Microsoft.Sql/servers@2023-05-01-preview' existing = {
7+
name: microsoftSqlServerName
8+
}
9+
10+
var contributorPrincipalId = existingMicrosoftSqlServer.identity.principalId
11+
12+
module diagnosticStorageBlobDataContributorRoleAssignment './role-assignments-storage-blob-data-contributor.bicep' = {
813
name: '${microsoftSqlServerName}-microsoft-sql-server-blob-contributer'
914
params: {
1015
storageAccountName: diagnosticStorageAccountName
11-
principalId: principalId
16+
principalId: contributorPrincipalId
1217
}
1318
}
1419

15-
resource existingMicrosoftSqlServer 'Microsoft.Sql/servers@2023-05-01-preview' existing = {
16-
name: microsoftSqlServerName
17-
}
18-
1920
resource microsoftSqlServerOutboundFirewallRules 'Microsoft.Sql/servers/outboundFirewallRules@2023-05-01-preview' = {
2021
parent: existingMicrosoftSqlServer
2122
name: replace(replace(dianosticStorageAccountBlobEndpoint, 'https:', ''), '/', '')

0 commit comments

Comments
 (0)