-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
AssociationForManagedApplication_DINE.json
124 lines (124 loc) · 4.76 KB
/
AssociationForManagedApplication_DINE.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
{
"properties": {
"displayName": "Deploy associations for a managed application",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Deploys an association resource that associates selected resource types to the specified managed application. This policy deployment does not support nested resource types.",
"metadata": {
"version": "1.0.0",
"category": "Managed Application"
},
"version": "1.0.0",
"parameters": {
"targetManagedApplicationId": {
"type": "String",
"metadata": {
"displayName": "Managed application ID",
"description": "Resource ID of the managed application to which resources need to be associated."
}
},
"resourceTypesToAssociate": {
"type": "Array",
"metadata": {
"displayName": "Resource types to associate",
"description": "The list of resource types to be associated to the managed application.",
"strongType": "resourceTypes"
}
},
"associationNamePrefix": {
"type": "String",
"metadata": {
"displayName": "Association name prefix",
"description": "Prefix to be added to the name of the association resource being created."
},
"defaultValue": "DeployedByPolicy"
}
},
"policyRule": {
"if": {
"field": "type",
"in": "[parameters('resourceTypesToAssociate')]"
},
"then": {
"effect": "deployIfNotExists",
"details": {
"type": "Microsoft.CustomProviders/Associations",
"name": "[concat(parameters('associationNamePrefix'), '-', uniqueString(parameters('targetManagedApplicationId')))]",
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
],
"deployment": {
"properties": {
"mode": "incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"associatedResourceName": {
"type": "string"
},
"resourceTypesToAssociate": {
"type": "string"
},
"targetManagedApplicationId": {
"type": "string"
},
"associationNamePrefix": {
"type": "string"
}
},
"variables": {
"resourceType": "[concat(parameters('resourceTypesToAssociate'), '/providers/associations')]",
"resourceName": "[concat(parameters('associatedResourceName'), '/microsoft.customproviders/', parameters('associationNamePrefix'), '-', uniqueString(parameters('targetManagedApplicationId')))]"
},
"resources": [
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2017-05-10",
"name": "[concat(deployment().Name, '-2')]",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "[variables('resourceType')]",
"name": "[variables('resourceName')]",
"apiVersion": "2018-09-01-preview",
"properties": {
"targetResourceId": "[parameters('targetManagedApplicationId')]"
}
}
]
}
}
}
]
},
"parameters": {
"resourceTypesToAssociate": {
"value": "[field('type')]"
},
"associatedResourceName": {
"value": "[field('name')]"
},
"targetManagedApplicationId": {
"value": "[parameters('targetManagedApplicationId')]"
},
"associationNamePrefix": {
"value": "[parameters('associationNamePrefix')]"
}
}
}
}
}
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/17763ad9-70c0-4794-9397-53d765932634",
"name": "17763ad9-70c0-4794-9397-53d765932634"
}