Skip to content

Commit efec2ab

Browse files
authored
Merge pull request #238 from microsoftgraph/dkershaw10-quickstartCleanUp
Cleaned up readmes to be consistent and update one template file to have truly optional parameters.
2 parents c55219d + ce4c783 commit efec2ab

5 files changed

Lines changed: 101 additions & 28 deletions

File tree

  • quickstart-templates
    • application-serviceprincipal-create-client-resource
    • create-client-app-sp-with-kv-cert
    • resource-application-access-grant-to-client-application
    • security-group-create-with-owners-and-members
Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Create client and resource apps
22

3-
> **Note**: Minimum Bicep version required to deploy this quickstart template is [v0.32.4](https://github.com/Azure/bicep/releases/tag/v0.32.4).
4-
53
This template allows you to create a client application and a resource application, along with their service principals.
64

7-
* The client application is created with an optional key credential. The key can be passed in as a parameter. [Get The Certificate Key](https://learn.microsoft.com/en-us/graph/applications-how-to-add-certificate?tabs=http#get-the-certificate-key) mentions the steps to get the certificate key for a self-signed certificate. Here's a basic script:
5+
## Details
6+
7+
The client application is created with an optional key credential. The key can be passed in as a parameter. [Get The Certificate Key](https://learn.microsoft.com/en-us/graph/applications-how-to-add-certificate?tabs=http#get-the-certificate-key) mentions the steps to get the certificate key for a self-signed certificate. Here's a basic PowerShell script to create a self-signed certificate for use in the template file:
88

99
```powershell
1010
$certname = "AppRegTestCert"
@@ -13,10 +13,32 @@ Export-Certificate -Cert $cert -FilePath "$certname.cer" // Exports PUBLIC cert
1313
[convert]::ToBase64String((Get-Content "$certname.cer" -Encoding byte)) | Out-File -FilePath "20231004.$certname.txt"
1414
```
1515

16-
* The resource application is created with an optional app role. The id for the app role can be passed in as a parameter.
16+
The resource application is created optionally with an app role, if an `appRoleId` (in the form of a GUID) is passed in as a parameter.
17+
18+
> NOTE: There are two other related quickstarts: You can [create a client app with an X509 certificate from Key Vault as the credential](../create-client-app-sp-with-kv-cert/README.md) or you can [configure a secretless client app using federated identity credentials](../msi-as-a-fic-secretless/README.md) .
19+
20+
### Prerequisites
21+
22+
- A valid **Azure subscription**: If you don't own an Azure subscription, [create a free account](https://azure.microsoft.com/free/) before you begin or [deploy without an Azure subscription][no-azure-sub].
23+
- An **Azure resource group** that you own under a valid Azure subscription.
24+
- [Bicep tools for authoring and deployment](https://learn.microsoft.com/graph/templates/quickstart-install-bicep-tools). The minimum required Bicep version is [v0.32.4](https://github.com/Azure/bicep/releases/tag/v0.32.4).
25+
- Have the requisite **Microsoft Entra roles** to deploy this template:
26+
- Permissions to create applications. [Users have this permission by default](https://learn.microsoft.com/entra/fundamentals/users-default-permissions#compare-member-and-guest-default-permissions). However, [admins can turn off this default](https://learn.microsoft.com/entra/fundamentals/users-default-permissions#restrict-member-users-default-permissions) in which case you need to be assigned at least the [Application Developer](https://learn.microsoft.com/entra/identity/role-based-access-control/permissions-reference#application-developer) role.
27+
28+
### Deploy the template
1729

1830
You can deploy the template with the following Azure CLI command (replace `<resource-group>`, `<app-role-id>` and `<cert-key>` with the necessary values for your deployment):
1931

32+
#### Az CLI
33+
2034
```sh
2135
az deployment group create --resource-group <resource-group> --template-file main.bicep --parameters appRoleId='<app-role-id>' certKey='<cert-key>'
2236
```
37+
38+
#### Az PowerShell
39+
40+
```powershell
41+
New-AzResourceGroupDeployment -ResourceGroupName <resource-group> -TemplateFile .\main.bicep -appRoleId="<app-role-id>" -certKey="<cert-key>"
42+
```
43+
44+
[no-azure-sub]:https://learn.microsoft.com/graph/templates/how-to-deploy-without-azure-sub?view=graph-bicep-1.0&tabs=CLI

quickstart-templates/application-serviceprincipal-create-client-resource/main.bicep

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
extension microsoftGraphV1
22

3-
@description('Id of the application role to add to the resource app')
4-
param appRoleId string
3+
@description('ID of the application role to add to the resource app. Must be a GUID.')
4+
param appRoleId string?
55

66
@secure()
7-
@description('Value of the key credential')
8-
param certKey string
7+
@description('Value of the key credential.')
8+
param certKey string?
99

1010
resource resourceApp 'Microsoft.Graph/applications@v1.0' = {
1111
uniqueName: 'ExampleResourceApp'
1212
displayName: 'Example Resource Application'
13-
appRoles: [
13+
appRoles: (!empty(appRoleId)) ? [
1414
{
1515
id: appRoleId
1616
allowedMemberTypes: [ 'User', 'Application' ]
@@ -19,7 +19,7 @@ resource resourceApp 'Microsoft.Graph/applications@v1.0' = {
1919
value: 'ResourceAppData.Read.All'
2020
isEnabled: true
2121
}
22-
]
22+
] : []
2323
}
2424

2525
resource resourceSp 'Microsoft.Graph/servicePrincipals@v1.0' = {
@@ -29,14 +29,14 @@ resource resourceSp 'Microsoft.Graph/servicePrincipals@v1.0' = {
2929
resource clientApp 'Microsoft.Graph/applications@v1.0' = {
3030
uniqueName: 'ExampleClientApp'
3131
displayName: 'Example Client Application'
32-
keyCredentials: [
32+
keyCredentials: (!empty(certKey)) ? [
3333
{
3434
displayName: 'Example Client App Key Credential'
3535
usage: 'Verify'
3636
type: 'AsymmetricX509Cert'
3737
key: certKey
3838
}
39-
]
39+
] : []
4040
}
4141

4242
resource clientSp 'Microsoft.Graph/servicePrincipals@v1.0' = {
Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
# Create a client app with an X509 certificate from Key Vault as the credential
22

3-
> **Note**: Minimum Bicep version required to deploy this quickstart template is [v0.32.4](https://github.com/Azure/bicep/releases/tag/v0.32.4).
3+
This template creates a client app with a key credential, created and sourced from a Key Vault.
44

5-
The template creates a Key Vault, through which the authorized managed identity can add an X509 certificate (if it doesn't exist) and get the certificate's public key (base64 encoded), along with the thumbprint and other metadata.
6-
Finally the template creates the client application resource using the certificate public key as its credential. followed
7-
by creation of the service principal
5+
## Details
6+
7+
The template creates a Key Vault, through which the authorized managed identity can add an X509 certificate (if it doesn't exist) and get the certificate's public key (base64 encoded), along with the thumbprint and other metadata. These Key Vault operations are not currently supported in Bicep, so the template file makes use of a deployment script.
8+
9+
Finally the template creates the client application resource using the certificate public key as its credential, followed
10+
by creation of the service principal.
11+
12+
### Prerequisites
13+
14+
- A valid **Azure subscription**: If you don't own an Azure subscription, [create a free account](https://azure.microsoft.com/free/) before you begin.
15+
- An **Azure resource group** that you own under the valid Azure subscription.
16+
- [Bicep tools for authoring and deployment](https://learn.microsoft.com/graph/templates/quickstart-install-bicep-tools). The minimum required Bicep version is [v0.32.4](https://github.com/Azure/bicep/releases/tag/v0.32.4).
17+
- Have the requisite **Microsoft Entra roles** to deploy this template:
18+
- Permissions to create applications. [Users have this permission by default](https://learn.microsoft.com/entra/fundamentals/users-default-permissions#compare-member-and-guest-default-permissions). However, [admins can turn off this default](https://learn.microsoft.com/entra/fundamentals/users-default-permissions#restrict-member-users-default-permissions) in which case you need to be assigned at least the [Application Developer](https://learn.microsoft.com/entra/identity/role-based-access-control/permissions-reference#application-developer) role.
19+
20+
### Deploy the template
21+
22+
#### Az CLI
823

924
You can deploy the template with the following Azure CLI command (replace `<resource-group>` with the necessary values for your deployment). This deployment uses a parameter file, main.bicepparam, where default values may also be changed. Since the parameter file references the Bicep template file, there's no need
1025
to use the `--template-file` switch.
@@ -13,8 +28,10 @@ to use the `--template-file` switch.
1328
az deployment group create --resource-group <resource-group> --parameter main.bicepparam --verbose
1429
```
1530

16-
To deploy the same template using Az Powershell, use:
31+
#### Az Powershell
1732

1833
```powershell
1934
New-AzResourceGroupDeployment -ResourceGroupName bicep-deployments -TemplateFile .\main.bicep -TemplateParameterFile .\main.bicepparam -Verbose
2035
```
36+
37+
[no-azure-sub]:https://learn.microsoft.com/graph/templates/how-to-deploy-without-azure-sub?view=graph-bicep-1.0&tabs=CLI
Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
11
# Grant a client app access to a resource app
22

3-
> **Note1**: Minimum Bicep version required to deploy this quickstart template is [v0.32.4](https://github.com/Azure/bicep/releases/tag/v0.32.4).
3+
This template allows you to grant client app access to resource application by assigning the app role (defined in the resource app) to the client app.
44

5-
> **Note2**: This template depends on a successful deployment of [application-serviceprincipal-create-client-resource](../application-serviceprincipal-create-client-resource/)
5+
## Details
66

7-
This template allows you to grant client app access to resource application by assigning the app role in the resource app to the client app.
7+
The id for the app role must be passed in as a parameter. It needs to be the same as the app role id deployed in the [application-serviceprincipal-create-client-resource](../application-serviceprincipal-create-client-resource/) example.
88

9-
* The id for the app role can be passed in as a parameter. It needs to be the same as the app role id deployed in the [application-serviceprincipal-create-client-resource](../application-serviceprincipal-create-client-resource/) example.
9+
### Prerequisites
1010

11-
You can deploy the template with the following Azure CLI command (replace `<resource-group>`, `<app-role-id>` with the necessary values for your deployment):
11+
- This template depends on a successful deployment of [application-serviceprincipal-create-client-resource](../application-serviceprincipal-create-client-resource/)
12+
- A valid **Azure subscription**: If you don't own an Azure subscription, [create a free account](https://azure.microsoft.com/free/) before you begin.
13+
- An **Azure resource group** that you own under a valid Azure subscription, or [deploy without an Azure subscription][no-azure-sub].
14+
- [Bicep tools for authoring and deployment](https://learn.microsoft.com/graph/templates/quickstart-install-bicep-tools). The minimum required Bicep version is [v0.32.4](https://github.com/Azure/bicep/releases/tag/v0.32.4).
15+
- Permissions to grant app roles. [Users have this permission by default](https://learn.microsoft.com/entra/fundamentals/users-default-permissions#compare-member-and-guest-default-permissions) as long as you created the client app. If not, you need to be assigned at least the [Application Administrator](https://learn.microsoft.com/entra/identity/role-based-access-control/permissions-reference#application-administrator) role.
16+
17+
### Deploy the Bicep template
18+
19+
You can deploy the template with the following commands (replace `<resource-group>`, `<app-role-id>` with the necessary values for your deployment):
20+
21+
#### Az CLI
1222

1323
```sh
1424
az deployment group create --resource-group <resource-group> --template-file main.bicep --parameters appRoleId='<app-role-id>'
1525
```
26+
27+
#### Az PowerShell
28+
29+
```powershell
30+
New-AzResourceGroupDeployment -ResourceGroupName <resource-group> -TemplateFile .\main.bicep -appRoleId "<app-role-id>"
31+
```
Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,35 @@
11
# Create a group with members and owners
22

3-
> **NOTE**:
4-
>
5-
> - Minimum Bicep version required to deploy this quickstart template is [v0.32.4](https://github.com/Azure/bicep/releases/tag/v0.32.4).
6-
> - This template depends on a successful deployment of [application-serviceprincipal-create-client-resource](../application-serviceprincipal-create-client-resource/)
3+
This template allows you to create a security group with members and owners.
74

8-
This template allows you to create a security group with members and owners. Both `members` and `owners` take a [MicrosoftGraphRelationship](../../generated/microsoftgraph/microsoft.graph/v1.0/0.1.10-preview/types.md#microsoftgraphrelationship) type.
5+
## Details
6+
7+
Both `members` and `owners` take a [MicrosoftGraphRelationship](../../generated/microsoftgraph/microsoft.graph/v1.0/0.2.0-preview/types.md#microsoftgraphrelationship) type.
98

109
- The resource service principal created in [application-serviceprincipal-create-client-resource](../application-serviceprincipal-create-client-resource/) is added to the owners
1110
- A managed identity is created and added to the members
1211

13-
You can deploy the template with the following Azure CLI command (replace `<resource-group>` with the name of your resource group):
12+
> NOTE: Due to replication delays, deploying the template may fail when trying to add the newly created managed identity as a member. Simply wait a few minutes and try running the deployment again.
13+
14+
### Prerequisites
15+
16+
- This template depends on a successful deployment of [application-serviceprincipal-create-client-resource](../application-serviceprincipal-create-client-resource/)
17+
- A valid **Azure subscription**: If you don't own an Azure subscription, [create a free account](https://azure.microsoft.com/free/) before you begin.
18+
- An **Azure resource group** that you own under the valid Azure subscription.
19+
- [Bicep tools for authoring and deployment](https://learn.microsoft.com/graph/templates/quickstart-install-bicep-tools). The minimum required Bicep version is [v0.32.4](https://github.com/Azure/bicep/releases/tag/v0.32.4).
20+
- Have the requisite **Microsoft Entra roles** to deploy this template:
21+
- A **Microsoft Entra role** that assigns you permissions to create security groups. [Users have this permission by default](https://learn.microsoft.com/entra/fundamentals/users-default-permissions#compare-member-and-guest-default-permissions). However, [admins can turn off this default](https://learn.microsoft.com/entra/fundamentals/users-default-permissions#restrict-member-users-default-permissions) in which case you need to be assigned at least the [Groups Administrator](https://learn.microsoft.com/entra/identity/role-based-access-control/permissions-reference#groups-administrator) role.
22+
23+
### Deploy the template
24+
25+
#### Az CLI
1426

1527
```sh
1628
az deployment group create --resource-group <resource-group> --template-file main.bicep
1729
```
30+
31+
#### Az PowerShell
32+
33+
```powershell
34+
New-AzResourceGroupDeployment -ResourceGroupName <resource-group> -TemplateFile .\main.bicep
35+
```

0 commit comments

Comments
 (0)