Aspirerelease/17.0

Customize Entra ID infrastructure

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

For each registration that Aspire creates, it generates Bicep that declares the application, its service principal, and any federated credentials, permission grants, and role assignments. Use ConfigureInfrastructure to set properties that Aspire doesn’t model, such as tags and the service management reference. You don’t need a bicepconfig.json.

ConfigureInfrastructure applies only to registrations that Aspire creates. References to existing registrations produce no infrastructure. For more information, see Existing registrations. For the shared pattern across Azure integrations, see Customize Azure resources.

Customize the application and service principal

Section titled “Customize the application and service principal”

The Graph models are public in the Aspire.Hosting.Azure.EntraId.Provisioning namespace. The primary declarations have the Bicep identifiers application and servicePrincipal, not the name of the Aspire resource. Look them up by identifier.

TypeScript AppHosts need the Aspire.Hosting.Azure.Provisioning.EntraId package, which generates typed proxies for the Graph models. Add it with the Aspire CLI:

Add typed Microsoft Graph infrastructure customization
aspire add Aspire.Hosting.Azure.Provisioning.EntraId
apphost.mts
import { createBuilder } from './.aspire/modules/aspire.mjs';
const builder = await createBuilder();
const serviceReference = await builder.addParameter("service-reference");
const entra = await builder.addEntraIdApplication("entra");
await entra.configureInfrastructure(async (infrastructure) => {
const application = await infrastructure.getMicrosoftGraphApplicationByIdentifier("application");
const tags = await application.tags.get();
await tags.add("department:engineering");
await application.serviceManagementReference.set(infrastructure.bicep().parameter(serviceReference));
const principal = await infrastructure.getMicrosoftGraphServicePrincipalByIdentifier("servicePrincipal");
const principalTags = await principal.tags.get();
await principalTags.add("department:engineering");
});
await builder.build().run();

The proxy properties use asynchronous get() and set() operations. Properties accept literals or shared Bicep values from infrastructure.bicep(), so a parameter stays a deployment-time value. For more information, see Compose Azure infrastructure with Bicep helpers.

Understand tags and the service management reference

Section titled “Understand tags and the service management reference”

Microsoft Graph application and service principal tags are string arrays, not Azure key and value tags. Add the exact string that you need. Applications also have a serviceManagementReference property, which holds a reference to a service or asset management database.

Add to the service principal’s tags and don’t replace them. Aspire sets the WindowsAzureActiveDirectoryIntegratedApp tag, which keeps the service principal in the Enterprise applications list.

Select the application by the identifier application. A registration that uses the default api://{clientId} URI has a second MicrosoftGraphApplication declaration with the identifier applicationIdentity.

Use the Aspire APIs for settings that Aspire models, such as the display name, redirect URIs, roles, and scopes. To inspect the module, see Inspect generated Bicep.