All skills
microsoft avatar

/azure-mgmt-apimanagement-dotnet

@073741f
by microsoftmicrosoft/skills3.1k stars
351

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".

Use this Skill: https://skilld.dev/gh/microsoft/skills/azure-mgmt-apimanagement-dotnet

This session only. Nothing lands on disk.

referencesproducts-subscriptions.md

≈1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Products and Subscriptions

Patterns for managing products, subscriptions, and access control.

Create Product

var productData = new ApiManagementProductData
{
    DisplayName = "Premium",
    Description = "Premium tier with full access",
    IsSubscriptionRequired = true,
    IsApprovalRequired = true,  // Requires admin approval
    SubscriptionsLimit = 5,
    State = ApiManagementProductState.Published,
    Terms = "Terms and conditions for premium tier..."
};

var product = await service.GetApiManagementProducts()
    .CreateOrUpdateAsync(WaitUntil.Completed, "premium", productData);

List Products

await foreach (var product in service.GetApiManagementProducts())
{
    Console.WriteLine($"{product.Data.DisplayName}: {product.Data.State}");
}

Add API to Product

// Get product
var product = await service.GetApiManagementProductAsync("premium");

// Add API
await product.Value.GetProductApis()
    .CreateOrUpdateAsync(WaitUntil.Completed, "my-api");

Remove API from Product

var productApi = await product.Value.GetProductApiAsync("my-api");
await productApi.Value.DeleteAsync(WaitUntil.Completed);

List APIs in Product

await foreach (var api in product.Value.GetProductApis())
{
    Console.WriteLine($"  - {api.Data.DisplayName}");
}

Create Subscription

// Subscription to product
var subscriptionData = new ApiManagementSubscriptionCreateOrUpdateContent
{
    DisplayName = "Customer A Subscription",
    Scope = $"/products/premium",
    State = ApiManagementSubscriptionState.Active,
    AllowTracing = true
};

var subscription = await service.GetApiManagementSubscriptions()
    .CreateOrUpdateAsync(WaitUntil.Completed, "customer-a-sub", subscriptionData);

// Subscription to specific API
var apiSubscriptionData = new ApiManagementSubscriptionCreateOrUpdateContent
{
    DisplayName = "API-specific Subscription",
    Scope = $"/apis/my-api",
    State = ApiManagementSubscriptionState.Active
};

Get Subscription Keys

var secrets = await subscription.Value.GetSecretsAsync();
Console.WriteLine($"Primary Key: {secrets.Value.PrimaryKey}");
Console.WriteLine($"Secondary Key: {secrets.Value.SecondaryKey}");

Regenerate Subscription Keys

// Regenerate primary key
await subscription.Value.RegeneratePrimaryKeyAsync();

// Regenerate secondary key
await subscription.Value.RegenerateSecondaryKeyAsync();

List Subscriptions

await foreach (var sub in service.GetApiManagementSubscriptions())
{
    Console.WriteLine($"{sub.Data.DisplayName}: {sub.Data.State}");
}

Suspend/Activate Subscription

// Suspend
var patch = new ApiManagementSubscriptionPatch
{
    State = ApiManagementSubscriptionState.Suspended
};
await subscription.Value.UpdateAsync(patch);

// Reactivate
patch.State = ApiManagementSubscriptionState.Active;
await subscription.Value.UpdateAsync(patch);

Create User

var userData = new ApiManagementUserCreateOrUpdateContent
{
    Email = "user@contoso.com",
    FirstName = "John",
    LastName = "Doe",
    State = ApiManagementUserState.Active,
    Password = "SecurePassword123!"  // Optional, can send invite instead
};

var user = await service.GetApiManagementUsers()
    .CreateOrUpdateAsync(WaitUntil.Completed, "john-doe", userData);

Create Group

var groupData = new ApiManagementGroupCreateOrUpdateContent
{
    DisplayName = "Premium Users",
    Description = "Users with premium access",
    GroupContractType = ApiManagementGroupType.Custom
};

var group = await service.GetApiManagementGroups()
    .CreateOrUpdateAsync(WaitUntil.Completed, "premium-users", groupData);

Add User to Group

await group.Value.GetGroupUsers()
    .CreateOrUpdateAsync(WaitUntil.Completed, "john-doe");

Add Group to Product

await product.Value.GetProductGroups()
    .CreateOrUpdateAsync(WaitUntil.Completed, "premium-users");

Delete Subscription

await subscription.Value.DeleteAsync(WaitUntil.Completed);

Source: SKILL.md on GitHub

1 warning15d4 checks · Risk SAFE
  • Gen Agent Trust Hub15d

    This skill facilitates the management of Azure API Management resources via the .NET SDK. It includes some security considerations regarding the handling of sensitive credentials in example code and the ingestion of external data for API definitions, which are standard for such tooling but warrant review.

  • Socket15d

    No alerts

  • Snyk15d

    Risk: LOW · No issues

  • Runlayer7mo

    5/5 files flagged

Signed by skilld at 073741f. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 5 months ago
Other metadata
metadata
{
  "author": "Microsoft",
  "version": "1.0.0",
  "package": "Azure.ResourceManager.ApiManagement"
}

README badge

README badge for microsoft/skills/azure-mgmt-apimanagement-dotnet