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.

referencesapis-operations.md

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

APIs and Operations

Patterns for managing APIs, operations, and schemas.

Create API from OpenAPI

var apiData = new ApiCreateOrUpdateContent
{
    DisplayName = "Pet Store API",
    Path = "petstore",
    Protocols = { ApiOperationInvokableProtocol.Https },
    // Import from OpenAPI spec
    Format = ContentFormat.OpenApiJson,
    Value = File.ReadAllText("petstore-openapi.json"),
    // Or from URL
    // Format = ContentFormat.OpenApiJsonLink,
    // Value = "https://petstore.swagger.io/v2/swagger.json"
};

var api = await service.GetApis()
    .CreateOrUpdateAsync(WaitUntil.Completed, "petstore-api", apiData);

Create API Manually

var apiData = new ApiCreateOrUpdateContent
{
    DisplayName = "Custom API",
    Path = "custom",
    Protocols = { ApiOperationInvokableProtocol.Https },
    ServiceUri = new Uri("https://backend.contoso.com"),
    SubscriptionKeyParameterNames = new SubscriptionKeyParameterNamesContract
    {
        Header = "X-API-Key",
        Query = "api-key"
    }
};

var api = await service.GetApis()
    .CreateOrUpdateAsync(WaitUntil.Completed, "custom-api", apiData);

List APIs

await foreach (var api in service.GetApis())
{
    Console.WriteLine($"{api.Data.DisplayName}: {api.Data.Path}");
}

Create Operation

var operationData = new ApiOperationData
{
    DisplayName = "Get Users",
    Method = "GET",
    UrlTemplate = "/users",
    Description = "Retrieves all users",
    Responses =
    {
        new ResponseContract(200)
        {
            Description = "Success",
            Representations =
            {
                new RepresentationContract("application/json")
            }
        }
    }
};

var operation = await api.Value.GetApiOperations()
    .CreateOrUpdateAsync(WaitUntil.Completed, "get-users", operationData);

Operation with Parameters

var operationData = new ApiOperationData
{
    DisplayName = "Get User by ID",
    Method = "GET",
    UrlTemplate = "/users/{userId}",
    TemplateParameters =
    {
        new ParameterContract("userId")
        {
            Description = "User identifier",
            ParameterContractType = "string",
            IsRequired = true
        }
    },
    Request = new RequestContract
    {
        QueryParameters =
        {
            new ParameterContract("include")
            {
                Description = "Related data to include",
                ParameterContractType = "string",
                IsRequired = false
            }
        }
    }
};

API Versioning

// Create version set
var versionSetData = new ApiVersionSetData
{
    DisplayName = "My API Versions",
    VersioningScheme = VersioningScheme.Segment // or Header, Query
};

var versionSet = await service.GetApiVersionSets()
    .CreateOrUpdateAsync(WaitUntil.Completed, "my-api-versions", versionSetData);

// Create versioned API
var apiV1Data = new ApiCreateOrUpdateContent
{
    DisplayName = "My API v1",
    Path = "myapi",
    ApiVersion = "v1",
    ApiVersionSetId = versionSet.Value.Id,
    Protocols = { ApiOperationInvokableProtocol.Https }
};

var apiV2Data = new ApiCreateOrUpdateContent
{
    DisplayName = "My API v2",
    Path = "myapi",
    ApiVersion = "v2",
    ApiVersionSetId = versionSet.Value.Id,
    Protocols = { ApiOperationInvokableProtocol.Https }
};

API Revisions

// Create revision
var revisionData = new ApiCreateOrUpdateContent
{
    SourceApiId = api.Value.Id,
    Path = api.Value.Data.Path,
    ApiRevisionDescription = "Added new endpoint"
};

var revision = await service.GetApis()
    .CreateOrUpdateAsync(WaitUntil.Completed, "my-api;rev=2", revisionData);

// Make revision current
await revision.Value.UpdateAsync(WaitUntil.Completed, 
    new ApiCreateOrUpdateContent { IsCurrent = true });

Delete API

await api.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