Skip to content

Commit 35a17ba

Browse files
authored
Update quickstart examples and docs to include fic and v1 resources (#88)
* Update quickstart examples and docs to include fic and v1 resources * Fix type and update v1.0 powershell script * Update example and doc based on review * Address comments * Address comments * Use a single string parameter for fic subject * Update based on feedback * minor update
1 parent acce1e3 commit 35a17ba

File tree

13 files changed

+104
-36
lines changed

13 files changed

+104
-36
lines changed

DEVELOPMENT.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ This document describes the steps to setup development tools and run Bicep types
4747
```
4848

4949
## Adding New Types
50-
1. Update the definitions and paths for the new type in the swagger file [microsoftgraph-beta.json](swagger\specification\microsoftgraph\resource-manager\microsoftgraph\preview\2023-09-15-preview\microsoftgraph-beta.json). Currently only `beta` version resources are supported.
50+
1. Update the entities and properties in [config-beta.yml](src\swagger-generation\config-beta.yml) and [config-v1.0.yml](src\swagger-generation\config-beta.yml)
5151

52-
1. Re-run generation using the command in [Running](#running), and new types will be available in [/generated](./generated)
52+
1. Follow steps in [Running Generation Locally](#running-generation-locally), and new types will be available in [/generated](./generated)

docs/getting-started.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ Now, when creating a Bicep resource, the available Microsoft.Graph resource type
3030

3131
![image](./VS%20code%20graph%20types%20in%20bicep.jpg)
3232

33-
| Bicep type definitions | Microsoft Graph API (beta) reference |
34-
|--------------|-----------|
35-
| [applications](../generated/microsoftgraph/microsoft.graph/beta/types.md#resource-microsoftgraphapplicationsbeta) | [application resource](https://learn.microsoft.com/graph/api/resources/application?view=graph-rest-beta) |
36-
| [servicePrincipals](../generated/microsoftgraph/microsoft.graph/beta/types.md#resource-microsoftgraphserviceprincipalsbeta) | [servicePrincipal resource](https://learn.microsoft.com/graph/api/resources/serviceprincipal?view=graph-rest-beta) |
37-
| [groups](../generated/microsoftgraph/microsoft.graph/beta/types.md#resource-microsoftgraphgroupsbeta) | [group resource](https://learn.microsoft.com/graph/api/resources/group?view=graph-rest-beta) |
38-
| [appRoleAssignedTo](../generated/microsoftgraph/microsoft.graph/beta/types.md#resource-microsoftgraphapproleassignedtobeta) | [appRoleAssignment resource](https://learn.microsoft.com/graph/api/resources/approleassignment?view=graph-rest-beta) |
39-
| [oauth2PermissionGrants](../generated/microsoftgraph/microsoft.graph/beta/types.md#resource-microsoftgraphoauth2permissiongrantsbeta) | [oauth2PermissionGrant resource](https://learn.microsoft.com/graph/api/resources/oauth2permissiongrant?view=graph-rest-beta) |
33+
| Bicep type (beta) definitions | Microsoft Graph API (beta) reference | Bicep type (v1.0) definitions | Microsoft Graph API (v1.0) reference |
34+
|--------------|-----------|--------------|-----------|
35+
| [applications](../generated/microsoftgraph/microsoft.graph/beta/types.md#resource-microsoftgraphapplicationsbeta) | [application resource](https://learn.microsoft.com/graph/api/resources/application?view=graph-rest-beta) | [applications](../generated/microsoftgraph/microsoft.graph/v1.0/types.md#resource-microsoftgraphapplicationsv10) | [application resource](https://learn.microsoft.com/graph/api/resources/application?view=graph-rest-1.0) |
36+
| [servicePrincipals](../generated/microsoftgraph/microsoft.graph/beta/types.md#resource-microsoftgraphserviceprincipalsbeta) | [servicePrincipal resource](https://learn.microsoft.com/graph/api/resources/serviceprincipal?view=graph-rest-beta) | [servicePrincipals](../generated/microsoftgraph/microsoft.graph/v1.0/types.md#resource-microsoftgraphserviceprincipalsv10) | [servicePrincipal resource](https://learn.microsoft.com/graph/api/resources/serviceprincipal?view=graph-rest-1.0) |
37+
| [groups](../generated/microsoftgraph/microsoft.graph/beta/types.md#resource-microsoftgraphgroupsbeta) | [group resource](https://learn.microsoft.com/graph/api/resources/group?view=graph-rest-beta) | [groups](../generated/microsoftgraph/microsoft.graph/v1.0/types.md#resource-microsoftgraphgroupsv10) | [group resource](https://learn.microsoft.com/graph/api/resources/group?view=graph-rest-1.0) |
38+
| [appRoleAssignedTo](../generated/microsoftgraph/microsoft.graph/beta/types.md#resource-microsoftgraphapproleassignedtobeta) | [appRoleAssignment resource](https://learn.microsoft.com/graph/api/resources/approleassignment?view=graph-rest-beta) | [appRoleAssignedTo](../generated/microsoftgraph/microsoft.graph/v1.0/types.md#resource-microsoftgraphapproleassignedtov10) | [appRoleAssignment resource](https://learn.microsoft.com/graph/api/resources/approleassignment?view=graph-rest-1.0) |
39+
| [oauth2PermissionGrants](../generated/microsoftgraph/microsoft.graph/beta/types.md#resource-microsoftgraphoauth2permissiongrantsbeta) | [oauth2PermissionGrant resource](https://learn.microsoft.com/graph/api/resources/oauth2permissiongrant?view=graph-rest-beta) | [oauth2PermissionGrants](../generated/microsoftgraph/microsoft.graph/v1.0/types.md#resource-microsoftgraphoauth2permissiongrantsv10) | [oauth2PermissionGrant resource](https://learn.microsoft.com/graph/api/resources/oauth2permissiongrant?view=graph-rest-1.0) |
40+
| [applications/federatedIdentityCredentials](../generated/microsoftgraph/microsoft.graph/beta/types.md#resource-microsoftgraphoauth2permissiongrantsbeta) | [federatedidentitycredential resource](https://learn.microsoft.com/graph/api/resources/federatedidentitycredential?view=graph-rest-beta) | Coming soon | Coming soon |
4041

4142
## Deploying Bicep templates
4243

@@ -50,9 +51,10 @@ Make sure that you've updated Azure CLI and/or Azure PS to use the latest Bicep
5051
We've created some quick-start templates to get you started.
5152

5253
1. [Create an applications and service principals for a client and resource application](../quickstart-templates/application-serviceprincipal-create-client-resource/)
53-
2. [Create an application and service principal for a client app using a key vault certificate](../quickstart-templates/create-client-app-sp-with-kv-cert/)
54-
3. [Grant a client application access (via an app role) to a resource application](../quickstart-templates/resource-application-access-grant-to-client-application/)
55-
4. [Create a security group with owners and members](../quickstart-templates/security-group-create-with-owners-and-members/)
56-
5. [Assign an Azure role to a security group](../quickstart-templates/security-group-assign-azure-role/)
54+
1. [Create an application and service principal for a client app using a key vault certificate](../quickstart-templates/create-client-app-sp-with-kv-cert/)
55+
1. [Configure federated identity credential for GitHub Actions](../quickstart-templates/create-fic-for-github-actions/)
56+
1. [Grant a client application access (via an app role) to a resource application](../quickstart-templates/resource-application-access-grant-to-client-application/)
57+
1. [Create a security group with owners and members](../quickstart-templates/security-group-create-with-owners-and-members/)
58+
1. [Assign an Azure role to a security group](../quickstart-templates/security-group-assign-azure-role/)
5759

5860
Feel free to contribute and share your own samples too, by creating some PRs for template examples!

docs/use-existing-resources.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ Let's use an example with an existing group, created through the Entra Portal, t
2626
### PowerShell
2727

2828
```powershell
29-
Import-Module Microsoft.Graph.Beta.Groups
29+
Import-Module Microsoft.Graph.Groups
3030
3131
$params = @{
3232
uniqueName = "TestGroup-2023-10-10"
3333
}
3434
$groupId = "056b6fdc-ab19-4e91-9180-fa1f14c8f4fa"
3535
36-
Update-MgBetaGroup -GroupId $groupId -BodyParameter $params
36+
Update-MgGroup -GroupId $groupId -BodyParameter $params
3737
```
3838

3939
### HTTP request
4040

4141
```http
42-
PATCH https://graph.microsoft.com/beta/groups/056b6fdc-ab19-4e91-9180-fa1f14c8f4fa
42+
PATCH https://graph.microsoft.com/v1.0/groups/056b6fdc-ab19-4e91-9180-fa1f14c8f4fa
4343
Content-type: application/json
4444
```
4545

@@ -59,7 +59,7 @@ provider microsoftGraph
5959
@description('Group to use')
6060
param groupName string = 'TestGroup-2023-10-10'
6161
62-
resource group 'Microsoft.Graph/groups@beta' existing = {
62+
resource group 'Microsoft.Graph/groups@v1.0' existing = {
6363
name: groupName
6464
}
6565

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ param appRoleId string
77
@description('Value of the key credential')
88
param certKey string
99

10-
resource resourceApp 'Microsoft.Graph/applications@beta' = {
10+
resource resourceApp 'Microsoft.Graph/applications@v1.0' = {
1111
uniqueName: 'ExampleResourceApp'
1212
displayName: 'Example Resource Application'
1313
appRoles: [
@@ -22,11 +22,11 @@ resource resourceApp 'Microsoft.Graph/applications@beta' = {
2222
]
2323
}
2424

25-
resource resourceSp 'Microsoft.Graph/servicePrincipals@beta' = {
25+
resource resourceSp 'Microsoft.Graph/servicePrincipals@v1.0' = {
2626
appId: resourceApp.appId
2727
}
2828

29-
resource clientApp 'Microsoft.Graph/applications@beta' = {
29+
resource clientApp 'Microsoft.Graph/applications@v1.0' = {
3030
uniqueName: 'ExampleClientApp'
3131
displayName: 'Example Client Application'
3232
keyCredentials: [
@@ -39,6 +39,6 @@ resource clientApp 'Microsoft.Graph/applications@beta' = {
3939
]
4040
}
4141

42-
resource clientSp 'Microsoft.Graph/servicePrincipals@beta' = {
42+
resource clientSp 'Microsoft.Graph/servicePrincipals@v1.0' = {
4343
appId: clientApp.appId
4444
}

quickstart-templates/create-client-app-sp-with-kv-cert/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ az deployment group create --resource-group <resource-group> --parameter main.bi
1313

1414
To deploy the same template using Az Powershell, use:
1515

16-
```sh
16+
```powershell
1717
New-AzResourceGroupDeployment -ResourceGroupName bicep-deployments -TemplateFile .\main.bicep -TemplateParameterFile .\main.bicepparam -Verbose
1818
```

quickstart-templates/create-client-app-sp-with-kv-cert/main.bicep

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ resource createAddCertificate 'Microsoft.Resources/deploymentScripts@2020-10-01'
163163
}
164164

165165
// Create a client application, setting its credential to the X509 cert public key.
166-
resource clientApp 'Microsoft.Graph/applications@beta' = {
166+
resource clientApp 'Microsoft.Graph/applications@v1.0' = {
167167
uniqueName: clientAppName
168168
displayName: 'Example Client Application'
169169
keyCredentials: [
@@ -179,7 +179,7 @@ resource clientApp 'Microsoft.Graph/applications@beta' = {
179179
}
180180

181181
// Create a service principal for the client app
182-
resource clientSp 'Microsoft.Graph/servicePrincipals@beta' = {
182+
resource clientSp 'Microsoft.Graph/servicePrincipals@v1.0' = {
183183
appId: clientApp.appId
184184
}
185185

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Configure federated identity credential for GitHub Actions
2+
3+
> **Note**: This template sample **only** configures the Microsoft Entra ID portion (to enable workload identity federation). Additional configuration steps are also required on the GitHub side, to ensure that the federation works end-to-end. See [Use GitHub Actions to connect to Azure](https://learn.microsoft.com/azure/developer/github/connect-from-azure?tabs=azure-cli%2Cwindows#use-the-azure-login-action-with-openid-connect), but skip the sections on "Create a Microsoft Entra application and service principal" and "Add federated credentials", as the following Bicep template replaces those sections.
4+
5+
This template enables a GitHub Actions workflow to exchange a GitHub access token for a Microsoft Entra ID access token, so that the GitHub Actions workflow can access Azure resources. To enable this, the template creates an application (to represent the GitHub Action) and configures it with a federated identity credential. When the GitHub Actions workflow requests to exchange a GitHub access token for an access token, from the Microsoft identity platform, the values in the federated identity credential are checked against the provided GitHub token's `issuer` and `subject` claim values.
6+
7+
* `subject` identifies the GitHub organization, repo, branch, and environment for your GitHub Actions workflow. Refer to [example subject claims](https://docs.github.com/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#example-subject-claims) which describes the `subject` value options for different scenarios.
8+
9+
For limitations on federated identity credentials, please refer to [Federated identity credentials considerations and limitations](https://learn.microsoft.com/entra/workload-id/workload-identity-federation-considerations).
10+
11+
You can deploy the template with the following Azure CLI command (replace `<resource-group>` with name of your resource group, and `<github-actions-fic-subject>` with the `subject` based on your scenario.):
12+
13+
```sh
14+
az deployment group create --resource-group <resource-group> --template-file main.bicep --parameter githubActionsFicSubject='<github-actions-fic-subject>'
15+
```
16+
17+
To deploy the same template using Az Powershell, use:
18+
19+
```powershell
20+
New-AzResourceGroupDeployment -ResourceGroupName <resource-group> -TemplateFile .\main.bicep -githubActionsFicSubject '<github-actions-fic-subject>'
21+
```
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"experimentalFeaturesEnabled": {
3+
"extensibility": true,
4+
"microsoftGraphPreview": true
5+
}
6+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
provider microsoftGraph
2+
3+
@description('Subject of the GitHub Actions workflow\'s federated identity credentials (FIC) that is checked before issuing an Entra ID access token to access Azure resources. GitHub Actions subject examples can be found in https://docs.github.com/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#example-subject-claims')
4+
param githubActionsFicSubject string
5+
6+
@description('Role definition ID to be assigned')
7+
param roleDefinitionId string = 'b24988ac-6180-42a0-ab88-20f7382dd24c' // Contributor
8+
9+
var githubOIDCProvider = 'https://token.actions.githubusercontent.com'
10+
var microsoftEntraAudience = 'api://AzureADTokenExchange'
11+
12+
resource githubActionsApp 'Microsoft.Graph/applications@v1.0' = {
13+
uniqueName: 'githubActionsApp'
14+
displayName: 'Github Actions App'
15+
16+
resource githubFic 'federatedIdentityCredentials@beta' = {
17+
name: '${githubActionsApp.uniqueName}/githubFic'
18+
audiences: [microsoftEntraAudience]
19+
description: 'FIC for Github Actions to access Entra protected resources'
20+
issuer: githubOIDCProvider
21+
subject: githubActionsFicSubject
22+
}
23+
}
24+
25+
resource githubActionsSp 'Microsoft.Graph/servicePrincipals@v1.0' = {
26+
appId: githubActionsApp.appId
27+
}
28+
29+
// The service principal needs to be assigned the necessary role to access the resources
30+
// In this example, it is assigned with the `Contributor` role to the resource group
31+
// which will allow GitHub actions to access Azure resources in the resource group via Az PS/CLI
32+
var roleAssignmentName = guid('githubActions', roleDefinitionId, resourceGroup().id)
33+
resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
34+
name: roleAssignmentName
35+
properties: {
36+
principalId: githubActionsSp.id
37+
principalType: 'ServicePrincipal'
38+
roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', roleDefinitionId)
39+
}
40+
}

quickstart-templates/resource-application-access-grant-to-client-application/main.bicep

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ provider microsoftGraph
33
@description('Id of the application role to add to the resource app')
44
param appRoleId string
55

6-
resource resourceApp 'Microsoft.Graph/applications@beta' existing = {
6+
resource resourceApp 'Microsoft.Graph/applications@v1.0' existing = {
77
uniqueName: 'ExampleResourceApp'
88
}
99

10-
resource resourceSp 'Microsoft.Graph/servicePrincipals@beta' existing = {
10+
resource resourceSp 'Microsoft.Graph/servicePrincipals@v1.0' existing = {
1111
appId: resourceApp.appId
1212
}
1313

14-
resource clientApp 'Microsoft.Graph/applications@beta' existing = {
14+
resource clientApp 'Microsoft.Graph/applications@v1.0' existing = {
1515
uniqueName: 'ExampleClientApp'
1616
}
1717

18-
resource clientSp 'Microsoft.Graph/servicePrincipals@beta' existing = {
18+
resource clientSp 'Microsoft.Graph/servicePrincipals@v1.0' existing = {
1919
appId: clientApp.appId
2020
}
2121

22-
resource appRoleAssignment 'Microsoft.Graph/appRoleAssignedTo@beta' = {
22+
resource appRoleAssignment 'Microsoft.Graph/appRoleAssignedTo@v1.0' = {
2323
principalId: clientSp.id
2424
resourceId: resourceSp.id
2525
appRoleId: appRoleId

0 commit comments

Comments
 (0)