File size: 7,884 Bytes
065fee7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "baseName": {
            "type": "string",
            "defaultValue": "[resourceGroup().name]",
            "metadata": {
                "description": "The base resource name."
            }
        },
        "tenantId": {
            "type": "string",
            "metadata": {
                "description": "The tenant ID to which the application and resources belong."
            }
        },
        "testApplicationOid": {
            "type": "string",
            "metadata": {
                "description": "The client OID to grant access to test resources."
            }
        },
        "location": {
            "type": "string",
            "defaultValue": "[resourceGroup().location]",
            "metadata": {
                "description": "The location of the resource. By default, this is the same as the resource group."
            }
        },
        "sku": {
            "defaultValue": "Standard",
            "type": "string"
        },
        "azConfigPrefix": {
            "defaultValue": "azconfig-python",
            "type": "string"
        },
        "azConfigEndpointSuffix": {
            "defaultValue": ".azconfig.io",
            "type": "string"
        },
        "keyVaultEndpointSuffix": {
            "defaultValue": ".vault.azure.net",
            "type": "string",
            "metadata": {
                "description": "Endpoint suffix for sovereign clouds, requires the proceeding '.'. The default uses the public Azure Cloud (.vault.azure.net)"
            }
        },
        "keyVaultSku": {
            "type": "string",
            "defaultValue": "premium",
            "metadata": {
                "description": "Key Vault SKU to deploy. The default is 'premium'"
            }
        }
    },
    "variables": {
        "roleDefinitionId": "[format('/subscriptions/{0}/providers/Microsoft.Authorization/roleDefinitions/5ae67dd6-50cb-40e7-96ff-dc2bfa4b606b', subscription().subscriptionId)]",
        "uniqueAzConfigName": "[format('{0}-{1}', parameters('baseName'), parameters('azConfigPrefix'))]",
        "endpointValue": "[format('https://{0}-{1}{2}', parameters('baseName'), parameters('azConfigPrefix'), parameters('azConfigEndpointSuffix'))]",
        "azureKeyVaultUrl": "[format('https://{0}{1}/', parameters('baseName'), parameters('keyVaultEndpointSuffix'))]",
        "azureKeyVaultSecretUrl": "[format('https://{0}{1}/secrets/TestSecret', parameters('baseName'), parameters('keyVaultEndpointSuffix'))]"
    },
    "resources": [
        {
            "type": "Microsoft.AppConfiguration/configurationStores",
            "apiVersion": "2019-10-01",
            "name": "[variables('uniqueAzConfigName')]",
            "location": "[parameters('location')]",
            "sku": {
                "name": "[parameters('sku')]"
            },
            "properties": {
                "endpoint": "[variables('endpointValue')]"
            }
        },
        {
            "type": "Microsoft.Authorization/roleAssignments",
            "apiVersion": "2018-09-01-preview",
            "name": "[guid(resourceGroup().id)]",
            "properties": {
                "roleDefinitionId": "[variables('roleDefinitionId')]",
                "principalId": "[parameters('testApplicationOid')]"
            }
        },
        {
            "type": "Microsoft.KeyVault/vaults",
            "apiVersion": "2016-10-01",
            "name": "[parameters('baseName')]",
            "location": "[parameters('location')]",
            "properties": {
                "sku": {
                    "family": "A",
                    "name": "[parameters('keyVaultSku')]"
                },
                "tenantId": "[parameters('tenantId')]",
                "accessPolicies": [
                    {
                        "tenantId": "[parameters('tenantId')]",
                        "objectId": "[parameters('testApplicationOid')]",
                        "permissions": {
                            "secrets": [
                                "get"
                            ]
                        }
                    }
                ]
            }
        },
        {
            "type": "Microsoft.KeyVault/vaults/secrets",
            "name": "[concat(parameters('baseName'), '/TestSecret')]",
            "apiVersion": "2016-10-01",
            "location": "[parameters('location')]",
            "dependsOn": [
                "[resourceId('Microsoft.KeyVault/vaults', parameters('baseName'))]"
            ],
            "properties": {
                "value": "Very secret value"
            }
        },
        {
            "type": "Microsoft.AppConfiguration/configurationStores/keyValues",
            "apiVersion": "2020-07-01-preview",
            "name": "[concat(variables('uniqueAzConfigName'), '/', 'message')]",
            "dependsOn": [
                "[variables('uniqueAzConfigName')]"
            ],
            "properties": {
                "value": "hi"
            }
        },
        {
            "type": "Microsoft.AppConfiguration/configurationStores/keyValues",
            "apiVersion": "2020-07-01-preview",
            "name": "[concat(variables('uniqueAzConfigName'), '/', 'message$dev')]",
            "dependsOn": [
                "[variables('uniqueAzConfigName')]"
            ],
            "properties": {
                "value": "test"
            }
        },
        {
            "type": "Microsoft.AppConfiguration/configurationStores/keyValues",
            "apiVersion": "2020-07-01-preview",
            "name": "[concat(variables('uniqueAzConfigName'), '/', 'my_json')]",
            "dependsOn": [
                "[variables('uniqueAzConfigName')]"
            ],
            "properties": {
                "value": "{\"key\": \"value\"}",
                "contentType": "application/json"
            }
        },
        {
            "type": "Microsoft.AppConfiguration/configurationStores/keyValues",
            "apiVersion": "2020-07-01-preview",
            "name": "[concat(variables('uniqueAzConfigName'), '/', 'test.trimmed')]",
            "dependsOn": [
                "[variables('uniqueAzConfigName')]"
            ],
            "properties": {
                "value": "key"
            }
        },
        {
            "type": "Microsoft.AppConfiguration/configurationStores/keyValues",
            "apiVersion": "2020-07-01-preview",
            "name": "[concat(variables('uniqueAzConfigName'), '/', '.appconfig.featureflag~2FAlpha')]",
            "dependsOn": [
                "[variables('uniqueAzConfigName')]"
            ],
            "properties": {
                "value": "{\"id\":\"Alpha\",\"description\":\"\",\"enabled\":false,\"conditions\":{\"client_filters\":[]}}",
                "contentType": "application/vnd.microsoft.appconfig.ff+json;charset=utf-8"
            }
        }
    ],
    "outputs": {
        "APPCONFIGURATION_CONNECTION_STRING": {
            "type": "string",
            "value": "[listKeys(resourceId('Microsoft.AppConfiguration/configurationStores',variables('uniqueAzConfigName')), '2019-02-01-preview').value[0].connectionString]"
        },
        "APPCONFIGURATION_ENDPOINT_STRING": {
            "type": "string",
            "value": "[variables('endpointValue')]"
        },
        "KEYVAULT_URL": {
            "type": "string",
            "value": "[variables('azureKeyVaultUrl')]"
        },
        "KEYVAULT_SECRET_URL": {
            "type": "string",
            "value": "[variables('azureKeyVaultSecretUrl')]"
        },
        "APPCONFIGURATION_KEYVAULT_SECRET_URL": {
            "type": "string",
            "value": "[variables('azureKeyVaultSecretUrl')]"
        }
    }
}