AzureApiManagementExtensions Methods
AddApi(IResourceBuilder<AzureApiManagementResource>, string, IResourceBuilder<T>, string, string?, bool, string?) Section titled AddApi(IResourceBuilder<AzureApiManagementResource>, string, IResourceBuilder<T>, string, string?, bool, string?)extensionIResourceBuilder<AzureApiManagementApiResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementApiResource> AddApi<T>( this IResourceBuilder<AzureApiManagementResource> builder, string name, IResourceBuilder<T> target, string path, string? displayName = null, bool subscriptionRequired = true, string? apiName = null) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> The Azure API Management resource builder.namestringThe globally unique Aspire resource name and default physical API name.targetIResourceBuilder<T> The backend compute resource. It must expose an HTTP or HTTPS endpoint. Internal endpoints require the API Management service to have virtual network connectivity to the target. pathstringThe public path beneath the API Management gateway hostname.displayName string?optionalThe API display name. The resource name is used when omitted.subscriptionRequired booloptionalWhether callers must provide an API Management subscription key. The default is true.apiName string?optionalThe physical API identifier in API Management. The Aspire resource name is used when omitted.Returns
IResourceBuilder<AzureApiManagementApiResource> A builder for the API resource.Exceptions
ArgumentNullExceptionThrown when builder or target is null.ArgumentExceptionThrown when a required string is empty.Remarks
AddApi(IResourceBuilder<AzureApiManagementResource>, string, string, string?, bool, string?) Section titled AddApi(IResourceBuilder<AzureApiManagementResource>, string, string, string?, bool, string?)extensionIResourceBuilder<AzureApiManagementApiResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementApiResource> AddApi( this IResourceBuilder<AzureApiManagementResource> builder, string name, string path, string? displayName = null, bool subscriptionRequired = true, string? apiName = null) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> The Azure API Management resource builder.namestringThe globally unique Aspire resource name and default physical API name.pathstringThe public path beneath the API Management gateway hostname.displayName string?optionalThe API display name. The resource name is used when omitted.subscriptionRequired booloptionalWhether callers must provide an API Management subscription key. The default is true.apiName string?optionalThe physical API identifier in API Management. The Aspire resource name is used when omitted.Returns
IResourceBuilder<AzureApiManagementApiResource> A builder for the API resource.Remarks
AzureApiManagementExtensions.WithBackend or AzureApiManagementExtensions.WithBackend . AddAzureApiManagement(IDistributedApplicationBuilder, string, AzureApiManagementOptions) Section titled AddAzureApiManagement(IDistributedApplicationBuilder, string, AzureApiManagementOptions)extensionIResourceBuilder<AzureApiManagementResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementResource> AddAzureApiManagement( this IDistributedApplicationBuilder builder, string name, AzureApiManagementOptions options) { // ... }}Parameters
builderIDistributedApplicationBuilder The distributed application builder.namestringThe name of the Aspire resource.optionsAzureReturns
IResourceBuilder<AzureApiManagementResource> A builder for the Azure API Management resource.Exceptions
ArgumentNullExceptionThrown when builder or options is null.ArgumentExceptionThrown when required option values are empty or capacity is invalid for the selected SKU.Examples
var apim = builder.AddAzureApiManagement("apim", new(){ PublisherEmail = "api-owners@example.com", PublisherName = "Contoso APIs", Sku = AzureApiManagementSku.StandardV2,});AddAzureOpenAIBackend(IResourceBuilder<AzureApiManagementResource>, string, IResourceBuilder<AzureOpenAIDeploymentResource>, string?) Section titled AddAzureOpenAIBackend(IResourceBuilder<AzureApiManagementResource>, string, IResourceBuilder<AzureOpenAIDeploymentResource>, string?)extensionIResourceBuilder<AzureApiManagementBackendResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementBackendResource> AddAzureOpenAIBackend( this IResourceBuilder<AzureApiManagementResource> builder, string name, IResourceBuilder<AzureOpenAIDeploymentResource> deployment, string? backendName = null) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> namestringdeploymentIResourceBuilder<AzureOpenAIDeploymentResource> backendName string?optionalAddBackend(IResourceBuilder<AzureApiManagementResource>, string, ReferenceExpression, AzureApiManagementBackendOptions?, string?) Section titled AddBackend(IResourceBuilder<AzureApiManagementResource>, string, ReferenceExpression, AzureApiManagementBackendOptions?, string?)extensionIResourceBuilder<AzureApiManagementBackendResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementBackendResource> AddBackend( this IResourceBuilder<AzureApiManagementResource> builder, string name, ReferenceExpression uri, AzureApiManagementBackendOptions? options = null, string? backendName = null) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> The API Management resource builder.namestringThe globally unique Aspire resource name and default physical backend name.uriReferenceExpression The deferred URI of the backend service.optionsAzurebackendName string?optionalThe physical backend identifier in API Management. The Aspire resource name is used when omitted.Returns
IResourceBuilder<AzureApiManagementBackendResource> A builder for the backend resource.AddBackendPool(IResourceBuilder<AzureApiManagementResource>, string, string?, string?) Section titled AddBackendPool(IResourceBuilder<AzureApiManagementResource>, string, string?, string?)extensionIResourceBuilder<AzureApiManagementBackendPoolResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementBackendPoolResource> AddBackendPool( this IResourceBuilder<AzureApiManagementResource> builder, string name, string? displayName = null, string? backendPoolName = null) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> namestringdisplayName string?optionalbackendPoolName string?optionalAddBlobStorageBackend(IResourceBuilder<AzureApiManagementResource>, string, IResourceBuilder<AzureBlobStorageResource>, string?) Section titled AddBlobStorageBackend(IResourceBuilder<AzureApiManagementResource>, string, IResourceBuilder<AzureBlobStorageResource>, string?)extensionIResourceBuilder<AzureApiManagementBackendResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementBackendResource> AddBlobStorageBackend( this IResourceBuilder<AzureApiManagementResource> builder, string name, IResourceBuilder<AzureBlobStorageResource> blobs, string? backendName = null) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> namestringblobsIResourceBuilder<AzureBlobStorageResource> backendName string?optionalAddFoundryBackend(IResourceBuilder<AzureApiManagementResource>, string, IResourceBuilder<FoundryDeploymentResource>, string?) Section titled AddFoundryBackend(IResourceBuilder<AzureApiManagementResource>, string, IResourceBuilder<FoundryDeploymentResource>, string?)extensionIResourceBuilder<AzureApiManagementBackendResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementBackendResource> AddFoundryBackend( this IResourceBuilder<AzureApiManagementResource> builder, string name, IResourceBuilder<FoundryDeploymentResource> deployment, string? backendName = null) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> namestringdeploymentIResourceBuilder<FoundryDeploymentResource> backendName string?optionalAddKeyVaultNamedValue(IResourceBuilder<AzureApiManagementResource>, string, IAzureKeyVaultSecretReference, string?, string?, string[]?) Section titled AddKeyVaultNamedValue(IResourceBuilder<AzureApiManagementResource>, string, IAzureKeyVaultSecretReference, string?, string?, string[]?)extensionIResourceBuilder<AzureApiManagementNamedValueResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementNamedValueResource> AddKeyVaultNamedValue( this IResourceBuilder<AzureApiManagementResource> builder, string name, IAzureKeyVaultSecretReference value, string? displayName = null, string? namedValueName = null, string[]? tags = null) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> The Azure API Management resource builder.namestringThe globally unique Aspire resource name and default physical named-value name.valueIAzureKeyVaultSecretReference The Key Vault secret reference.displayName string?optionalThe name used to reference the value in policies. The resource name is used when omitted.namedValueName string?optionalThe physical named-value identifier in API Management. The resource name is used when omitted.tagsstring[]? optionalTags used to organize the named value.Returns
IResourceBuilder<AzureApiManagementNamedValueResource> A builder for the named-value resource.AddNamedValue(IResourceBuilder<AzureApiManagementResource>, string, string, string?, string?, string[]?) Section titled AddNamedValue(IResourceBuilder<AzureApiManagementResource>, string, string, string?, string?, string[]?)extensionIResourceBuilder<AzureApiManagementNamedValueResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementNamedValueResource> AddNamedValue( this IResourceBuilder<AzureApiManagementResource> builder, string name, string value, string? displayName = null, string? namedValueName = null, string[]? tags = null) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> The Azure API Management resource builder.namestringThe globally unique Aspire resource name and default physical named-value name.valuestringThe named value.displayName string?optionalThe name used to reference the value in policies. The resource name is used when omitted.namedValueName string?optionalThe physical named-value identifier in API Management. The resource name is used when omitted.tagsstring[]? optionalTags used to organize the named value.Returns
IResourceBuilder<AzureApiManagementNamedValueResource> A builder for the named-value resource.AddOpenAIApi(IResourceBuilder<AzureApiManagementResource>, string, string, string?, bool, string?) Section titled AddOpenAIApi(IResourceBuilder<AzureApiManagementResource>, string, string, string?, bool, string?)extensionIResourceBuilder<AzureApiManagementApiResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementApiResource> AddOpenAIApi( this IResourceBuilder<AzureApiManagementResource> builder, string name, string path, string? displayName = null, bool subscriptionRequired = true, string? apiName = null) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> The Azure API Management resource builder.namestringThe globally unique Aspire resource name and default physical API name.pathstringThe public path beneath the API Management gateway hostname.displayName string?optionalThe API display name. The resource name is used when omitted.subscriptionRequired booloptionalWhether callers must provide an API Management subscription key. The default is true.apiName string?optionalThe physical API identifier in API Management. The Aspire resource name is used when omitted.Returns
IResourceBuilder<AzureApiManagementApiResource> A builder for the API resource.Remarks
AzureApiManagementExtensions.AddAzureOpenAIBackend or AzureApiManagementExtensions.AddFoundryBackend , compose them with AzureApiManagementExtensions.AddBackendPool , and attach the pool with AzureApiManagementExtensions.WithBackend . Requests beneath path are appended to the selected backend URI. AddOperation(IResourceBuilder<AzureApiManagementApiResource>, string, string, string, string?, string?) Section titled AddOperation(IResourceBuilder<AzureApiManagementApiResource>, string, string, string, string?, string?)extensionIResourceBuilder<AzureApiManagementOperationResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementOperationResource> AddOperation( this IResourceBuilder<AzureApiManagementApiResource> builder, string name, string method, string urlTemplate, string? displayName = null, string? operationName = null) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementApiResource> The API resource builder.namestringThe globally unique Aspire resource name and default physical operation name.methodstringThe HTTP method.urlTemplate stringThe URL template relative to the API path.displayName string?optionalThe operation display name. The resource name is used when omitted.operationName string?optionalThe physical operation identifier in API Management. The Aspire resource name is used when omitted.Returns
IResourceBuilder<AzureApiManagementOperationResource> A builder for the operation resource.Exceptions
ArgumentNullExceptionThrown when builder is null.ArgumentExceptionThrown when a required string is empty.InvalidOperationExceptionThrown when the operation identifier or route duplicates another operation or conflicts with a generated proxy route.AddPolicyFragment(IResourceBuilder<AzureApiManagementResource>, string, string, string?, string?) Section titled AddPolicyFragment(IResourceBuilder<AzureApiManagementResource>, string, string, string?, string?)extensionIResourceBuilder<AzureApiManagementPolicyFragmentResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementPolicyFragmentResource> AddPolicyFragment( this IResourceBuilder<AzureApiManagementResource> builder, string name, string policyXml, string? description = null, string? fragmentName = null) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> The Azure API Management resource builder.namestringThe globally unique Aspire resource name and default physical policy-fragment name.policyXml stringOne or more well-formed APIM policy elements without a fragment envelope.descriptionstring?optionalAn optional description.fragmentName string?optionalThe physical policy-fragment identifier in API Management. The resource name is used when omitted.Returns
IResourceBuilder<AzureApiManagementPolicyFragmentResource> A builder for the policy-fragment resource.AddProduct(IResourceBuilder<AzureApiManagementResource>, string, string, AzureApiManagementProductOptions?, string?) Section titled AddProduct(IResourceBuilder<AzureApiManagementResource>, string, string, AzureApiManagementProductOptions?, string?)extensionIResourceBuilder<AzureApiManagementProductResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementProductResource> AddProduct( this IResourceBuilder<AzureApiManagementResource> builder, string name, string displayName, AzureApiManagementProductOptions? options = null, string? productName = null) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> The Azure API Management resource builder.namestringThe globally unique Aspire resource name and default physical product name.displayName stringThe product display name.optionsAzureproductName string?optionalThe physical product identifier in API Management. The resource name is used when omitted.Returns
IResourceBuilder<AzureApiManagementProductResource> A builder for the product resource.AddSecretNamedValue(IResourceBuilder<AzureApiManagementResource>, string, IResourceBuilder<ParameterResource>, string?, string?, string[]?) Section titled AddSecretNamedValue(IResourceBuilder<AzureApiManagementResource>, string, IResourceBuilder<ParameterResource>, string?, string?, string[]?)extensionIResourceBuilder<AzureApiManagementNamedValueResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementNamedValueResource> AddSecretNamedValue( this IResourceBuilder<AzureApiManagementResource> builder, string name, IResourceBuilder<ParameterResource> value, string? displayName = null, string? namedValueName = null, string[]? tags = null) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> The Azure API Management resource builder.namestringThe globally unique Aspire resource name and default physical named-value name.valueIResourceBuilder<ParameterResource> The secret parameter containing the named value.displayName string?optionalThe name used to reference the value in policies. The resource name is used when omitted.namedValueName string?optionalThe physical named-value identifier in API Management. The resource name is used when omitted.tagsstring[]? optionalTags used to organize the named value.Returns
IResourceBuilder<AzureApiManagementNamedValueResource> A builder for the named-value resource.AddSubscription(IResourceBuilder<AzureApiManagementProductResource>, string, string, AzureApiManagementSubscriptionOptions?, string?) Section titled AddSubscription(IResourceBuilder<AzureApiManagementProductResource>, string, string, AzureApiManagementSubscriptionOptions?, string?)extensionIResourceBuilder<AzureApiManagementSubscriptionResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementSubscriptionResource> AddSubscription( this IResourceBuilder<AzureApiManagementProductResource> builder, string name, string displayName, AzureApiManagementSubscriptionOptions? options = null, string? subscriptionName = null) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementProductResource> The API Management product resource builder.namestringThe globally unique Aspire resource name and default physical subscription name.displayName stringThe subscription display name.optionsAzuresubscriptionName string?optionalThe physical subscription identifier in API Management. The resource name is used when omitted.Returns
IResourceBuilder<AzureApiManagementSubscriptionResource> A builder for the subscription resource.Remarks
WithApi(IResourceBuilder<AzureApiManagementProductResource>, IResourceBuilder<AzureApiManagementApiResource>) Section titled WithApi(IResourceBuilder<AzureApiManagementProductResource>, IResourceBuilder<AzureApiManagementApiResource>)extensionIResourceBuilder<AzureApiManagementProductResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementProductResource> WithApi( this IResourceBuilder<AzureApiManagementProductResource> builder, IResourceBuilder<AzureApiManagementApiResource> api) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementProductResource> The API Management product resource builder.apiIResourceBuilder<AzureApiManagementApiResource> The API to add to the product.Returns
IResourceBuilder<AzureApiManagementProductResource> The product resource builder.WithApplicationInsights(IResourceBuilder<AzureApiManagementResource>, IResourceBuilder<AzureApplicationInsightsResource>, AzureApiManagementDiagnosticOptions?) Section titled WithApplicationInsights(IResourceBuilder<AzureApiManagementResource>, IResourceBuilder<AzureApplicationInsightsResource>, AzureApiManagementDiagnosticOptions?)extensionIResourceBuilder<AzureApiManagementResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementResource> WithApplicationInsights( this IResourceBuilder<AzureApiManagementResource> builder, IResourceBuilder<AzureApplicationInsightsResource> applicationInsights, AzureApiManagementDiagnosticOptions? options = null) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> The Azure API Management resource builder.applicationInsights IResourceBuilder<AzureApplicationInsightsResource> The Application Insights resource.optionsAzureReturns
IResourceBuilder<AzureApiManagementResource> The resource builder.WithApplicationInsights(IResourceBuilder<AzureApiManagementApiResource>, IResourceBuilder<AzureApplicationInsightsResource>, AzureApiManagementDiagnosticOptions?) Section titled WithApplicationInsights(IResourceBuilder<AzureApiManagementApiResource>, IResourceBuilder<AzureApplicationInsightsResource>, AzureApiManagementDiagnosticOptions?)extensionIResourceBuilder<AzureApiManagementApiResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementApiResource> WithApplicationInsights( this IResourceBuilder<AzureApiManagementApiResource> builder, IResourceBuilder<AzureApplicationInsightsResource> applicationInsights, AzureApiManagementDiagnosticOptions? options = null) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementApiResource> The API Management API resource builder.applicationInsights IResourceBuilder<AzureApplicationInsightsResource> The Application Insights resource.optionsAzureReturns
IResourceBuilder<AzureApiManagementApiResource> The resource builder.WithAzureUserAssignedIdentity(IResourceBuilder<AzureApiManagementResource>, IResourceBuilder<AzureUserAssignedIdentityResource>) Section titled WithAzureUserAssignedIdentity(IResourceBuilder<AzureApiManagementResource>, IResourceBuilder<AzureUserAssignedIdentityResource>)extensionIResourceBuilder<AzureApiManagementResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementResource> WithAzureUserAssignedIdentity( this IResourceBuilder<AzureApiManagementResource> builder, IResourceBuilder<AzureUserAssignedIdentityResource> identityResourceBuilder) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> The Azure API Management resource builder.identityResourceBuilder IResourceBuilder<AzureUserAssignedIdentityResource> The user-assigned managed identity.Returns
IResourceBuilder<AzureApiManagementResource> The Azure API Management resource builder.Exceptions
ArgumentNullExceptionThrown when builder or identityResourceBuilder is null.Remarks
WithBackend(IResourceBuilder<AzureApiManagementBackendPoolResource>, IResourceBuilder<AzureApiManagementBackendResource>, int, int) Section titled WithBackend(IResourceBuilder<AzureApiManagementBackendPoolResource>, IResourceBuilder<AzureApiManagementBackendResource>, int, int)extensionIResourceBuilder<AzureApiManagementBackendPoolResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementBackendPoolResource> WithBackend( this IResourceBuilder<AzureApiManagementBackendPoolResource> builder, IResourceBuilder<AzureApiManagementBackendResource> backend, int priority = 1, int weight = 1) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementBackendPoolResource> backendIResourceBuilder<AzureApiManagementBackendResource> priorityintoptionalweightintoptionalWithBackend(IResourceBuilder<AzureApiManagementApiResource>, IResourceBuilder<AzureApiManagementBackendResource>) Section titled WithBackend(IResourceBuilder<AzureApiManagementApiResource>, IResourceBuilder<AzureApiManagementBackendResource>)extensionIResourceBuilder<AzureApiManagementApiResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementApiResource> WithBackend( this IResourceBuilder<AzureApiManagementApiResource> builder, IResourceBuilder<AzureApiManagementBackendResource> backend) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementApiResource> backendIResourceBuilder<AzureApiManagementBackendResource> WithBackend(IResourceBuilder<AzureApiManagementApiResource>, IResourceBuilder<AzureApiManagementBackendPoolResource>) Section titled WithBackend(IResourceBuilder<AzureApiManagementApiResource>, IResourceBuilder<AzureApiManagementBackendPoolResource>)extensionIResourceBuilder<AzureApiManagementApiResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementApiResource> WithBackend( this IResourceBuilder<AzureApiManagementApiResource> builder, IResourceBuilder<AzureApiManagementBackendPoolResource> backend) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementApiResource> backendIResourceBuilder<AzureApiManagementBackendPoolResource> WithClassicVirtualNetwork(IResourceBuilder<AzureApiManagementResource>, IResourceBuilder<AzureSubnetResource>, AzureApiManagementVirtualNetworkMode) Section titled WithClassicVirtualNetwork(IResourceBuilder<AzureApiManagementResource>, IResourceBuilder<AzureSubnetResource>, AzureApiManagementVirtualNetworkMode)extensionIResourceBuilder<AzureApiManagementResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementResource> WithClassicVirtualNetwork( this IResourceBuilder<AzureApiManagementResource> builder, IResourceBuilder<AzureSubnetResource> subnet, AzureApiManagementVirtualNetworkMode mode) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> The Azure API Management resource builder.subnetIResourceBuilder<AzureSubnetResource> The subnet resource. Classic APIM injection requires an undelegated subnet with an NSG.modeAzureReturns
IResourceBuilder<AzureApiManagementResource> The resource builder.Exceptions
InvalidOperationExceptionThrown when the selected SKU does not support classic VNet injection or the subnet is delegated.Remarks
AzureApiManagementExtensions.WithVirtualNetworkIntegration for Standard v2 outbound integration or AzureApiManagementExtensions.WithVirtualNetworkInjection for Premium v2 injection. See APIM virtual networking. WithCustomDomain(IResourceBuilder<AzureApiManagementResource>, string, IAzureKeyVaultSecretReference, AzureApiManagementHostnameType, bool, bool) Section titled WithCustomDomain(IResourceBuilder<AzureApiManagementResource>, string, IAzureKeyVaultSecretReference, AzureApiManagementHostnameType, bool, bool)extensionIResourceBuilder<AzureApiManagementResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementResource> WithCustomDomain( this IResourceBuilder<AzureApiManagementResource> builder, string hostname, IAzureKeyVaultSecretReference certificate, AzureApiManagementHostnameType type = AzureApiManagementHostnameType.Proxy, bool defaultSslBinding = false, bool negotiateClientCertificate = false) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> The Azure API Management resource builder.hostnamestringThe fully qualified custom hostname.certificateIAzureKeyVaultSecretReference The Key Vault secret containing a PFX certificate.typeAzuredefaultSslBinding booloptionalWhether this certificate is the default SNI fallback. This is valid only for gateway hostnames.negotiateClientCertificate booloptionalWhether the endpoint negotiates client certificates.Returns
IResourceBuilder<AzureApiManagementResource> The resource builder.WithInboundPolicy(IResourceBuilder<AzureApiManagementResource>, string) Section titled WithInboundPolicy(IResourceBuilder<AzureApiManagementResource>, string)extensionIResourceBuilder<AzureApiManagementResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementResource> WithInboundPolicy( this IResourceBuilder<AzureApiManagementResource> builder, string policyXml) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> The Azure API Management resource builder.policyXml stringOne or more well-formed APIM policy elements without a policies envelope.Returns
IResourceBuilder<AzureApiManagementResource> The resource builder.Exceptions
ArgumentExceptionThrown when policyXml is empty or is not a valid XML fragment.WithInboundPolicy(IResourceBuilder<AzureApiManagementApiResource>, string) Section titled WithInboundPolicy(IResourceBuilder<AzureApiManagementApiResource>, string)extensionIResourceBuilder<AzureApiManagementApiResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementApiResource> WithInboundPolicy( this IResourceBuilder<AzureApiManagementApiResource> builder, string policyXml) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementApiResource> The API resource builder.policyXml stringOne or more well-formed APIM policy elements without a policies envelope.Returns
IResourceBuilder<AzureApiManagementApiResource> The resource builder.Exceptions
ArgumentExceptionThrown when policyXml is empty or is not a valid XML fragment.WithInboundPolicy(IResourceBuilder<AzureApiManagementOperationResource>, string) Section titled WithInboundPolicy(IResourceBuilder<AzureApiManagementOperationResource>, string)extensionIResourceBuilder<AzureApiManagementOperationResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementOperationResource> WithInboundPolicy( this IResourceBuilder<AzureApiManagementOperationResource> builder, string policyXml) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementOperationResource> The operation resource builder.policyXml stringOne or more well-formed APIM policy elements without a policies envelope.Returns
IResourceBuilder<AzureApiManagementOperationResource> The resource builder.Exceptions
ArgumentExceptionThrown when policyXml is empty or is not a valid XML fragment.WithInboundPolicyFragment(IResourceBuilder<AzureApiManagementResource>, IResourceBuilder<AzureApiManagementPolicyFragmentResource>) Section titled WithInboundPolicyFragment(IResourceBuilder<AzureApiManagementResource>, IResourceBuilder<AzureApiManagementPolicyFragmentResource>)extensionIResourceBuilder<AzureApiManagementResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementResource> WithInboundPolicyFragment( this IResourceBuilder<AzureApiManagementResource> builder, IResourceBuilder<AzureApiManagementPolicyFragmentResource> fragment) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> The Azure API Management resource builder.fragmentIResourceBuilder<AzureApiManagementPolicyFragmentResource> The policy fragment to include.Returns
IResourceBuilder<AzureApiManagementResource> The resource builder.WithInboundPolicyFragment(IResourceBuilder<AzureApiManagementApiResource>, IResourceBuilder<AzureApiManagementPolicyFragmentResource>) Section titled WithInboundPolicyFragment(IResourceBuilder<AzureApiManagementApiResource>, IResourceBuilder<AzureApiManagementPolicyFragmentResource>)extensionIResourceBuilder<AzureApiManagementApiResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementApiResource> WithInboundPolicyFragment( this IResourceBuilder<AzureApiManagementApiResource> builder, IResourceBuilder<AzureApiManagementPolicyFragmentResource> fragment) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementApiResource> The API Management API resource builder.fragmentIResourceBuilder<AzureApiManagementPolicyFragmentResource> The policy fragment to include.Returns
IResourceBuilder<AzureApiManagementApiResource> The resource builder.WithInboundPolicyFragment(IResourceBuilder<AzureApiManagementOperationResource>, IResourceBuilder<AzureApiManagementPolicyFragmentResource>) Section titled WithInboundPolicyFragment(IResourceBuilder<AzureApiManagementOperationResource>, IResourceBuilder<AzureApiManagementPolicyFragmentResource>)extensionIResourceBuilder<AzureApiManagementOperationResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementOperationResource> WithInboundPolicyFragment( this IResourceBuilder<AzureApiManagementOperationResource> builder, IResourceBuilder<AzureApiManagementPolicyFragmentResource> fragment) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementOperationResource> The API Management operation resource builder.fragmentIResourceBuilder<AzureApiManagementPolicyFragmentResource> The policy fragment to include.Returns
IResourceBuilder<AzureApiManagementOperationResource> The resource builder.WithOpenApiDocument(IResourceBuilder<AzureApiManagementApiResource>, string, AzureApiManagementOpenApiFormat?) Section titled WithOpenApiDocument(IResourceBuilder<AzureApiManagementApiResource>, string, AzureApiManagementOpenApiFormat?)extensionIResourceBuilder<AzureApiManagementApiResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementApiResource> WithOpenApiDocument( this IResourceBuilder<AzureApiManagementApiResource> builder, string documentPath, AzureApiManagementOpenApiFormat? format = null) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementApiResource> The API Management API resource builder.documentPath stringThe document path, relative to the AppHost directory when not absolute.formatAzureReturns
IResourceBuilder<AzureApiManagementApiResource> The API Management API resource builder.Exceptions
ArgumentNullExceptionThrown when builder is null.ArgumentExceptionThrown when documentPath is empty or its extension cannot determine the format.InvalidOperationExceptionThrown when a different OpenAPI source is already configured.Remarks
WithOpenApiEndpoint(IResourceBuilder<AzureApiManagementApiResource>, string, string?, AzureApiManagementOpenApiFormat?) Section titled WithOpenApiEndpoint(IResourceBuilder<AzureApiManagementApiResource>, string, string?, AzureApiManagementOpenApiFormat?)extensionIResourceBuilder<AzureApiManagementApiResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementApiResource> WithOpenApiEndpoint( this IResourceBuilder<AzureApiManagementApiResource> builder, string documentPath = "/openapi/v1.json", string? endpointName = null, AzureApiManagementOpenApiFormat? format = null) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementApiResource> The API Management API resource builder.documentPath stringoptionalThe absolute path of the OpenAPI endpoint, such as /openapi/v1.json .endpointName string?optionalThe target endpoint name. An external HTTP or HTTPS endpoint is selected when omitted.formatAzureReturns
IResourceBuilder<AzureApiManagementApiResource> The API Management API resource builder.Exceptions
ArgumentNullExceptionThrown when builder is null.ArgumentExceptionThrown when documentPath is empty or is not an absolute path.InvalidOperationExceptionThrown when a different OpenAPI source is already configured, or the API has no target compute resource or no suitable external endpoint.Remarks
AzureApiManagementExtensions.WithOpenApiDocument for private backends. An API can have only one OpenAPI source: either a document file or an endpoint. Repeating the same source configuration is allowed; configuring a different source throws. WithPolicy(IResourceBuilder<AzureApiManagementResource>, string) Section titled WithPolicy(IResourceBuilder<AzureApiManagementResource>, string)extensionIResourceBuilder<AzureApiManagementResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementResource> WithPolicy( this IResourceBuilder<AzureApiManagementResource> builder, string policyXml) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> The Azure API Management resource builder.policyXml stringA complete APIM policies XML document.Returns
IResourceBuilder<AzureApiManagementResource> The resource builder.Exceptions
ArgumentExceptionThrown when policyXml is not a complete policy document.Remarks
AzureApiManagementExtensions.WithInboundPolicy at the same scope. WithPolicy(IResourceBuilder<AzureApiManagementApiResource>, string) Section titled WithPolicy(IResourceBuilder<AzureApiManagementApiResource>, string)extensionIResourceBuilder<AzureApiManagementApiResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementApiResource> WithPolicy( this IResourceBuilder<AzureApiManagementApiResource> builder, string policyXml) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementApiResource> The API resource builder.policyXml stringA complete APIM policies XML document.Returns
IResourceBuilder<AzureApiManagementApiResource> The resource builder.Exceptions
ArgumentExceptionThrown when policyXml is not a complete policy document.Remarks
WithPolicy(IResourceBuilder<AzureApiManagementOperationResource>, string) Section titled WithPolicy(IResourceBuilder<AzureApiManagementOperationResource>, string)extensionIResourceBuilder<AzureApiManagementOperationResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementOperationResource> WithPolicy( this IResourceBuilder<AzureApiManagementOperationResource> builder, string policyXml) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementOperationResource> The operation resource builder.policyXml stringA complete APIM policies XML document.Returns
IResourceBuilder<AzureApiManagementOperationResource> The resource builder.Exceptions
ArgumentExceptionThrown when policyXml is not a complete policy document.WithVirtualNetworkInjection(IResourceBuilder<AzureApiManagementResource>, IResourceBuilder<AzureSubnetResource>) Section titled WithVirtualNetworkInjection(IResourceBuilder<AzureApiManagementResource>, IResourceBuilder<AzureSubnetResource>)extensionIResourceBuilder<AzureApiManagementResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementResource> WithVirtualNetworkInjection( this IResourceBuilder<AzureApiManagementResource> builder, IResourceBuilder<AzureSubnetResource> subnet) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> The Azure API Management resource builder.subnetIResourceBuilder<AzureSubnetResource> A dedicated subnet for API Management virtual network injection.Returns
IResourceBuilder<AzureApiManagementResource> The resource builder.Exceptions
InvalidOperationException Thrown when the selected SKU is not Premium v2, the subnet has a conflicting delegation, or the subnet is already used by another API Management service, or its NSG cannot accommodate the required Key Vault allow rule ahead of outbound deny rules. Remarks
Microsoft.Web/hostingEnvironments . Premium v2 injection can only be selected when the service is created and cannot later be changed to virtual network integration. See Premium v2 virtual network injection. WithVirtualNetworkIntegration(IResourceBuilder<AzureApiManagementResource>, IResourceBuilder<AzureSubnetResource>) Section titled WithVirtualNetworkIntegration(IResourceBuilder<AzureApiManagementResource>, IResourceBuilder<AzureSubnetResource>)extensionIResourceBuilder<AzureApiManagementResource> public static class AzureApiManagementExtensions{ public static IResourceBuilder<AzureApiManagementResource> WithVirtualNetworkIntegration( this IResourceBuilder<AzureApiManagementResource> builder, IResourceBuilder<AzureSubnetResource> subnet) { // ... }}Parameters
builderIResourceBuilder<AzureApiManagementResource> The Azure API Management resource builder.subnetIResourceBuilder<AzureSubnetResource> A dedicated subnet for API Management virtual network integration.Returns
IResourceBuilder<AzureApiManagementResource> The resource builder.Exceptions
InvalidOperationException Thrown when the selected SKU does not support v2 virtual network integration, the subnet has a conflicting delegation, the subnet is already used by another API Management service, or its NSG cannot accommodate the required Key Vault allow rule ahead of outbound deny rules. Remarks
Microsoft.Web/serverFarms . The APIM gateway remains publicly accessible, while backend traffic can reach resources in the virtual network. See APIM outbound virtual network integration.