-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploymentScripts.bicep
59 lines (55 loc) · 1.41 KB
/
deploymentScripts.bicep
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
param parLocation string = 'westeurope'
var varTenantId = tenant().tenantId
resource resManagedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2022-01-31-preview' = {
name: 'my-managed-identity'
location: parLocation
}
resource resDeploymentScript 'Microsoft.Resources/deploymentScripts@2020-10-01' = {
name: 'create-spn-for-kv'
location: parLocation
kind: 'AzurePowerShell'
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${resManagedIdentity.id}' : {}
}
}
properties: {
azPowerShellVersion: '9.0'
retentionInterval: 'P1D'
scriptContent: '''
$spnAppId = New-AzADServicePrincipal -DisplayName "my-keyvault-spn" | Select-Object -ExpandProperty AppId
$DeploymentScriptOutputs = @{}
$DeploymentScriptOutputs['appId'] = $spnAppId
'''
}
}
resource resKeyVault 'Microsoft.KeyVault/vaults@2019-09-01' = {
name: 'my-ds-key-vault'
location: parLocation
properties: {
enabledForDeployment: true
enabledForTemplateDeployment: true
enabledForDiskEncryption: true
tenantId: varTenantId
accessPolicies: [
{
tenantId: varTenantId
objectId: resDeploymentScript.properties.outputs.appId
permissions: {
keys: [
'get'
]
secrets: [
'list'
'get'
]
}
}
]
sku: {
name: 'standard'
family: 'A'
}
}
}