@@ -14,6 +14,7 @@ param userName string
14
14
@description ('The username of the Azure SQL database server administrator for SQL authentication.' )
15
15
param sqlAdminUserName string
16
16
17
+ @secure ()
17
18
@description ('The password of the Azure SQL database server administrator for SQL authentication.' )
18
19
param sqlAdminPassword string
19
20
@@ -29,9 +30,9 @@ param location string = resourceGroup().location
29
30
////////////////////////////////////////////
30
31
31
32
// Create the server
32
- var SQLServerName_var = '${projectName }server'
33
- resource Server_Name_resource 'Microsoft.Sql/servers@2022-05 -01-preview' = {
34
- name : SQLServerName_var
33
+ var SQLServerName = '${projectName }server'
34
+ resource Server_Name_resource 'Microsoft.Sql/servers@2023-02 -01-preview' = {
35
+ name : SQLServerName
35
36
location : location
36
37
tags : {}
37
38
identity : {
@@ -47,41 +48,43 @@ resource Server_Name_resource 'Microsoft.Sql/servers@2022-05-01-preview' = {
47
48
}
48
49
49
50
// Allow Azure services and resources to access this server
50
- resource Server_Name_AllowAllWindowsAzureIps 'Microsoft.Sql/servers/firewallRules@2022-05-01-preview' = {
51
- name : '${Server_Name_resource .name }/AllowAllWindowsAzureIps'
51
+ resource Server_Name_AllowAllWindowsAzureIps 'Microsoft.Sql/servers/firewallRules@2023-02-01-preview' = {
52
+ parent : Server_Name_resource
53
+ name : 'AllowAllWindowsAzureIps'
52
54
properties : {
53
55
endIpAddress : '0.0.0.0'
54
56
startIpAddress : '0.0.0.0'
55
57
}
56
58
}
57
59
58
60
// Allow Client IP to access this server
59
- resource Server_Name_AllowClientIP 'Microsoft.Sql/servers/firewallRules@2022-05-01-preview' = {
60
- name : '${Server_Name_resource .name }/AllowClientIP'
61
+ resource Server_Name_AllowClientIP 'Microsoft.Sql/servers/firewallRules@2023-02-01-preview' = {
62
+ parent : Server_Name_resource
63
+ name : 'AllowClientIP'
61
64
properties : {
62
65
endIpAddress : clientIP
63
66
startIpAddress : clientIP
64
67
}
65
68
}
66
69
67
70
// Make the user an Azure AD administrator for the server, so that the user can connect with universal authentication
68
- resource Server_Name_activeDirectory 'Microsoft.Sql/servers/administrators@2022-05-01-preview' = {
69
- name : '${Server_Name_resource .name }/activeDirectory'
71
+ resource Server_Name_activeDirectory 'Microsoft.Sql/servers/administrators@2023-02-01-preview' = {
72
+ parent : Server_Name_resource
73
+ name : 'activeDirectory'
70
74
properties : {
71
75
administratorType : 'ActiveDirectory'
72
76
login : userName
73
- //sid: reference(resourceId('Microsoft.Sql/servers', '${projectName}server'), '2019-06-01-preview', 'Full').identity.principalId
74
77
sid : userObjectId
75
- //tenantId: AAD_TenantId //optional
76
- }
78
+ }
77
79
}
78
80
79
81
//////////////////////////////////////////////////////////////////////////////
80
82
// Create the ContosoHR database using the DC-series hardware configuration //
81
83
//////////////////////////////////////////////////////////////////////////////
82
84
83
- resource Database_Resource 'Microsoft.Sql/servers/databases@2022-05-01-preview' = {
84
- name : '${Server_Name_resource .name }/ContosoHR'
85
+ resource Database_Resource 'Microsoft.Sql/servers/databases@2023-02-01-preview' = {
86
+ parent : Server_Name_resource
87
+ name : 'ContosoHR'
85
88
location : location
86
89
tags : {}
87
90
sku : {
@@ -96,18 +99,18 @@ resource Database_Resource 'Microsoft.Sql/servers/databases@2022-05-01-preview'
96
99
///////////////////////////////////////
97
100
98
101
// Create the attestation provider
99
- resource attestationProviderName_resource 'Microsoft.Attestation/attestationProviders@2021-06-01-preview ' = {
100
- name : '${projectName }attest '
102
+ resource attestationProviderName 'Microsoft.Attestation/attestationProviders@2021-06-01' = {
103
+ name : '${projectName }attestation '
101
104
location : location
102
105
properties : {}
103
106
}
104
107
105
108
///////////////////////////////////
106
109
// Configure the web application //
107
110
///////////////////////////////////
108
-
111
+ var sqlServerSuffix = environment (). suffixes . sqlServerHostname
109
112
// Create an App Service plan
110
- resource WebAppServicePlan_Resource 'Microsoft.Web/serverfarms@2022-03 -01' = {
113
+ resource WebAppServicePlan_Resource 'Microsoft.Web/serverfarms@2022-09 -01' = {
111
114
name : '${projectName }plan'
112
115
location : location
113
116
properties : {}
@@ -117,7 +120,7 @@ resource WebAppServicePlan_Resource 'Microsoft.Web/serverfarms@2022-03-01' = {
117
120
}
118
121
119
122
// Create the App Service
120
- resource WebApp_Resource 'Microsoft.Web/sites@2022-03 -01' = {
123
+ resource WebApp_Resource 'Microsoft.Web/sites@2022-09 -01' = {
121
124
name : '${projectName }app'
122
125
location : location
123
126
identity : {
@@ -132,7 +135,7 @@ resource WebApp_Resource 'Microsoft.Web/sites@2022-03-01' = {
132
135
name : 'connectionstrings'
133
136
properties : {
134
137
ContosoHRDatabase : {
135
- value : 'Server=tcp:${Server_Name_resource .name }.database.windows.net ;Database=ContosoHR;Column Encryption Setting=Enabled; Attestation Protocol = AAS; Enclave Attestation Url=${attestationProviderName_resource .properties .attestUri }; Authentication=Active Directory Managed Identity'
138
+ value : 'Server=tcp:${Server_Name_resource .name }${ sqlServerSuffix } ;Database=ContosoHR;Column Encryption Setting=Enabled; Attestation Protocol = AAS; Enclave Attestation Url=${attestationProviderName .properties .attestUri }; Authentication=Active Directory Managed Identity'
136
139
type : 'SQLAzure'
137
140
}
138
141
}
@@ -147,8 +150,9 @@ resource WebApp_Resource 'Microsoft.Web/sites@2022-03-01' = {
147
150
}
148
151
149
152
// Deploy the application
150
- resource sourceControl 'Microsoft.Web/sites/sourcecontrols@2022-03-01' = {
151
- name : '${projectName }app/web'
153
+ resource sourceControl 'Microsoft.Web/sites/sourcecontrols@2022-09-01' = {
154
+ parent : WebApp_Resource
155
+ name : 'web'
152
156
properties : {
153
157
repoUrl : 'https://github.com/microsoft/sql-server-samples.git'
154
158
branch : 'master'
@@ -164,7 +168,7 @@ resource sourceControl 'Microsoft.Web/sites/sourcecontrols@2022-03-01' = {
164
168
//////////////////////////////////////
165
169
166
170
// Create a key vault and assign key permissions to the user, so that the user can manage the keys
167
- resource KeyVault_Resource 'Microsoft.KeyVault/vaults@2022-07 -01' = {
171
+ resource KeyVault_Resource 'Microsoft.KeyVault/vaults@2023-02 -01' = {
168
172
name : '${projectName }vault'
169
173
location : location
170
174
tags : {}
@@ -197,7 +201,7 @@ resource KeyVault_Resource 'Microsoft.KeyVault/vaults@2022-07-01' = {
197
201
}
198
202
199
203
// Assign key permissions to the web app
200
- resource KeyVaultWebAppAccessPolicy_Resource 'Microsoft.KeyVault/vaults/accessPolicies@2022-07 -01' = {
204
+ resource KeyVaultWebAppAccessPolicy_Resource 'Microsoft.KeyVault/vaults/accessPolicies@2023-02 -01' = {
201
205
name : any ('${KeyVault_Resource .name }/add' )
202
206
properties : {
203
207
accessPolicies : [
@@ -218,8 +222,9 @@ resource KeyVaultWebAppAccessPolicy_Resource 'Microsoft.KeyVault/vaults/accessPo
218
222
}
219
223
220
224
// Create a key
221
- resource Key_Resource 'Microsoft.KeyVault/vaults/keys@2022-07-01' = {
222
- name : '${KeyVault_Resource .name }/CMK'
225
+ resource Key_Resource 'Microsoft.KeyVault/vaults/keys@2023-02-01' = {
226
+ parent : KeyVault_Resource
227
+ name : 'CMK'
223
228
tags : {}
224
229
properties : {
225
230
attributes : {
0 commit comments