Skip to content

Commit d90170e

Browse files
committed
Fixed sample based on feedback
Also uses latest graph type version 0.1.9
1 parent e70c902 commit d90170e

3 files changed

Lines changed: 12 additions & 10 deletions

File tree

quickstart-templates/apps-permissions-and-grants/appGrantScopes.bicep

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ param graphSpId string
1616

1717
var app = 'myApp'
1818

19+
// convert scopes array into space separate scopes string
20+
var scopeArray = [for (scopeItem,i) in filteredScopes: filteredScopes[i].value]
21+
var scopeString = join(scopeArray, ' ')
22+
1923
// create basic app
2024
resource myApp 'Microsoft.Graph/applications@v1.0' = {
2125
displayName: displayName == null ? '${app}-${date}' :'${displayName}-${app}-${date}'
@@ -29,18 +33,16 @@ resource mySP 'Microsoft.Graph/servicePrincipals@v1.0' = {
2933

3034
// Grant the OAuth2.0 scopes (requested in parameters) to the basic app,
3135
// for all users in the tenant
32-
resource graphScopesAssignment 'Microsoft.Graph/oauth2PermissionGrants@v1.0' = [
33-
for (scopeItem,i) in filteredScopes: {
36+
resource graphScopesAssignment 'Microsoft.Graph/oauth2PermissionGrants@v1.0' = {
3437
clientId: mySP.id
3538
resourceId: graphSpId
3639
consentType: 'AllPrincipals'
37-
scope: filteredScopes[i].value
38-
}
39-
]
40+
scope: scopeString
41+
}
4042

4143
// output information
4244
output appName string = myApp.displayName
4345
output appObjectID string = myApp.id
4446
output appID string = myApp.appId
45-
output scopes array = [for (scopeItem,i) in filteredScopes: filteredScopes[i].value]
46-
output scopeGrants array = [for i in range(0, length(filteredScopes)): graphScopesAssignment[i]]
47+
output scopes array = scopeArray
48+
output grantedScopes string = graphScopesAssignment.scope

quickstart-templates/apps-permissions-and-grants/bicepconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
},
55
// specify an alias for the version of the v1.0 dynamic types package you want to use
66
"extensions": {
7-
"microsoftGraphV1": "br:mcr.microsoft.com/bicep/extensions/microsoftgraph/v1.0:0.1.8-preview"
7+
"microsoftGraphV1": "br:mcr.microsoft.com/bicep/extensions/microsoftgraph/v1.0:0.1.9-preview"
88
}
99
}

quickstart-templates/apps-permissions-and-grants/main.bicep

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ module appCreateGrantScopesModule './appGrantScopes.bicep' = if (mode == 'grant-
5959
output appName string = ((mode == 'set-required-scopes') ? appCreateRraModule.outputs.appName : appCreateGrantScopesModule.outputs.appName)
6060
output appObjectID string = ((mode == 'set-required-scopes') ? appCreateRraModule.outputs.appObjectID : appCreateGrantScopesModule.outputs.appObjectID)
6161
output appID string = ((mode == 'set-required-scopes') ? appCreateRraModule.outputs.appID : appCreateGrantScopesModule.outputs.appID)
62-
output foundScopes array = ((mode == 'set-required-scopes') ? appCreateRraModule.outputs.scopes: appCreateGrantScopesModule.outputs.scopes)
62+
output foundInputScopes array = ((mode == 'set-required-scopes') ? appCreateRraModule.outputs.scopes: appCreateGrantScopesModule.outputs.scopes)
6363
output clientAppResourceAccessList array = ((mode == 'set-required-scopes') ? appCreateRraModule.outputs.clientAppResourceAccessList : ['Not set'])
64-
output scopeGrants array = ((mode == 'grant-scopes') ? appCreateGrantScopesModule.outputs.scopeGrants : ['Not set'])
64+
output grantedScopes string = ((mode == 'grant-scopes') ? appCreateGrantScopesModule.outputs.grantedScopes : 'Not set')

0 commit comments

Comments
 (0)