Skip to content

Commit 3065fe0

Browse files
Merge pull request #214545 from johndowns/arm-deployment-scripts-graph
ARM - Add information about using deployment scripts with Microsoft Graph
2 parents e814857 + e957636 commit 3065fe0

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

articles/azure-resource-manager/bicep/deployment-script-bicep.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services: azure-resource-manager
55
author: mumian
66
ms.service: azure-resource-manager
77
ms.topic: conceptual
8-
ms.date: 12/28/2021
8+
ms.date: 10/26/2022
99
ms.author: jgao
1010

1111
---
@@ -18,7 +18,7 @@ Learn how to use deployment scripts in Bicep. With [Microsoft.Resources/deployme
1818
- perform data plane operations, for example, copy blobs or seed database
1919
- look up and validate a license key
2020
- create a self-signed certificate
21-
- create an object in Azure AD
21+
- create an object in Azure Active Directory (Azure AD)
2222
- look up IP Address blocks from custom system
2323

2424
The benefits of deployment script:
@@ -38,7 +38,7 @@ The deployment script resource is only available in the regions where Azure Cont
3838
3939
### Training resources
4040

41-
If you would rather learn about the ARM template test toolkit through step-by-step guidance, see [Extend ARM templates by using deployment scripts](/training/modules/extend-resource-manager-template-deployment-scripts).
41+
If you would rather learn about deployment scripts through step-by-step guidance, see [Extend ARM templates by using deployment scripts](/training/modules/extend-resource-manager-template-deployment-scripts).
4242

4343
## Configure the minimum permissions
4444

@@ -174,6 +174,7 @@ Property value details:
174174
- [Sample 1](https://raw.githubusercontent.com/Azure/azure-docs-bicep-samples/master/samples/deployment-script/deploymentscript-keyvault.bicep): create a key vault and use deployment script to assign a certificate to the key vault.
175175
- [Sample 2](https://raw.githubusercontent.com/Azure/azure-docs-bicep-samples/master/samples/deployment-script/deploymentscript-keyvault-subscription.bicep): create a resource group at the subscription level, create a key vault in the resource group, and then use deployment script to assign a certificate to the key vault.
176176
- [Sample 3](https://raw.githubusercontent.com/Azure/azure-docs-bicep-samples/master/samples/deployment-script/deploymentscript-keyvault-mi.bicep): create a user-assigned managed identity, assign the contributor role to the identity at the resource group level, create a key vault, and then use deployment script to assign a certificate to the key vault.
177+
- [Sample 4](https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.resources/deployment-script-azcli-graph-azure-ad): manually create a user-assigned managed identity and assign it permission to use the Microsoft Graph API to create Azure AD applications; in the Bicep file, use a deployment script to create an Azure AD application and service principal, and output the object IDs and client ID.
177178

178179
## Use inline scripts
179180

@@ -614,6 +615,20 @@ After the script is tested successfully, you can use it as a deployment script i
614615
| DeploymentScriptContainerGroupInNonterminalState | When creating the Azure container instance (ACI), another deployment script is using the same ACI name in the same scope (same subscription, resource group name, and resource name). |
615616
| DeploymentScriptContainerGroupNameInvalid | The Azure container instance name (ACI) specified doesn't meet the ACI requirements. See [Troubleshoot common issues in Azure Container Instances](../../container-instances/container-instances-troubleshooting.md#issues-during-container-group-deployment).|
616617

618+
## Use Microsoft Graph within a deployment script
619+
620+
A deployment script can use [Microsoft Graph](/graph/overview) to create and work with objects in Azure AD.
621+
622+
### Commands
623+
624+
When you use Azure CLI deployment scripts, you can use commands within the `az ad` command group to work with applications, service principals, groups, and users. You can also directly invoke Microsoft Graph APIs by using the `az rest` command.
625+
626+
When you use Azure PowerShell deployment scripts, you can use the `Invoke-RestMethod` cmdlet to directly invoke the Microsoft Graph APIs.
627+
628+
### Permissions
629+
630+
The identity that your deployment script uses needs to be authorized to work with the Microsoft Graph API, with the appropriate permissions for the operations it performs. You must authorize the identity outside of your Bicep file, such as by pre-creating a user-assigned managed identity and assigning it an app role for Microsoft Graph. For more information, [see this quickstart example](https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.resources/deployment-script-azcli-graph-azure-ad).
631+
617632
## Next steps
618633

619634
In this article, you learned how to use deployment scripts. To walk through a Learn module:

articles/azure-resource-manager/templates/deployment-script-template.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services: azure-resource-manager
55
author: mumian
66
ms.service: azure-resource-manager
77
ms.topic: conceptual
8-
ms.date: 09/06/2022
8+
ms.date: 10/26/2022
99
ms.author: jgao
1010
ms.custom: devx-track-azurepowershell
1111

@@ -18,7 +18,7 @@ Learn how to use deployment scripts in Azure Resource templates (ARM templates).
1818
- Perform data plane operations, for example, copy blobs or seed database.
1919
- Look up and validate a license key.
2020
- Create a self-signed certificate.
21-
- Create an object in Azure AD.
21+
- Create an object in Azure Active Directory (Azure AD).
2222
- Look up IP Address blocks from custom system.
2323

2424
The benefits of deployment script:
@@ -41,7 +41,7 @@ The deployment script resource is only available in the regions where Azure Cont
4141
4242
### Training resources
4343

44-
To learn more about the ARM template test toolkit, and for hands-on guidance, see [Extend ARM templates by using deployment scripts](/training/modules/extend-resource-manager-template-deployment-scripts).
44+
If you would rather learn about deployment scripts through step-by-step guidance, see [Extend ARM templates by using deployment scripts](/training/modules/extend-resource-manager-template-deployment-scripts).
4545

4646
## Configure the minimum permissions
4747

@@ -181,6 +181,7 @@ Property value details:
181181
- [Sample 3](https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/deployment-script/deploymentscript-keyvault-mi.json): create a user-assigned managed identity, assign the contributor role to the identity at the resource group level, create a key vault, and then use deployment script to assign a certificate to the key vault.
182182
- [Sample 4](https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/deployment-script/deploymentscript-keyvault-lock-sub.json): it is the same scenario as Sample 1 in this list. A new resource group is created to run the deployment script. This template is a subscription level template.
183183
- [Sample 5](https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/deployment-script/deploymentscript-keyvault-lock-group.json): it is the same scenario as Sample 4. This template is a resource group level template.
184+
- [Sample 6](https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.resources/deployment-script-azcli-graph-azure-ad): manually create a user-assigned managed identity and assign it permission to use the Microsoft Graph API to create Azure AD applications; in the Bicep file, use a deployment script to create an Azure AD application and service principal, and output the object IDs and client ID.
184185

185186
## Use inline scripts
186187

@@ -622,6 +623,20 @@ After the script is tested successfully, you can use it as a deployment script i
622623
| DeploymentScriptContainerGroupInNonterminalState | When creating the Azure container instance (ACI), another deployment script is using the same ACI name in the same scope (same subscription, resource group name, and resource name). |
623624
| DeploymentScriptContainerGroupNameInvalid | The Azure container instance name (ACI) specified doesn't meet the ACI requirements. See [Troubleshoot common issues in Azure Container Instances](../../container-instances/container-instances-troubleshooting.md#issues-during-container-group-deployment).|
624625

626+
## Use Microsoft Graph within a deployment script
627+
628+
A deployment script can use [Microsoft Graph](/graph/overview) to create and work with objects in Azure AD.
629+
630+
### Commands
631+
632+
When you use Azure CLI deployment scripts, you can use commands within the `az ad` command group to work with applications, service principals, groups, and users. You can also directly invoke Microsoft Graph APIs by using the `az rest` command.
633+
634+
When you use Azure PowerShell deployment scripts, you can use the `Invoke-RestMethod` cmdlet to directly invoke the Microsoft Graph APIs.
635+
636+
### Permissions
637+
638+
The identity that your deployment script uses needs to be authorized to work with the Microsoft Graph API, with the appropriate permissions for the operations it performs. You must authorize the identity outside of your template deployment, such as by pre-creating a user-assigned managed identity and assigning it an app role for Microsoft Graph. For more information, [see this quickstart example](https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.resources/deployment-script-azcli-graph-azure-ad).
639+
625640
## Next steps
626641

627642
In this article, you learned how to use deployment scripts. To walk through a deployment script tutorial:

0 commit comments

Comments
 (0)