Azure Mgmt Apimanagement Dotnet

by microsoft354361d83247MITListed Oct 8, 2026Updated Oct 8, 2026

Azure Resource Manager SDK for API Management in .NET. Use for MANAGEMENT PLANE operations: creating/managing APIM services, APIs, products, subscriptions, policies, users, groups, gateways, and backends via Azure Resource Manager. Triggers: "API Management", "APIM service", "create APIM", "manage APIs", "ApiManagementServiceResource", "API policies", "APIM products", "APIM subscriptions".

FeaturedInstructions onlyDevOps & Cloud
AI-generated overview

Guides .NET management-plane provisioning of Azure API Management services, APIs, products, subscriptions and policies via Azure Resource Manager.

What it does
This skill provides .NET code patterns for managing Azure API Management through the Azure Resource Manager SDK (Azure.ResourceManager.ApiManagement). It covers authentication with DefaultAzureCredential, the ARM resource hierarchy, and creating or updating APIM services, APIs, products, subscriptions, policies, users, groups, gateways and backends. It also documents SKU types, backup and restore, error handling with RequestFailedException, and best practices such as WaitUntil usage. Reference files cover service management, APIs and operations, and products and subscriptions.
When to use it
Use it when writing .NET code that provisions or manages Azure API Management resources at the management plane, such as creating an APIM service, publishing an API, or attaching a policy. It is not intended for direct data-plane calls to APIM gateway endpoints.
Requirements
Requires the .NET SDK with the Azure.ResourceManager.ApiManagement and Azure.Identity NuGet packages, an Azure subscription, and credentials (environment variables such as AZURE_SUBSCRIPTION_ID, plus tenant/client/secret or managed identity). Network access to Azure Resource Manager is needed. No scripts are shipped; it is instructions and reference documents only.

Azure.ResourceManager.ApiManagement (.NET)

Management plane SDK for provisioning and managing Azure API Management resources via Azure Resource Manager.

⚠️ Management vs Data Plane

  • This SDK (Azure.ResourceManager.ApiManagement): Create services, APIs, products, subscriptions, policies, users, groups
  • Data Plane: Direct API calls to your APIM gateway endpoints

Installation

bash
dotnet add package Azure.ResourceManager.ApiManagementdotnet add package Azure.Identity

Current Version: v1.3.0

Environment Variables

bash
AZURE_SUBSCRIPTION_ID=<your-subscription-id> # Required: Azure subscription IDAZURE_TOKEN_CREDENTIALS=prod  # Required only if DefaultAzureCredential is used in productionAZURE_TENANT_ID=<tenant-id> # For service principal auth (optional)AZURE_CLIENT_ID=<client-id> # For service principal auth (optional)AZURE_CLIENT_SECRET=<client-secret> # For service principal auth (optional)

Authentication

csharp
using Azure.Identity;using Azure.ResourceManager;using Azure.ResourceManager.ApiManagement;
// Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=<specific_credential>var credential = new DefaultAzureCredential(    DefaultAzureCredential.DefaultEnvironmentVariableName);// Or use a specific credential directly in production:// See https://learn.microsoft.com/dotnet/api/overview/azure/identity-readme?view=azure-dotnet#credential-classes// var credential = new ManagedIdentityCredential();var armClient = new ArmClient(credential);
// Get subscriptionvar subscriptionId = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID");var subscription = armClient.GetSubscriptionResource(    new ResourceIdentifier($"/subscriptions/{subscriptionId}"));

Resource Hierarchy

ArmClient└── SubscriptionResource    └── ResourceGroupResource        └── ApiManagementServiceResource            ├── ApiResource            │   ├── ApiOperationResource            │   │   └── ApiOperationPolicyResource            │   ├── ApiPolicyResource            │   ├── ApiSchemaResource            │   └── ApiDiagnosticResource            ├── ApiManagementProductResource            │   ├── ProductApiResource            │   ├── ProductGroupResource            │   └── ProductPolicyResource            ├── ApiManagementSubscriptionResource            ├── ApiManagementPolicyResource            ├── ApiManagementUserResource            ├── ApiManagementGroupResource            ├── ApiManagementBackendResource            ├── ApiManagementGatewayResource            ├── ApiManagementCertificateResource            ├── ApiManagementNamedValueResource            └── ApiManagementLoggerResource

Core Workflow

1. Create API Management Service

csharp
using Azure.ResourceManager.ApiManagement;using Azure.ResourceManager.ApiManagement.Models;
// Get resource groupvar resourceGroup = await subscription    .GetResourceGroupAsync("my-resource-group");
// Define servicevar serviceData = new ApiManagementServiceData(    location: AzureLocation.EastUS,    sku: new ApiManagementServiceSkuProperties(        ApiManagementServiceSkuType.Developer,         capacity: 1),    publisherEmail: "[email protected]",    publisherName: "Contoso");
// Create service (long-running operation - can take 30+ minutes)var serviceCollection = resourceGroup.Value.GetApiManagementServices();var operation = await serviceCollection.CreateOrUpdateAsync(    WaitUntil.Completed,    "my-apim-service",    serviceData);
ApiManagementServiceResource service = operation.Value;

2. Create an API

csharp
var apiData = new ApiCreateOrUpdateContent{    DisplayName = "My API",    Path = "myapi",    Protocols = { ApiOperationInvokableProtocol.Https },    ServiceUri = new Uri("https://backend.contoso.com/api")};
var apiCollection = service.GetApis();var apiOperation = await apiCollection.CreateOrUpdateAsync(    WaitUntil.Completed,    "my-api",    apiData);
ApiResource api = apiOperation.Value;

3. Create a Product

csharp
var productData = new ApiManagementProductData{    DisplayName = "Starter",    Description = "Starter tier with limited access",    IsSubscriptionRequired = true,    IsApprovalRequired = false,    SubscriptionsLimit = 1,    State = ApiManagementProductState.Published};
var productCollection = service.GetApiManagementProducts();var productOperation = await productCollection.CreateOrUpdateAsync(    WaitUntil.Completed,    "starter",    productData);
ApiManagementProductResource product = productOperation.Value;
// Add API to productawait product.GetProductApis().CreateOrUpdateAsync(    WaitUntil.Completed,    "my-api");

4. Create a Subscription

csharp
var subscriptionData = new ApiManagementSubscriptionCreateOrUpdateContent{    DisplayName = "My Subscription",    Scope = $"/products/{product.Data.Name}",    State = ApiManagementSubscriptionState.Active};
var subscriptionCollection = service.GetApiManagementSubscriptions();var subOperation = await subscriptionCollection.CreateOrUpdateAsync(    WaitUntil.Completed,    "my-subscription",    subscriptionData);
ApiManagementSubscriptionResource subscription = subOperation.Value;
// Get subscription keysvar keys = await subscription.GetSecretsAsync();Console.WriteLine($"Primary Key: {keys.Value.PrimaryKey}");

5. Set API Policy

csharp
var policyXml = @"<policies>    <inbound>        <rate-limit calls=""100"" renewal-period=""60"" />        <set-header name=""X-Custom-Header"" exists-action=""override"">            <value>CustomValue</value>        </set-header>        <base />    </inbound>    <backend>        <base />    </backend>    <outbound>        <base />    </outbound>    <on-error>        <base />    </on-error></policies>";
var policyData = new PolicyContractData{    Value = policyXml,    Format = PolicyContentFormat.Xml};
await api.GetApiPolicy().CreateOrUpdateAsync(    WaitUntil.Completed,    policyData);

6. Backup and Restore

csharp
// Backupvar backupParams = new ApiManagementServiceBackupRestoreContent(    storageAccount: "mystorageaccount",    containerName: "apim-backups",    backupName: "backup-2024-01-15"){    AccessType = StorageAccountAccessType.SystemAssignedManagedIdentity};
await service.BackupAsync(WaitUntil.Completed, backupParams);
// Restoreawait service.RestoreAsync(WaitUntil.Completed, backupParams);

Key Types Reference

TypePurpose
ArmClientEntry point for all ARM operations
ApiManagementServiceResourceRepresents an APIM service instance
ApiManagementServiceCollectionCollection for service CRUD
ApiResourceRepresents an API
ApiManagementProductResourceRepresents a product
ApiManagementSubscriptionResourceRepresents a subscription
ApiManagementPolicyResourceService-level policy
ApiPolicyResourceAPI-level policy
ApiManagementUserResourceRepresents a user
ApiManagementGroupResourceRepresents a group
ApiManagementBackendResourceRepresents a backend service
ApiManagementGatewayResourceRepresents a self-hosted gateway

SKU Types

SKUPurposeCapacity
DeveloperDevelopment/testing (no SLA)1
BasicEntry-level production1-2
StandardMedium workloads1-4
PremiumHigh availability, multi-region1-12 per region
ConsumptionServerless, pay-per-callN/A

Best Practices

  1. Use WaitUntil.Completed for operations that must finish before proceeding
  2. Use WaitUntil.Started for long operations like service creation (30+ min)
  3. Always use DefaultAzureCredential — never hardcode keys
  4. Handle RequestFailedException for ARM API errors
  5. Use CreateOrUpdateAsync for idempotent operations
  6. Navigate hierarchy via Get* methods (e.g., service.GetApis())
  7. Policy format — Use XML format for policies; JSON is also supported
  8. Service creation — Developer SKU is fastest for testing (~15-30 min)

Error Handling

csharp
using Azure;
try{    var operation = await serviceCollection.CreateOrUpdateAsync(        WaitUntil.Completed, serviceName, serviceData);}catch (RequestFailedException ex) when (ex.Status == 409){    Console.WriteLine("Service already exists");}catch (RequestFailedException ex) when (ex.Status == 400){    Console.WriteLine($"Bad request: {ex.Message}");}catch (RequestFailedException ex){    Console.WriteLine($"ARM Error: {ex.Status} - {ex.ErrorCode}: {ex.Message}");}

Reference Files

FileWhen to Read
references/service-management.md [blocked]Service CRUD, SKUs, networking, backup/restore
references/apis-operations.md [blocked]APIs, operations, schemas, versioning
references/products-subscriptions.md [blocked]Products, subscriptions, access control
references/policies.md [blocked]Policy XML patterns, scopes, common policies

Related Resources

ResourcePurpose
API Management DocumentationOfficial Azure docs
Policy ReferenceComplete policy reference
SDK Reference.NET API reference

Source and attribution

Source:microsoft/skillsin.github/plugins/azure-sdk-dotnet/skills/azure-mgmt-apimanagement-dotnetat commit354361d

License: MIT

Content belongs to its original authors. SourceWeft indexes it from a public repository.

Report or request removal

More from microsoft/skills

Azure Mgmt Fabric Dotnet

microsoft

Featured

Guides .NET management-plane provisioning and lifecycle of Microsoft Fabric capacities via Azure Resource Manager.

DevOps & CloudOct 8, 2026

Azure Communication Common Java

microsoft

Featured

Reference for Azure Communication Services common Java utilities: token credentials, refresh, and user identifiers.

Software DevelopmentOct 8, 2026

Azure Mgmt Botservice Dotnet

microsoft

Featured

Azure Resource Manager SDK for Bot Service in .NET. Management plane operations for creating and managing Azure Bot resources, channels (Teams, DirectLine, Slack), and connection settings. Triggers: "Bot Service", "BotResource", "Azure Bot", "DirectLine channel", "Teams channel", "bot management .NET", "create bot".

Awaiting classificationOct 8, 2026

Azure Communication Chat Java

microsoft

Featured

Guides Java developers in building real-time chat features with the Azure Communication Services Chat SDK.

Software DevelopmentOct 8, 2026

Azure Mgmt Arizeaiobservabilityeval Dotnet

microsoft

Featured

Azure Resource Manager SDK for Arize AI Observability and Evaluation (.NET). Use when managing Arize AI organizations on Azure via Azure Marketplace, creating/updating/deleting Arize resources, or integrating Arize ML observability into .NET applications. Triggers: "Arize AI", "ML observability", "ArizeAIObservabilityEval", "Arize organization".

Awaiting classificationOct 8, 2026

Azure Mgmt Applicationinsights Dotnet

microsoft

Featured

Azure Application Insights SDK for .NET. Application performance monitoring and observability resource management. Use for creating Application Insights components, web tests, workbooks, analytics items, and API keys. Triggers: "Application Insights", "ApplicationInsights", "App Insights", "APM", "application monitoring", "web tests", "availability tests", "workbooks".

Awaiting classificationOct 8, 2026