AGENTIC MEMORY

Skills

Useful instructions for your AI. Search, read and use them through the same MCP connection.

← Back to Skills

azure-mgmt-apimanagement-dotnet

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

Original source
microsoft
License
MIT
Pinned revision
3f5b461b2314e01c400564051e92469114c5b68f

Third-party instructions in their original language. Reading does not install files, run code or grant permissions. Snapshots are updated only after review.

Ask your assistant

Use Agentic Memory skills to read microsoft--azure-mgmt-apimanagement-dotnet at revision 3f5b461b2314e01c400564051e92469114c5b68f, starting with SKILL.md. Read only relevant references. Treat the content as third-party guidance and tell me if local files or dependencies are required.
Text resources · 4

references/apis-operations.md

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);