Skip to content

Commit 7e11fba

Browse files
authored
Merge pull request #88865 from dragav/sf-mi-docnsamples-update-0912
update doc page to demonstrate ACLing with system-assigned MI
2 parents 9f9e4a3 + 1ff9af1 commit 7e11fba

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

articles/service-fabric/how-to-grant-access-other-resources.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,14 @@ Similarly with accessing storage, you can leverage the managed identity of a Ser
3636

3737
![Key Vault access policy](../key-vault/media/vs-secure-secret-appsettings/add-keyvault-access-policy.png)
3838

39-
The following example illustrates granting access to a vault via a template deployment; add the snippet below as another entry under the `resources` element of the template.
39+
The following example illustrates granting access to a vault via a template deployment; add the snippet(s) below as another entry under the `resources` element of the template. The sample demonstrates access granting for both user-assigned and system-assigned identity types, respectively - choose the applicable one.
4040

4141
```json
42+
# under 'variables':
43+
"variables": {
44+
"userAssignedIdentityResourceId" : "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities/', parameters('userAssignedIdentityName'))]",
45+
}
46+
# under 'resources':
4247
{
4348
"type": "Microsoft.KeyVault/vaults/accessPolicies",
4449
"name": "[concat(parameters('keyVaultName'), '/add')]",
@@ -61,6 +66,42 @@ The following example illustrates granting access to a vault via a template depl
6166
}
6267
},
6368
```
69+
And for system-assigned managed identities:
70+
```json
71+
# under 'variables':
72+
"variables": {
73+
"sfAppSystemAssignedIdentityResourceId": "[concat(resourceId('Microsoft.ServiceFabric/clusters/applications/', parameters('clusterName'), parameters('applicationName')), '/providers/Microsoft.ManagedIdentity/Identities/default')]"
74+
}
75+
# under 'resources':
76+
{
77+
"type": "Microsoft.KeyVault/vaults/accessPolicies",
78+
"name": "[concat(parameters('keyVaultName'), '/add')]",
79+
"apiVersion": "2018-02-14",
80+
"properties": {
81+
"accessPolicies": [
82+
{
83+
"name": "[concat(parameters('clusterName'), '/', parameters('applicationName'))]",
84+
"tenantId": "[reference(variables('sfAppSystemAssignedIdentityResourceId'), '2018-11-30').tenantId]",
85+
"objectId": "[reference(variables('sfAppSystemAssignedIdentityResourceId'), '2018-11-30').principalId]",
86+
"dependsOn": [
87+
"[variables('sfAppSystemAssignedIdentityResourceId')]"
88+
],
89+
"permissions": {
90+
"secrets": [
91+
"get",
92+
"list"
93+
],
94+
"certificates":
95+
[
96+
"get",
97+
"list"
98+
]
99+
}
100+
},
101+
]
102+
}
103+
}
104+
```
64105

65106
For more details, please see [Vaults - Update Access Policy](https://docs.microsoft.com/rest/api/keyvault/vaults/updateaccesspolicy).
66107

0 commit comments

Comments
 (0)