-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazuredeploy.json
178 lines (177 loc) · 6.03 KB
/
azuredeploy.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"domainName": {
"type": "string",
"metadata" : {
"description":"Type your domain name. Ex.: contoso.com"
}
},
"subDomainName": {
"type": "string",
"metadata" : {
"description":"Type your subdomain name. Ex.: www"
}
},
"websiteName": {
"type": "string",
"metadata" : {
"description":"Web App name that will host the Custom Domain."
}
},
"dnsResourceGroup": {
"type": "string",
"metadata" :{
"description": "Resource Group where your dns zone is located. It will be used to create Cname and TXT record. Make sure you have access"
}
},
"existingKeyVaultId": {
"type": "string",
"metadata": {
"description": "Existing Key Vault resource Id with an access policy to allow Microsoft.Web RP to read Key Vault secrets (Checkout README.md for more information)"
}
},
"existingKeyVaultSecretName": {
"type": "string",
"metadata": {
"description": "Key Vault Secret that contains a PFX certificate"
}
}
},
"variables": {
"certificateName": "[toLower(concat(parameters('subDomainName'), '.', parameters('domainName')))]",
"mainTempalteRG": "[resourceGroup().name]",
"sku": "s1",
"workerSize": "0",
"AppServicePlanName": "[concat(toLower(parameters('websiteName')), 'ASP')]"
},
"resources": [
{
"apiVersion": "2018-02-01",
"name": "[variables('AppServicePlanName')]",
"type": "Microsoft.Web/serverfarms",
"location": "[resourceGroup().location]",
"sku": {
"name": "[variables('sku')]",
"capacity": "[variables('workerSize')]"
},
"properties": {
"name": "[variables('AppServicePlanName')]"
}
},
{
"apiVersion": "2018-02-01",
"name": "[parameters('websiteName')]",
"type": "Microsoft.Web/sites",
"location": "[resourceGroup().location]",
"properties": {
"serverFarmId": "[variables('AppServicePlanName')]"
},
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('AppServicePlanName'))]"
]
},
{
"type": "Microsoft.Web/certificates",
"name": "[variables('certificateName')]",
"apiVersion": "2020-09-01",
"location": "[resourceGroup().location]",
"properties": {
"keyVaultId": "[parameters('existingKeyVaultId')]",
"keyVaultSecretName": "[parameters('existingKeyVaultSecretName')]",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms/', variables('AppServicePlanName'))]"
},
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('AppServicePlanName'))]"
]
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2020-06-01",
"name": "nestedTemplate-CreateDNSName",
"resourceGroup": "[parameters('dnsResourceGroup')]",
"properties":
{
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"apiVersion": "2018-05-01",
"name": "[parameters('domainName')]",
"type": "Microsoft.Network/dnszones",
"location": "global",
"properties": {
"zoneType": "Public"
}
},
{
"apiVersion": "2018-05-01",
"name": "[concat(parameters('domainName'), '/', parameters('subDomainName'))]",
"type": "Microsoft.Network/dnszones/CNAME",
"properties": {
"TTL": 3600,
"CNAMERecord": {
"cname": "[concat(parameters('websiteName'), '.azurewebsites.net')]"
}
},
"dependsOn": [
]
},
{
"apiVersion": "2018-05-01",
"name": "[concat(parameters('domainName'), '/asuid.', parameters('subDomainName'))]",
"type": "Microsoft.Network/dnszones/TXT",
"properties": {
"TTL": 3600,
"TXTRecords": [
{
"value": [
"[reference(resourceId(variables('mainTempalteRG'),'Microsoft.Web/sites', parameters('websiteName')), '2018-02-01').customDomainVerificationId]"
]
}
]
},
"dependsOn": [
]
}
]
},
"parameters": {}
}
},
{
"apiVersion": "2018-11-01",
"name": "[concat(parameters('websiteName'), '/', parameters('subDomainName'),'.',parameters('domainName'))]",
"type": "Microsoft.Web/sites/hostNameBindings",
"location": "[resourceGroup().location]",
"properties": {
"sslState": "SniEnabled",
"thumbprint": "[reference(resourceId('Microsoft.Web/certificates', variables('certificateName'))).Thumbprint]"
},
"dependsOn": [
"[resourceId(parameters('dnsResourceGroup'),'Microsoft.Resources/deployments', 'nestedTemplate-CreateDNSName')]",
"[resourceId('Microsoft.Web/sites', parameters('websiteName'))]",
"[resourceId('Microsoft.Web/certificates', variables('certificateName'))]"
]
}
],
"outputs": {
"subDomainName": {
"type": "string",
"value": "[concat(parameters('websiteName'), '.', parameters('domainName'))]"
},
"cert": {
"type": "string",
"value": "[concat(parameters('websiteName'), '.', parameters('domainName'), '-', parameters('websiteName'))]"
},
"certificateThumbprint": {
"type": "string",
"value": "[reference(resourceId('Microsoft.Web/certificates', variables('certificateName'))).thumbprint]"
}
}
}