1- @minLength (2 )
2- @maxLength (3 )
3- @description ('Enter an abbreviation for the solution.' )
4- param solutionAbbreviation string
5-
6- @minLength (2 )
7- @maxLength (6 )
8- @description ('Enter an abbreviation for the environment.' )
9- param environmentAbbreviation string
10-
111@description ('Resource location.' )
122param location string
133
14- @description ('Tenant Id.' )
15- param tenantId string
16-
174@description ('Name of SQL Server' )
185param sqlServerName string
196
207@description ('Name of SQL Database' )
218param sqlDatabaseName string
229
23- @description ('Administrator user name' )
24- param sqlAdminUserName string
25-
26- @secure ()
27- @description ('Administrator password' )
28- param sqlAdminPassword string
29-
30- @description ('Administrators Azure AD Group Object Id' )
31- param sqlAdministratorsGroupId string
32-
33- @description ('Administrators Azure AD Group Name' )
34- param sqlAdministratorsGroupName string
35-
36- @description ('Key vault name.' )
37- param keyVaultName string
38-
39- var logAnalyticsName = '${solutionAbbreviation }-data-${environmentAbbreviation }'
40- var sqlServerUrl = 'Server=tcp:${sqlServerName }${environment ().suffixes .sqlServerHostname },1433;'
41- var sqlServerDataBaseName = 'Initial Catalog=${sqlDatabaseName };'
42- var sqlServerAdditionalSettings = 'MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=90;'
43-
44- resource sqlServer 'Microsoft.Sql/servers@2022-11-01-preview' = {
10+ resource sqlServer 'Microsoft.Sql/servers@2022-11-01-preview' existing = {
4511 name : sqlServerName
46- location : location
47- identity : {
48- type : 'SystemAssigned'
49- }
50- properties : {
51- administratorLogin : sqlAdminUserName
52- administratorLoginPassword : sqlAdminPassword
53- administrators : {
54- administratorType : 'ActiveDirectory'
55- principalType : 'Group'
56- login : sqlAdministratorsGroupName
57- sid : sqlAdministratorsGroupId
58- tenantId : tenantId
59- }
60- }
61-
62- resource sqlServerFirewall 'firewallRules@2022-11-01-preview' = {
63- name : 'AllowAllWindowsAzureIps'
64- properties : {
65- startIpAddress : '0.0.0.0'
66- endIpAddress : '0.0.0.0'
67- }
68- }
69-
70- resource masterDataBase 'databases@2022-11-01-preview' = {
71- location : location
72- name : 'master'
73- properties : {}
74- }
75-
76- resource auditingSettings 'auditingSettings@2022-11-01-preview' = {
77- name : 'default'
78- properties : {
79- state : 'Enabled'
80- isAzureMonitorTargetEnabled : true
81- }
82- }
8312}
8413
8514resource sqlDatabase 'Microsoft.Sql/servers/databases@2021-02-01-preview' = {
@@ -93,51 +22,3 @@ resource sqlDatabase 'Microsoft.Sql/servers/databases@2021-02-01-preview' = {
9322 capacity : 0
9423 }
9524}
96-
97- resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2022-10-01' existing = {
98- name : logAnalyticsName
99- }
100-
101- resource diagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
102- scope : sqlServer ::masterDataBase
103- name : 'diagnosticSettings'
104- properties : {
105- workspaceId : logAnalytics .id
106- logs : [
107- {
108- category : 'SQLSecurityAuditEvents'
109- enabled : true
110- retentionPolicy : {
111- days : 0
112- enabled : false
113- }
114- }
115- ]
116- }
117- dependsOn : [
118- sqlServer
119- ]
120- }
121-
122- module secureKeyvaultSecrets 'keyVaultSecretsSecure.bicep' = {
123- name : 'secureKeyvaultSecrets'
124- params : {
125- keyVaultName : keyVaultName
126- keyVaultSecrets : {
127- secrets : [
128- {
129- name : 'sqlAdminUserName'
130- value : sqlAdminUserName
131- }
132- {
133- name : 'sqlAdminPassword'
134- value : sqlAdminPassword
135- }
136- {
137- name : 'sqlServerBasicConnectionString'
138- value : '${sqlServerUrl }${sqlServerDataBaseName }${sqlServerAdditionalSettings }'
139- }
140- ]
141- }
142- }
143- }
0 commit comments