AzureApiManagementExtensions Methods

ClassMethods38 members
Provides extension methods for adding Azure API Management resources to the application model.
AddApi(IResourceBuilder<AzureApiManagementResource>, string, IResourceBuilder<T>, string, string?, bool, string?)Section titled AddApi(IResourceBuilder<AzureApiManagementResource>, string, IResourceBuilder<T>, string, string?, bool, string?)extensionIResourceBuilder<AzureApiManagementApiResource>
Adds an API that routes requests to an Aspire compute resource.
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)
{
// ...
}
}
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.
displayNamestring?optionalThe API display name. The resource name is used when omitted.
subscriptionRequiredbooloptionalWhether callers must provide an API Management subscription key. The default is true.
apiNamestring?optionalThe physical API identifier in API Management. The Aspire resource name is used when omitted.
IResourceBuilder<AzureApiManagementApiResource>A builder for the API resource.
ArgumentNullExceptionThrown when builder or target is null.
ArgumentExceptionThrown when a required string is empty.
The generated API contains catch-all operations for supported HTTP methods and paths. The generated policy routes requests through an API Management backend entity whose URL is resolved from the target deployment environment.
AddApi(IResourceBuilder<AzureApiManagementResource>, string, string, string?, bool, string?)Section titled AddApi(IResourceBuilder<AzureApiManagementResource>, string, string, string?, bool, string?)extensionIResourceBuilder<AzureApiManagementApiResource>
Adds an API whose backend is configured separately.
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)
{
// ...
}
}
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.
displayNamestring?optionalThe API display name. The resource name is used when omitted.
subscriptionRequiredbooloptionalWhether callers must provide an API Management subscription key. The default is true.
apiNamestring?optionalThe physical API identifier in API Management. The Aspire resource name is used when omitted.
IResourceBuilder<AzureApiManagementApiResource>A builder for the API resource.
AddAzureApiManagement(IDistributedApplicationBuilder, string, AzureApiManagementOptions)Section titled AddAzureApiManagement(IDistributedApplicationBuilder, string, AzureApiManagementOptions)extensionIResourceBuilder<AzureApiManagementResource>
Adds an Azure API Management service.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementResource> AddAzureApiManagement(
this IDistributedApplicationBuilder builder,
string name,
AzureApiManagementOptions options)
{
// ...
}
}
builderIDistributedApplicationBuilderThe distributed application builder.
namestringThe name of the Aspire resource.
optionsAzureApiManagementOptionsThe API Management service options.
IResourceBuilder<AzureApiManagementResource>A builder for the Azure API Management resource.
ArgumentNullExceptionThrown when builder or options is null.
ArgumentExceptionThrown when required option values are empty or capacity is invalid for the selected SKU.
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>
Adds an Azure OpenAI deployment as an API Management backend.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementBackendResource> AddAzureOpenAIBackend(
this IResourceBuilder<AzureApiManagementResource> builder,
string name,
IResourceBuilder<AzureOpenAIDeploymentResource> deployment,
string? backendName = null)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementResource>
namestring
deploymentIResourceBuilder<AzureOpenAIDeploymentResource>
backendNamestring?optional
AddBackend(IResourceBuilder<AzureApiManagementResource>, string, ReferenceExpression, AzureApiManagementBackendOptions?, string?)Section titled AddBackend(IResourceBuilder<AzureApiManagementResource>, string, ReferenceExpression, AzureApiManagementBackendOptions?, string?)extensionIResourceBuilder<AzureApiManagementBackendResource>
Adds a configurable backend to the API Management service.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementBackendResource> AddBackend(
this IResourceBuilder<AzureApiManagementResource> builder,
string name,
ReferenceExpression uri,
AzureApiManagementBackendOptions? options = null,
string? backendName = null)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementResource>The API Management resource builder.
namestringThe globally unique Aspire resource name and default physical backend name.
uriReferenceExpressionThe deferred URI of the backend service.
optionsAzureApiManagementBackendOptions?optionalThe backend options.
backendNamestring?optionalThe physical backend identifier in API Management. The Aspire resource name is used when omitted.
IResourceBuilder<AzureApiManagementBackendResource>A builder for the backend resource.
AddBackendPool(IResourceBuilder<AzureApiManagementResource>, string, string?, string?)Section titled AddBackendPool(IResourceBuilder<AzureApiManagementResource>, string, string?, string?)extensionIResourceBuilder<AzureApiManagementBackendPoolResource>
Adds a reusable load-balancing pool to the API Management service.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementBackendPoolResource> AddBackendPool(
this IResourceBuilder<AzureApiManagementResource> builder,
string name,
string? displayName = null,
string? backendPoolName = null)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementResource>
namestring
displayNamestring?optional
backendPoolNamestring?optional
AddBlobStorageBackend(IResourceBuilder<AzureApiManagementResource>, string, IResourceBuilder<AzureBlobStorageResource>, string?)Section titled AddBlobStorageBackend(IResourceBuilder<AzureApiManagementResource>, string, IResourceBuilder<AzureBlobStorageResource>, string?)extensionIResourceBuilder<AzureApiManagementBackendResource>
Adds an Azure Blob Storage service as an API Management backend.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementBackendResource> AddBlobStorageBackend(
this IResourceBuilder<AzureApiManagementResource> builder,
string name,
IResourceBuilder<AzureBlobStorageResource> blobs,
string? backendName = null)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementResource>
namestring
blobsIResourceBuilder<AzureBlobStorageResource>
backendNamestring?optional
AddFoundryBackend(IResourceBuilder<AzureApiManagementResource>, string, IResourceBuilder<FoundryDeploymentResource>, string?)Section titled AddFoundryBackend(IResourceBuilder<AzureApiManagementResource>, string, IResourceBuilder<FoundryDeploymentResource>, string?)extensionIResourceBuilder<AzureApiManagementBackendResource>
Adds a Microsoft Foundry OpenAI deployment as an API Management backend.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementBackendResource> AddFoundryBackend(
this IResourceBuilder<AzureApiManagementResource> builder,
string name,
IResourceBuilder<FoundryDeploymentResource> deployment,
string? backendName = null)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementResource>
namestring
deploymentIResourceBuilder<FoundryDeploymentResource>
backendNamestring?optional
AddKeyVaultNamedValue(IResourceBuilder<AzureApiManagementResource>, string, IAzureKeyVaultSecretReference, string?, string?, string[]?)Section titled AddKeyVaultNamedValue(IResourceBuilder<AzureApiManagementResource>, string, IAzureKeyVaultSecretReference, string?, string?, string[]?)extensionIResourceBuilder<AzureApiManagementNamedValueResource>
Adds a Key Vault-backed named value to the API Management service.
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)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementResource>The Azure API Management resource builder.
namestringThe globally unique Aspire resource name and default physical named-value name.
valueIAzureKeyVaultSecretReferenceThe Key Vault secret reference.
displayNamestring?optionalThe name used to reference the value in policies. The resource name is used when omitted.
namedValueNamestring?optionalThe physical named-value identifier in API Management. The resource name is used when omitted.
tagsstring[]?optionalTags used to organize the named value.
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>
Adds a non-secret named value to the API Management service.
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)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementResource>The Azure API Management resource builder.
namestringThe globally unique Aspire resource name and default physical named-value name.
valuestringThe named value.
displayNamestring?optionalThe name used to reference the value in policies. The resource name is used when omitted.
namedValueNamestring?optionalThe physical named-value identifier in API Management. The resource name is used when omitted.
tagsstring[]?optionalTags used to organize the named value.
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>
Adds an OpenAI-compatible API backed by an API Management load-balancing pool.
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)
{
// ...
}
}
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.
displayNamestring?optionalThe API display name. The resource name is used when omitted.
subscriptionRequiredbooloptionalWhether callers must provide an API Management subscription key. The default is true.
apiNamestring?optionalThe physical API identifier in API Management. The Aspire resource name is used when omitted.
IResourceBuilder<AzureApiManagementApiResource>A builder for the API resource.
Create backends with 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>
Adds an explicitly modeled operation to an API.
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)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementApiResource>The API resource builder.
namestringThe globally unique Aspire resource name and default physical operation name.
methodstringThe HTTP method.
urlTemplatestringThe URL template relative to the API path.
displayNamestring?optionalThe operation display name. The resource name is used when omitted.
operationNamestring?optionalThe physical operation identifier in API Management. The Aspire resource name is used when omitted.
IResourceBuilder<AzureApiManagementOperationResource>A builder for the operation resource.
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>
Adds a reusable policy fragment to the API Management service.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementPolicyFragmentResource> AddPolicyFragment(
this IResourceBuilder<AzureApiManagementResource> builder,
string name,
string policyXml,
string? description = null,
string? fragmentName = null)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementResource>The Azure API Management resource builder.
namestringThe globally unique Aspire resource name and default physical policy-fragment name.
policyXmlstringOne or more well-formed APIM policy elements without a fragment envelope.
descriptionstring?optionalAn optional description.
fragmentNamestring?optionalThe physical policy-fragment identifier in API Management. The resource name is used when omitted.
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>
Adds a product to the API Management service.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementProductResource> AddProduct(
this IResourceBuilder<AzureApiManagementResource> builder,
string name,
string displayName,
AzureApiManagementProductOptions? options = null,
string? productName = null)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementResource>The Azure API Management resource builder.
namestringThe globally unique Aspire resource name and default physical product name.
displayNamestringThe product display name.
optionsAzureApiManagementProductOptions?optionalThe product options.
productNamestring?optionalThe physical product identifier in API Management. The resource name is used when omitted.
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>
Adds a secret parameter as a named value in the API Management service.
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)
{
// ...
}
}
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.
displayNamestring?optionalThe name used to reference the value in policies. The resource name is used when omitted.
namedValueNamestring?optionalThe physical named-value identifier in API Management. The resource name is used when omitted.
tagsstring[]?optionalTags used to organize the named value.
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>
Adds a subscription scoped to an API Management product.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementSubscriptionResource> AddSubscription(
this IResourceBuilder<AzureApiManagementProductResource> builder,
string name,
string displayName,
AzureApiManagementSubscriptionOptions? options = null,
string? subscriptionName = null)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementProductResource>The API Management product resource builder.
namestringThe globally unique Aspire resource name and default physical subscription name.
displayNamestringThe subscription display name.
optionsAzureApiManagementSubscriptionOptions?optionalThe subscription options.
subscriptionNamestring?optionalThe physical subscription identifier in API Management. The resource name is used when omitted.
IResourceBuilder<AzureApiManagementSubscriptionResource>A builder for the subscription resource.
API Management generates the primary and secondary subscription keys during deployment.
WithApi(IResourceBuilder<AzureApiManagementProductResource>, IResourceBuilder<AzureApiManagementApiResource>)Section titled WithApi(IResourceBuilder<AzureApiManagementProductResource>, IResourceBuilder<AzureApiManagementApiResource>)extensionIResourceBuilder<AzureApiManagementProductResource>
Adds an API to an API Management product.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementProductResource> WithApi(
this IResourceBuilder<AzureApiManagementProductResource> builder,
IResourceBuilder<AzureApiManagementApiResource> api)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementProductResource>The API Management product resource builder.
apiIResourceBuilder<AzureApiManagementApiResource>The API to add to the product.
IResourceBuilder<AzureApiManagementProductResource>The product resource builder.
WithApplicationInsights(IResourceBuilder<AzureApiManagementResource>, IResourceBuilder<AzureApplicationInsightsResource>, AzureApiManagementDiagnosticOptions?)Section titled WithApplicationInsights(IResourceBuilder<AzureApiManagementResource>, IResourceBuilder<AzureApplicationInsightsResource>, AzureApiManagementDiagnosticOptions?)extensionIResourceBuilder<AzureApiManagementResource>
Sends service-level API Management diagnostics to Application Insights.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementResource> WithApplicationInsights(
this IResourceBuilder<AzureApiManagementResource> builder,
IResourceBuilder<AzureApplicationInsightsResource> applicationInsights,
AzureApiManagementDiagnosticOptions? options = null)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementResource>The Azure API Management resource builder.
applicationInsightsIResourceBuilder<AzureApplicationInsightsResource>The Application Insights resource.
optionsAzureApiManagementDiagnosticOptions?optionalThe diagnostic options.
IResourceBuilder<AzureApiManagementResource>The resource builder.
WithApplicationInsights(IResourceBuilder<AzureApiManagementApiResource>, IResourceBuilder<AzureApplicationInsightsResource>, AzureApiManagementDiagnosticOptions?)Section titled WithApplicationInsights(IResourceBuilder<AzureApiManagementApiResource>, IResourceBuilder<AzureApplicationInsightsResource>, AzureApiManagementDiagnosticOptions?)extensionIResourceBuilder<AzureApiManagementApiResource>
Sends API-level API Management diagnostics to Application Insights.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementApiResource> WithApplicationInsights(
this IResourceBuilder<AzureApiManagementApiResource> builder,
IResourceBuilder<AzureApplicationInsightsResource> applicationInsights,
AzureApiManagementDiagnosticOptions? options = null)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementApiResource>The API Management API resource builder.
applicationInsightsIResourceBuilder<AzureApplicationInsightsResource>The Application Insights resource.
optionsAzureApiManagementDiagnosticOptions?optionalThe diagnostic options.
IResourceBuilder<AzureApiManagementApiResource>The resource builder.
WithAzureUserAssignedIdentity(IResourceBuilder<AzureApiManagementResource>, IResourceBuilder<AzureUserAssignedIdentityResource>)Section titled WithAzureUserAssignedIdentity(IResourceBuilder<AzureApiManagementResource>, IResourceBuilder<AzureUserAssignedIdentityResource>)extensionIResourceBuilder<AzureApiManagementResource>
Configures the user-assigned managed identity used by API Management.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementResource> WithAzureUserAssignedIdentity(
this IResourceBuilder<AzureApiManagementResource> builder,
IResourceBuilder<AzureUserAssignedIdentityResource> identityResourceBuilder)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementResource>The Azure API Management resource builder.
identityResourceBuilderIResourceBuilder<AzureUserAssignedIdentityResource>The user-assigned managed identity.
IResourceBuilder<AzureApiManagementResource>The Azure API Management resource builder.
ArgumentNullExceptionThrown when builder or identityResourceBuilder is null.
New services attach the supplied identity automatically instead of creating a default identity. For an existing service, the supplied identity must be configured as an existing resource and already attached to the service outside Aspire. Aspire does not change or verify the existing service's identity attachments. Backend and Key Vault permissions use the supplied identity.
WithBackend(IResourceBuilder<AzureApiManagementBackendPoolResource>, IResourceBuilder<AzureApiManagementBackendResource>, int, int)Section titled WithBackend(IResourceBuilder<AzureApiManagementBackendPoolResource>, IResourceBuilder<AzureApiManagementBackendResource>, int, int)extensionIResourceBuilder<AzureApiManagementBackendPoolResource>
Adds a backend to a load-balancing pool.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementBackendPoolResource> WithBackend(
this IResourceBuilder<AzureApiManagementBackendPoolResource> builder,
IResourceBuilder<AzureApiManagementBackendResource> backend,
int priority = 1,
int weight = 1)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementBackendPoolResource>
backendIResourceBuilder<AzureApiManagementBackendResource>
priorityintoptional
weightintoptional
WithBackend(IResourceBuilder<AzureApiManagementApiResource>, IResourceBuilder<AzureApiManagementBackendResource>)Section titled WithBackend(IResourceBuilder<AzureApiManagementApiResource>, IResourceBuilder<AzureApiManagementBackendResource>)extensionIResourceBuilder<AzureApiManagementApiResource>
Configures an API to route requests to a backend.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementApiResource> WithBackend(
this IResourceBuilder<AzureApiManagementApiResource> builder,
IResourceBuilder<AzureApiManagementBackendResource> backend)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementApiResource>
backendIResourceBuilder<AzureApiManagementBackendResource>
WithBackend(IResourceBuilder<AzureApiManagementApiResource>, IResourceBuilder<AzureApiManagementBackendPoolResource>)Section titled WithBackend(IResourceBuilder<AzureApiManagementApiResource>, IResourceBuilder<AzureApiManagementBackendPoolResource>)extensionIResourceBuilder<AzureApiManagementApiResource>
Configures an API to route requests to a backend pool.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementApiResource> WithBackend(
this IResourceBuilder<AzureApiManagementApiResource> builder,
IResourceBuilder<AzureApiManagementBackendPoolResource> backend)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementApiResource>
backendIResourceBuilder<AzureApiManagementBackendPoolResource>
WithClassicVirtualNetwork(IResourceBuilder<AzureApiManagementResource>, IResourceBuilder<AzureSubnetResource>, AzureApiManagementVirtualNetworkMode)Section titled WithClassicVirtualNetwork(IResourceBuilder<AzureApiManagementResource>, IResourceBuilder<AzureSubnetResource>, AzureApiManagementVirtualNetworkMode)extensionIResourceBuilder<AzureApiManagementResource>
Injects a classic Developer or Premium API Management service into a virtual network subnet.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementResource> WithClassicVirtualNetwork(
this IResourceBuilder<AzureApiManagementResource> builder,
IResourceBuilder<AzureSubnetResource> subnet,
AzureApiManagementVirtualNetworkMode mode)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementResource>The Azure API Management resource builder.
subnetIResourceBuilder<AzureSubnetResource>The subnet resource. Classic APIM injection requires an undelegated subnet with an NSG.
modeAzureApiManagementVirtualNetworkModeWhether the APIM endpoints are externally or internally accessible.
IResourceBuilder<AzureApiManagementResource>The resource builder.
InvalidOperationExceptionThrown when the selected SKU does not support classic VNet injection or the subnet is delegated.
This API models classic VNet injection only. Standard v2 outbound integration and Premium v2 injection have different subnet delegations and lifecycle constraints. Use 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>
Configures a custom hostname using a certificate stored in Azure Key Vault.
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)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementResource>The Azure API Management resource builder.
hostnamestringThe fully qualified custom hostname.
certificateIAzureKeyVaultSecretReferenceThe Key Vault secret containing a PFX certificate.
typeAzureApiManagementHostnameTypeoptionalThe API Management endpoint to configure.
defaultSslBindingbooloptionalWhether this certificate is the default SNI fallback. This is valid only for gateway hostnames.
negotiateClientCertificatebooloptionalWhether the endpoint negotiates client certificates.
IResourceBuilder<AzureApiManagementResource>The resource builder.
WithInboundPolicy(IResourceBuilder<AzureApiManagementResource>, string)Section titled WithInboundPolicy(IResourceBuilder<AzureApiManagementResource>, string)extensionIResourceBuilder<AzureApiManagementResource>
Appends an XML policy statement to the service-level inbound policy section.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementResource> WithInboundPolicy(
this IResourceBuilder<AzureApiManagementResource> builder,
string policyXml)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementResource>The Azure API Management resource builder.
policyXmlstringOne or more well-formed APIM policy elements without a policies envelope.
IResourceBuilder<AzureApiManagementResource>The resource builder.
ArgumentExceptionThrown when policyXml is empty or is not a valid XML fragment.
WithInboundPolicy(IResourceBuilder<AzureApiManagementApiResource>, string)Section titled WithInboundPolicy(IResourceBuilder<AzureApiManagementApiResource>, string)extensionIResourceBuilder<AzureApiManagementApiResource>
Appends an XML policy statement to the API-level inbound policy section.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementApiResource> WithInboundPolicy(
this IResourceBuilder<AzureApiManagementApiResource> builder,
string policyXml)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementApiResource>The API resource builder.
policyXmlstringOne or more well-formed APIM policy elements without a policies envelope.
IResourceBuilder<AzureApiManagementApiResource>The resource builder.
ArgumentExceptionThrown when policyXml is empty or is not a valid XML fragment.
WithInboundPolicy(IResourceBuilder<AzureApiManagementOperationResource>, string)Section titled WithInboundPolicy(IResourceBuilder<AzureApiManagementOperationResource>, string)extensionIResourceBuilder<AzureApiManagementOperationResource>
Appends an XML policy statement to the operation-level inbound policy section.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementOperationResource> WithInboundPolicy(
this IResourceBuilder<AzureApiManagementOperationResource> builder,
string policyXml)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementOperationResource>The operation resource builder.
policyXmlstringOne or more well-formed APIM policy elements without a policies envelope.
IResourceBuilder<AzureApiManagementOperationResource>The resource builder.
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>
Includes a policy fragment in the service-level inbound policy.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementResource> WithInboundPolicyFragment(
this IResourceBuilder<AzureApiManagementResource> builder,
IResourceBuilder<AzureApiManagementPolicyFragmentResource> fragment)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementResource>The Azure API Management resource builder.
fragmentIResourceBuilder<AzureApiManagementPolicyFragmentResource>The policy fragment to include.
IResourceBuilder<AzureApiManagementResource>The resource builder.
WithInboundPolicyFragment(IResourceBuilder<AzureApiManagementApiResource>, IResourceBuilder<AzureApiManagementPolicyFragmentResource>)Section titled WithInboundPolicyFragment(IResourceBuilder<AzureApiManagementApiResource>, IResourceBuilder<AzureApiManagementPolicyFragmentResource>)extensionIResourceBuilder<AzureApiManagementApiResource>
Includes a policy fragment in the API-level inbound policy.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementApiResource> WithInboundPolicyFragment(
this IResourceBuilder<AzureApiManagementApiResource> builder,
IResourceBuilder<AzureApiManagementPolicyFragmentResource> fragment)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementApiResource>The API Management API resource builder.
fragmentIResourceBuilder<AzureApiManagementPolicyFragmentResource>The policy fragment to include.
IResourceBuilder<AzureApiManagementApiResource>The resource builder.
WithInboundPolicyFragment(IResourceBuilder<AzureApiManagementOperationResource>, IResourceBuilder<AzureApiManagementPolicyFragmentResource>)Section titled WithInboundPolicyFragment(IResourceBuilder<AzureApiManagementOperationResource>, IResourceBuilder<AzureApiManagementPolicyFragmentResource>)extensionIResourceBuilder<AzureApiManagementOperationResource>
Includes a policy fragment in the operation-level inbound policy.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementOperationResource> WithInboundPolicyFragment(
this IResourceBuilder<AzureApiManagementOperationResource> builder,
IResourceBuilder<AzureApiManagementPolicyFragmentResource> fragment)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementOperationResource>The API Management operation resource builder.
fragmentIResourceBuilder<AzureApiManagementPolicyFragmentResource>The policy fragment to include.
IResourceBuilder<AzureApiManagementOperationResource>The resource builder.
WithOpenApiDocument(IResourceBuilder<AzureApiManagementApiResource>, string, AzureApiManagementOpenApiFormat?)Section titled WithOpenApiDocument(IResourceBuilder<AzureApiManagementApiResource>, string, AzureApiManagementOpenApiFormat?)extensionIResourceBuilder<AzureApiManagementApiResource>
Imports an OpenAPI document from a file into an API.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementApiResource> WithOpenApiDocument(
this IResourceBuilder<AzureApiManagementApiResource> builder,
string documentPath,
AzureApiManagementOpenApiFormat? format = null)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementApiResource>The API Management API resource builder.
documentPathstringThe document path, relative to the AppHost directory when not absolute.
formatAzureApiManagementOpenApiFormat?optionalThe document format. The file extension is used when omitted.
IResourceBuilder<AzureApiManagementApiResource>The API Management API resource builder.
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.
The document is read when generating infrastructure for publish or deploy, never during run mode. It must exist and contain non-whitespace content by the time infrastructure is generated. 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.
WithOpenApiEndpoint(IResourceBuilder<AzureApiManagementApiResource>, string, string?, AzureApiManagementOpenApiFormat?)Section titled WithOpenApiEndpoint(IResourceBuilder<AzureApiManagementApiResource>, string, string?, AzureApiManagementOpenApiFormat?)extensionIResourceBuilder<AzureApiManagementApiResource>
Imports an OpenAPI document exposed by the API's target compute resource.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementApiResource> WithOpenApiEndpoint(
this IResourceBuilder<AzureApiManagementApiResource> builder,
string documentPath = "/openapi/v1.json",
string? endpointName = null,
AzureApiManagementOpenApiFormat? format = null)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementApiResource>The API Management API resource builder.
documentPathstringoptionalThe absolute path of the OpenAPI endpoint, such as /openapi/v1.json.
endpointNamestring?optionalThe target endpoint name. An external HTTP or HTTPS endpoint is selected when omitted.
formatAzureApiManagementOpenApiFormat?optionalThe document format. The endpoint path extension is used when omitted.
IResourceBuilder<AzureApiManagementApiResource>The API Management API resource builder.
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.
Azure API Management retrieves linked documents through its control plane, so the selected endpoint must be externally reachable during deployment. Use 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>
Replaces the complete service-level policy document.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementResource> WithPolicy(
this IResourceBuilder<AzureApiManagementResource> builder,
string policyXml)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementResource>The Azure API Management resource builder.
policyXmlstringA complete APIM policies XML document.
IResourceBuilder<AzureApiManagementResource>The resource builder.
ArgumentExceptionThrown when policyXml is not a complete policy document.
APIM policy updates replace the complete policy document at a scope. To prevent silently dropping policy fragments, this method cannot be combined with AzureApiManagementExtensions.WithInboundPolicy at the same scope.
WithPolicy(IResourceBuilder<AzureApiManagementApiResource>, string)Section titled WithPolicy(IResourceBuilder<AzureApiManagementApiResource>, string)extensionIResourceBuilder<AzureApiManagementApiResource>
Replaces the complete API-level policy document.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementApiResource> WithPolicy(
this IResourceBuilder<AzureApiManagementApiResource> builder,
string policyXml)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementApiResource>The API resource builder.
policyXmlstringA complete APIM policies XML document.
IResourceBuilder<AzureApiManagementApiResource>The resource builder.
ArgumentExceptionThrown when policyXml is not a complete policy document.
Replacing the API policy also replaces the generated backend-routing policy. The supplied document must configure backend routing when the API should continue forwarding requests.
WithPolicy(IResourceBuilder<AzureApiManagementOperationResource>, string)Section titled WithPolicy(IResourceBuilder<AzureApiManagementOperationResource>, string)extensionIResourceBuilder<AzureApiManagementOperationResource>
Replaces the complete operation-level policy document.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementOperationResource> WithPolicy(
this IResourceBuilder<AzureApiManagementOperationResource> builder,
string policyXml)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementOperationResource>The operation resource builder.
policyXmlstringA complete APIM policies XML document.
IResourceBuilder<AzureApiManagementOperationResource>The resource builder.
ArgumentExceptionThrown when policyXml is not a complete policy document.
WithVirtualNetworkInjection(IResourceBuilder<AzureApiManagementResource>, IResourceBuilder<AzureSubnetResource>)Section titled WithVirtualNetworkInjection(IResourceBuilder<AzureApiManagementResource>, IResourceBuilder<AzureSubnetResource>)extensionIResourceBuilder<AzureApiManagementResource>
Injects a Premium v2 API Management service into a virtual network for private inbound and outbound access.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementResource> WithVirtualNetworkInjection(
this IResourceBuilder<AzureApiManagementResource> builder,
IResourceBuilder<AzureSubnetResource> subnet)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementResource>The Azure API Management resource builder.
subnetIResourceBuilder<AzureSubnetResource>A dedicated subnet for API Management virtual network injection.
IResourceBuilder<AzureApiManagementResource>The resource builder.
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.
The subnet is delegated to 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>
Integrates a Standard v2 or Premium v2 API Management service with a virtual network for outbound access.
public static class AzureApiManagementExtensions
{
public static IResourceBuilder<AzureApiManagementResource> WithVirtualNetworkIntegration(
this IResourceBuilder<AzureApiManagementResource> builder,
IResourceBuilder<AzureSubnetResource> subnet)
{
// ...
}
}
builderIResourceBuilder<AzureApiManagementResource>The Azure API Management resource builder.
subnetIResourceBuilder<AzureSubnetResource>A dedicated subnet for API Management virtual network integration.
IResourceBuilder<AzureApiManagementResource>The resource builder.
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.
The subnet is delegated to 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.