Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Register Microsoft Entra ID apps and configure OAuth 2.0 authentication with MSAL integration.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/BICEP-EXAMPLE.bicep
1// Bicep template for Microsoft Entra App Registration2// Requires: Bicep v0.21.1+ with Microsoft Graph extension enabled34extension 'br:mcr.microsoft.com/bicep/extensions/microsoftgraph/v1.0:1.0.0'56@description('Display name for the application')7param appDisplayName string = 'MyEntraApp'89@description('Sign-in audience for the application')10@allowed([11'AzureADMyOrg'12'AzureADMultipleOrgs'13'AzureADandPersonalMicrosoftAccount'14'PersonalMicrosoftAccount'15])16param signInAudience string = 'AzureADMyOrg'1718@description('Redirect URIs for web application')19param webRedirectUris array = [20'https://localhost:5001/signin-oidc'21'https://myapp.azurewebsites.net/signin-oidc'22]2324@description('Redirect URIs for single-page application')25param spaRedirectUris array = [26'http://localhost:3000'27'https://myapp.azurewebsites.net'28]2930@description('Tags for the application')31param tags array = [32'Production'33'WebApp'34]3536// App Registration37resource appRegistration 'Microsoft.Graph/[email protected]' = {38displayName: appDisplayName39uniqueName: toLower(replace(appDisplayName, ' ', '-'))40signInAudience: signInAudience41tags: tags4243// Application identification44identifierUris: [45'api://${appDisplayName}'46]4748// Web application settings49web: {50redirectUris: webRedirectUris51implicitGrantSettings: {52enableIdTokenIssuance: true53enableAccessTokenIssuance: false54}55homePageUrl: 'https://myapp.azurewebsites.net'56logoutUrl: 'https://myapp.azurewebsites.net/signout-oidc'57}5859// Single-page application settings60spa: {61redirectUris: spaRedirectUris62}6364// Public client (mobile/desktop) settings65publicClient: {66redirectUris: [67'http://localhost'68'myapp://auth'69'https://login.microsoftonline.com/common/oauth2/nativeclient'70]71}7273// API definition (expose an API)74api: {75// Version of the access token affects the values present in the token claims76requestedAccessTokenVersion: 277oauth2PermissionScopes: [78{79id: '00000000-0000-0000-0000-000000000001'80adminConsentDisplayName: 'Read user data'81adminConsentDescription: 'Allows the app to read user data on behalf of the signed-in user'82userConsentDisplayName: 'Read your data'83userConsentDescription: 'Allows the app to read your data'84value: 'User.Read'85type: 'User'86isEnabled: true87}88{89id: '00000000-0000-0000-0000-000000000002'90adminConsentDisplayName: 'Read and write user data'91adminConsentDescription: 'Allows the app to read and write user data on behalf of the signed-in user'92userConsentDisplayName: 'Read and write your data'93userConsentDescription: 'Allows the app to read and write your data'94value: 'User.ReadWrite'95type: 'User'96isEnabled: true97}98]99}100101// App roles for authorization102appRoles: [103{104id: '00000000-0000-0000-0000-000000000010'105displayName: 'Admin'106description: 'Administrators can manage all aspects of the app'107value: 'Admin'108allowedMemberTypes: ['User', 'Application']109isEnabled: true110}111{112id: '00000000-0000-0000-0000-000000000011'113displayName: 'Reader'114description: 'Readers can view data but not modify'115value: 'Reader'116allowedMemberTypes: ['User']117isEnabled: true118}119]120121// Required API permissions (Microsoft Graph)122requiredResourceAccess: [123{124// Microsoft Graph API125resourceAppId: '00000003-0000-0000-c000-000000000000'126resourceAccess: [127{128// User.Read - Delegated129id: 'e1fe6dd8-ba31-4d61-89e7-88639da4683d'130type: 'Scope'131}132{133// User.ReadBasic.All - Delegated134id: 'b340eb25-3456-403f-be2f-af7a0d370277'135type: 'Scope'136}137{138// Mail.Read - Delegated139id: '570282fd-fa5c-430d-a7fd-fc8dc98a9dca'140type: 'Scope'141}142{143// User.Read.All - Application144id: 'df021288-bdef-4463-88db-98f22de89214'145type: 'Role'146}147]148}149]150151// Optional claims configuration152optionalClaims: {153idToken: [154{155name: 'email'156essential: false157}158{159name: 'upn'160essential: false161}162{163name: 'groups'164essential: false165}166]167accessToken: [168{169name: 'email'170essential: false171}172]173}174175// Information URLs176info: {177marketingUrl: 'https://myapp.example.com'178privacyStatementUrl: 'https://myapp.example.com/privacy'179supportUrl: 'https://myapp.example.com/support'180termsOfServiceUrl: 'https://myapp.example.com/terms'181}182}183184// Service Principal (Enterprise Application)185resource servicePrincipal 'Microsoft.Graph/[email protected]' = {186appId: appRegistration.appId187displayName: appDisplayName188tags: [189'WindowsAzureActiveDirectoryIntegratedApp'190]191appRoleAssignmentRequired: false192preferredSingleSignOnMode: 'oidc'193}194195// Outputs196output applicationId string = appRegistration.appId197output objectId string = appRegistration.id198output servicePrincipalId string = servicePrincipal.id199output identifierUri string = appRegistration.identifierUris[0]200