Skip to main content Skills Marketplace Discover and explore AI skills built by the community.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Copy promptShow prompt details A direct command skips the review prompt. Inspect the source before running it.
npx skills add https://github.com/foolhardy45/portfolio --skill azure-mgmt-apimanagement-dotnetThe command stays on one line. Scroll horizontally to inspect it before copying.
Prefer a local copy? Download the files currently available to SkillsMP.
Download Zip Downloading... More from this repository
Related occupations SOC
Based on SOC occupation classification
name azure-mgmt-apimanagement-dotnet description Azure Resource Manager SDK for API Management in .NET. risk unknown source community date_added 2026-02-27
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
dotnet add package Azure.ResourceManager.ApiManagement
dotnet add package Azure.Identity
Current Version : v1.3.0
Environment Variables
AZURE_SUBSCRIPTION_ID=<your-subscription-id>
AZURE_TENANT_ID=<tenant-id>
AZURE_CLIENT_ID=<client-id>
AZURE_CLIENT_SECRET=<client-secret>
Authentication
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.ApiManagement;
var credential = new DefaultAzureCredential();
var armClient = new ArmClient(credential);
var 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 using Azure.ResourceManager.ApiManagement;
using Azure.ResourceManager.ApiManagement.Models;
var resourceGroup = await subscription
.GetResourceGroupAsync("my-resource-group" );
var serviceData = new ApiManagementServiceData(
location: AzureLocation.EastUS,
sku: new ApiManagementServiceSkuProperties(
ApiManagementServiceSkuType.Developer,
capacity: 1 ),
publisherEmail: "admin@contoso.com" ,
publisherName: "Contoso" );
var serviceCollection = resourceGroup.Value.GetApiManagementServices();
var operation = await serviceCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
"my-apim-service" ,
serviceData);
ApiManagementServiceResource service = operation.Value;
2. Create an API 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 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;
await product.GetProductApis().CreateOrUpdateAsync(
WaitUntil.Completed,
"my-api" );
4. Create a Subscription 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;
var keys = await subscription.GetSecretsAsync();
Console.WriteLine($"Primary Key: {keys.Value.PrimaryKey} " );
5. Set API Policy 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
var backupParams = new ApiManagementServiceBackupRestoreContent(
storageAccount: "mystorageaccount" ,
containerName: "apim-backups" ,
backupName: "backup-2024-01-15" )
{
AccessType = StorageAccountAccessType.SystemAssignedManagedIdentity
};
await service.BackupAsync(WaitUntil.Completed, backupParams);
await service.RestoreAsync(WaitUntil.Completed, backupParams);
Key Types Reference Type Purpose 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 SKU Purpose Capacity DeveloperDevelopment/testing (no SLA) 1 BasicEntry-level production 1-2 StandardMedium workloads 1-4 PremiumHigh availability, multi-region 1-12 per region ConsumptionServerless, pay-per-call N/A
Best Practices
Use WaitUntil.Completed for operations that must finish before proceeding
Use WaitUntil.Started for long operations like service creation (30+ min)
Always use DefaultAzureCredential — never hardcode keys
Handle RequestFailedException for ARM API errors
Use CreateOrUpdateAsync for idempotent operations
Navigate hierarchy via Get* methods (e.g., service.GetApis())
Policy format — Use XML format for policies; JSON is also supported
Service creation — Developer SKU is fastest for testing (~15-30 min)
Error Handling 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 File When to Read references/service-management.md Service CRUD, SKUs, networking, backup/restore references/apis-operations.md APIs, operations, schemas, versioning references/products-subscriptions.md Products, subscriptions, access control references/policies.md Policy XML patterns, scopes, common policies
Related Resources
When to Use This skill is applicable to execute the workflow or actions described in the overview.