Skip to content

Commit 6a48b40

Browse files
authored
Update AzureSqlServerResource to use the new AzurePowerShellScript provisioning feature (#10290)
* Update AzureSqlServerResource to use the new AzurePowerShellScript provisioning feature We can't fully remove all our work arounds yet because of Azure/azure-sdk-for-net#51135, but this is a step in the right direction. * Fix the test for new lines
1 parent 75d7668 commit 6a48b40

16 files changed

Lines changed: 122 additions & 185 deletions

playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/sql1-roles.module.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ resource script_sql1_db1 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
3434
}
3535
kind: 'AzurePowerShell'
3636
properties: {
37-
scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\r\n\$sqlDatabaseName = "\$env:DBNAME"\r\n\$principalName = "\$env:PRINCIPALNAME"\r\n\$id = "\$env:ID"\r\n\r\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/dotnet/aspire/issues/9926)\r\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\r\nImport-Module SqlServer\r\n\r\n\$sqlCmd = @"\r\nDECLARE @name SYSNAME = \'\$principalName\';\r\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\r\n\r\n-- Convert the guid to the right type\r\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\r\n\r\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\r\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\r\nEXEC (@cmd);\r\n\r\n-- Assign roles to the new user\r\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\r\nEXEC (@role1);\r\n\r\n"@\r\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\r\n\r\nWrite-Host \$sqlCmd\r\n\r\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\r\n\r\nInvoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd'
3837
azPowerShellVersion: '10.0'
3938
retentionInterval: 'PT1H'
4039
environmentVariables: [
@@ -59,5 +58,6 @@ resource script_sql1_db1 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
5958
value: mi.properties.clientId
6059
}
6160
]
61+
scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\r\n\$sqlDatabaseName = "\$env:DBNAME"\r\n\$principalName = "\$env:PRINCIPALNAME"\r\n\$id = "\$env:ID"\r\n\r\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/dotnet/aspire/issues/9926)\r\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\r\nImport-Module SqlServer\r\n\r\n\$sqlCmd = @"\r\nDECLARE @name SYSNAME = \'\$principalName\';\r\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\r\n\r\n-- Convert the guid to the right type\r\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\r\n\r\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\r\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\r\nEXEC (@cmd);\r\n\r\n-- Assign roles to the new user\r\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\r\nEXEC (@role1);\r\n\r\n"@\r\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\r\n\r\nWrite-Host \$sqlCmd\r\n\r\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\r\n\r\nInvoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd'
6262
}
6363
}

playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/sql2-roles.module.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ resource script_sql2_db2 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
3434
}
3535
kind: 'AzurePowerShell'
3636
properties: {
37-
scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\r\n\$sqlDatabaseName = "\$env:DBNAME"\r\n\$principalName = "\$env:PRINCIPALNAME"\r\n\$id = "\$env:ID"\r\n\r\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/dotnet/aspire/issues/9926)\r\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\r\nImport-Module SqlServer\r\n\r\n\$sqlCmd = @"\r\nDECLARE @name SYSNAME = \'\$principalName\';\r\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\r\n\r\n-- Convert the guid to the right type\r\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\r\n\r\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\r\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\r\nEXEC (@cmd);\r\n\r\n-- Assign roles to the new user\r\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\r\nEXEC (@role1);\r\n\r\n"@\r\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\r\n\r\nWrite-Host \$sqlCmd\r\n\r\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\r\n\r\nInvoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd'
3837
azPowerShellVersion: '10.0'
3938
retentionInterval: 'PT1H'
4039
environmentVariables: [
@@ -59,5 +58,6 @@ resource script_sql2_db2 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
5958
value: mi.properties.clientId
6059
}
6160
]
61+
scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\r\n\$sqlDatabaseName = "\$env:DBNAME"\r\n\$principalName = "\$env:PRINCIPALNAME"\r\n\$id = "\$env:ID"\r\n\r\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/dotnet/aspire/issues/9926)\r\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\r\nImport-Module SqlServer\r\n\r\n\$sqlCmd = @"\r\nDECLARE @name SYSNAME = \'\$principalName\';\r\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\r\n\r\n-- Convert the guid to the right type\r\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\r\n\r\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\r\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\r\nEXEC (@cmd);\r\n\r\n-- Assign roles to the new user\r\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\r\nEXEC (@role1);\r\n\r\n"@\r\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\r\n\r\nWrite-Host \$sqlCmd\r\n\r\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\r\n\r\nInvoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd'
6262
}
6363
}

playground/SqlServerScript/AppHost1/Properties/launchSettings.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@
2424
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19139",
2525
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20080"
2626
}
27+
},
28+
"generate-manifest": {
29+
"commandName": "Project",
30+
"commandLineArgs": "--publisher manifest --output-path aspire-manifest.json",
31+
"launchBrowser": true,
32+
"environmentVariables": {
33+
"ASPNETCORE_ENVIRONMENT": "Development",
34+
"DOTNET_ENVIRONMENT": "Development",
35+
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16175"
36+
},
37+
"dotnetRunMessages": true,
38+
"applicationUrl": "http://localhost:15888"
2739
}
2840
}
2941
}

playground/SqlServerScript/AppHost1/api1-identity.module.bicep

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@description('The location for the resource(s) to be deployed.')
22
param location string = resourceGroup().location
33

4-
resource api1_identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
4+
resource api1_identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2024-11-30' = {
55
name: take('api1_identity-${uniqueString(resourceGroup().id)}', 128)
66
location: location
77
}
@@ -12,4 +12,6 @@ output clientId string = api1_identity.properties.clientId
1212

1313
output principalId string = api1_identity.properties.principalId
1414

15-
output principalName string = api1_identity.name
15+
output principalName string = api1_identity.name
16+
17+
output name string = api1_identity.name

playground/SqlServerScript/AppHost1/api1-roles-mysqlserver.module.bicep

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ param principalId string
99

1010
param principalName string
1111

12-
resource mysqlserver 'Microsoft.Sql/servers@2021-11-01' existing = {
12+
resource mysqlserver 'Microsoft.Sql/servers@2023-08-01' existing = {
1313
name: mysqlserver_outputs_name
1414
}
1515

16-
resource sqlServerAdmin 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' existing = {
16+
resource sqlServerAdmin 'Microsoft.ManagedIdentity/userAssignedIdentities@2024-11-30' existing = {
1717
name: mysqlserver_outputs_sqlserveradminname
1818
}
1919

20-
resource mi 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' existing = {
20+
resource mi 'Microsoft.ManagedIdentity/userAssignedIdentities@2024-11-30' existing = {
2121
name: principalName
2222
}
2323

@@ -32,7 +32,6 @@ resource script_mysqlserver_todosdb 'Microsoft.Resources/deploymentScripts@2023-
3232
}
3333
kind: 'AzurePowerShell'
3434
properties: {
35-
scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\r\n\$sqlDatabaseName = "\$env:DBNAME"\r\n\$principalName = "\$env:PRINCIPALNAME"\r\n\$id = "\$env:ID"\r\n\r\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/dotnet/aspire/issues/9926)\r\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\r\nImport-Module SqlServer\r\n\r\n\$sqlCmd = @"\r\nDECLARE @name SYSNAME = \'\$principalName\';\r\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\r\n\r\n-- Convert the guid to the right type\r\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\r\n\r\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\r\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\r\nEXEC (@cmd);\r\n\r\n-- Assign roles to the new user\r\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\r\nEXEC (@role1);\r\n\r\n"@\r\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\r\n\r\nWrite-Host \$sqlCmd\r\n\r\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\r\n\r\nInvoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd'
3635
azPowerShellVersion: '10.0'
3736
retentionInterval: 'PT1H'
3837
environmentVariables: [
@@ -57,5 +56,6 @@ resource script_mysqlserver_todosdb 'Microsoft.Resources/deploymentScripts@2023-
5756
value: mi.properties.clientId
5857
}
5958
]
59+
scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\r\n\$sqlDatabaseName = "\$env:DBNAME"\r\n\$principalName = "\$env:PRINCIPALNAME"\r\n\$id = "\$env:ID"\r\n\r\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/dotnet/aspire/issues/9926)\r\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\r\nImport-Module SqlServer\r\n\r\n\$sqlCmd = @"\r\nDECLARE @name SYSNAME = \'\$principalName\';\r\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\r\n\r\n-- Convert the guid to the right type\r\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\r\n\r\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\r\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\r\nEXEC (@cmd);\r\n\r\n-- Assign roles to the new user\r\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\r\nEXEC (@role1);\r\n\r\n"@\r\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\r\n\r\nWrite-Host \$sqlCmd\r\n\r\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\r\n\r\nInvoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd'
6060
}
6161
}

playground/SqlServerScript/AppHost1/api1.module.bicep

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ param mysqlserver_outputs_sqlserverfqdn string
1919

2020
param api1_identity_outputs_clientid string
2121

22-
resource api1 'Microsoft.App/containerApps@2024-03-01' = {
22+
resource api1 'Microsoft.App/containerApps@2025-02-02-preview' = {
2323
name: 'api1'
2424
location: location
2525
properties: {
@@ -36,6 +36,11 @@ resource api1 'Microsoft.App/containerApps@2024-03-01' = {
3636
identity: env_outputs_azure_container_registry_managed_identity_id
3737
}
3838
]
39+
runtime: {
40+
dotnet: {
41+
autoConfigureDataProtection: true
42+
}
43+
}
3944
}
4045
environmentId: env_outputs_azure_container_apps_environment_id
4146
template: {

playground/SqlServerScript/AppHost1/api2-identity.module.bicep

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@description('The location for the resource(s) to be deployed.')
22
param location string = resourceGroup().location
33

4-
resource api2_identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
4+
resource api2_identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2024-11-30' = {
55
name: take('api2_identity-${uniqueString(resourceGroup().id)}', 128)
66
location: location
77
}
@@ -12,4 +12,6 @@ output clientId string = api2_identity.properties.clientId
1212

1313
output principalId string = api2_identity.properties.principalId
1414

15-
output principalName string = api2_identity.name
15+
output principalName string = api2_identity.name
16+
17+
output name string = api2_identity.name

playground/SqlServerScript/AppHost1/api2-roles-mysqlserver.module.bicep

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ param principalId string
99

1010
param principalName string
1111

12-
resource mysqlserver 'Microsoft.Sql/servers@2021-11-01' existing = {
12+
resource mysqlserver 'Microsoft.Sql/servers@2023-08-01' existing = {
1313
name: mysqlserver_outputs_name
1414
}
1515

16-
resource sqlServerAdmin 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' existing = {
16+
resource sqlServerAdmin 'Microsoft.ManagedIdentity/userAssignedIdentities@2024-11-30' existing = {
1717
name: mysqlserver_outputs_sqlserveradminname
1818
}
1919

20-
resource mi 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' existing = {
20+
resource mi 'Microsoft.ManagedIdentity/userAssignedIdentities@2024-11-30' existing = {
2121
name: principalName
2222
}
2323

@@ -32,7 +32,6 @@ resource script_mysqlserver_todosdb 'Microsoft.Resources/deploymentScripts@2023-
3232
}
3333
kind: 'AzurePowerShell'
3434
properties: {
35-
scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\r\n\$sqlDatabaseName = "\$env:DBNAME"\r\n\$principalName = "\$env:PRINCIPALNAME"\r\n\$id = "\$env:ID"\r\n\r\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/dotnet/aspire/issues/9926)\r\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\r\nImport-Module SqlServer\r\n\r\n\$sqlCmd = @"\r\nDECLARE @name SYSNAME = \'\$principalName\';\r\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\r\n\r\n-- Convert the guid to the right type\r\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\r\n\r\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\r\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\r\nEXEC (@cmd);\r\n\r\n-- Assign roles to the new user\r\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\r\nEXEC (@role1);\r\n\r\n"@\r\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\r\n\r\nWrite-Host \$sqlCmd\r\n\r\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\r\n\r\nInvoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd'
3635
azPowerShellVersion: '10.0'
3736
retentionInterval: 'PT1H'
3837
environmentVariables: [
@@ -57,5 +56,6 @@ resource script_mysqlserver_todosdb 'Microsoft.Resources/deploymentScripts@2023-
5756
value: mi.properties.clientId
5857
}
5958
]
59+
scriptContent: '\$sqlServerFqdn = "\$env:DBSERVER"\r\n\$sqlDatabaseName = "\$env:DBNAME"\r\n\$principalName = "\$env:PRINCIPALNAME"\r\n\$id = "\$env:ID"\r\n\r\n# Install SqlServer module - using specific version to avoid breaking changes in 22.4.5.1 (see https://github.com/dotnet/aspire/issues/9926)\r\nInstall-Module -Name SqlServer -RequiredVersion 22.3.0 -Force -AllowClobber -Scope CurrentUser\r\nImport-Module SqlServer\r\n\r\n\$sqlCmd = @"\r\nDECLARE @name SYSNAME = \'\$principalName\';\r\nDECLARE @id UNIQUEIDENTIFIER = \'\$id\';\r\n\r\n-- Convert the guid to the right type\r\nDECLARE @castId NVARCHAR(MAX) = CONVERT(VARCHAR(MAX), CONVERT (VARBINARY(16), @id), 1);\r\n\r\n-- Construct command: CREATE USER [@name] WITH SID = @castId, TYPE = E;\r\nDECLARE @cmd NVARCHAR(MAX) = N\'CREATE USER [\' + @name + \'] WITH SID = \' + @castId + \', TYPE = E;\'\r\nEXEC (@cmd);\r\n\r\n-- Assign roles to the new user\r\nDECLARE @role1 NVARCHAR(MAX) = N\'ALTER ROLE db_owner ADD MEMBER [\' + @name + \']\';\r\nEXEC (@role1);\r\n\r\n"@\r\n# Note: the string terminator must not have whitespace before it, therefore it is not indented.\r\n\r\nWrite-Host \$sqlCmd\r\n\r\n\$connectionString = "Server=tcp:\${sqlServerFqdn},1433;Initial Catalog=\${sqlDatabaseName};Authentication=Active Directory Default;"\r\n\r\nInvoke-Sqlcmd -ConnectionString \$connectionString -Query \$sqlCmd'
6060
}
6161
}

playground/SqlServerScript/AppHost1/api2.module.bicep

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ param mysqlserver_outputs_sqlserverfqdn string
1919

2020
param api2_identity_outputs_clientid string
2121

22-
resource api2 'Microsoft.App/containerApps@2024-03-01' = {
22+
resource api2 'Microsoft.App/containerApps@2025-02-02-preview' = {
2323
name: 'api2'
2424
location: location
2525
properties: {
@@ -36,6 +36,11 @@ resource api2 'Microsoft.App/containerApps@2024-03-01' = {
3636
identity: env_outputs_azure_container_registry_managed_identity_id
3737
}
3838
]
39+
runtime: {
40+
dotnet: {
41+
autoConfigureDataProtection: true
42+
}
43+
}
3944
}
4045
environmentId: env_outputs_azure_container_apps_environment_id
4146
template: {

playground/SqlServerScript/AppHost1/env.module.bicep

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ param userPrincipalId string
55

66
param tags object = { }
77

8-
resource env_mi 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
8+
resource env_mi 'Microsoft.ManagedIdentity/userAssignedIdentities@2024-11-30' = {
99
name: take('env_mi-${uniqueString(resourceGroup().id)}', 128)
1010
location: location
1111
tags: tags
1212
}
1313

14-
resource env_acr 'Microsoft.ContainerRegistry/registries@2023-07-01' = {
14+
resource env_acr 'Microsoft.ContainerRegistry/registries@2025-04-01' = {
1515
name: take('envacr${uniqueString(resourceGroup().id)}', 50)
1616
location: location
1717
sku: {
@@ -30,7 +30,7 @@ resource env_acr_env_mi_AcrPull 'Microsoft.Authorization/roleAssignments@2022-04
3030
scope: env_acr
3131
}
3232

33-
resource env_law 'Microsoft.OperationalInsights/workspaces@2023-09-01' = {
33+
resource env_law 'Microsoft.OperationalInsights/workspaces@2025-02-01' = {
3434
name: take('envlaw-${uniqueString(resourceGroup().id)}', 63)
3535
location: location
3636
properties: {
@@ -41,7 +41,7 @@ resource env_law 'Microsoft.OperationalInsights/workspaces@2023-09-01' = {
4141
tags: tags
4242
}
4343

44-
resource env 'Microsoft.App/managedEnvironments@2024-03-01' = {
44+
resource env 'Microsoft.App/managedEnvironments@2025-01-01' = {
4545
name: take('env${uniqueString(resourceGroup().id)}', 24)
4646
location: location
4747
properties: {
@@ -70,19 +70,6 @@ resource aspireDashboard 'Microsoft.App/managedEnvironments/dotNetComponents@202
7070
parent: env
7171
}
7272

73-
resource env_Contributor 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
74-
name: guid(env.id, userPrincipalId, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c'))
75-
properties: {
76-
principalId: userPrincipalId
77-
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')
78-
}
79-
scope: env
80-
}
81-
82-
output MANAGED_IDENTITY_NAME string = env_mi.name
83-
84-
output MANAGED_IDENTITY_PRINCIPAL_ID string = env_mi.properties.principalId
85-
8673
output AZURE_LOG_ANALYTICS_WORKSPACE_NAME string = env_law.name
8774

8875
output AZURE_LOG_ANALYTICS_WORKSPACE_ID string = env_law.id

0 commit comments

Comments
 (0)