Add this skill
npx mdskills install sickn33/azure-mgmt-apicenter-dotnetComprehensive Azure API Center SDK documentation with well-structured workflows and clear examples
1---2name: azure-mgmt-apicenter-dotnet3description: |4 Azure API Center SDK for .NET. Centralized API inventory management with governance, versioning, and discovery. Use for creating API services, workspaces, APIs, versions, definitions, environments, deployments, and metadata schemas. Triggers: "API Center", "ApiCenterService", "ApiCenterWorkspace", "ApiCenterApi", "API inventory", "API governance", "API versioning", "API catalog", "API discovery".5package: Azure.ResourceManager.ApiCenter6---78# Azure.ResourceManager.ApiCenter (.NET)910Centralized API inventory and governance SDK for managing APIs across your organization.1112## Installation1314```bash15dotnet add package Azure.ResourceManager.ApiCenter16dotnet add package Azure.Identity17```1819**Current Version**: v1.0.0 (GA)20**API Version**: 2024-03-012122## Environment Variables2324```bash25AZURE_SUBSCRIPTION_ID=<your-subscription-id>26AZURE_RESOURCE_GROUP=<your-resource-group>27AZURE_APICENTER_SERVICE_NAME=<your-apicenter-service>28```2930## Authentication3132```csharp33using Azure.Identity;34using Azure.ResourceManager;35using Azure.ResourceManager.ApiCenter;3637ArmClient client = new ArmClient(new DefaultAzureCredential());38```3940## Resource Hierarchy4142```43Subscription44└── ResourceGroup45 └── ApiCenterService # API inventory service46 ├── Workspace # Logical grouping of APIs47 │ ├── Api # API definition48 │ │ └── ApiVersion # Version of the API49 │ │ └── ApiDefinition # OpenAPI/GraphQL/etc specification50 │ ├── Environment # Deployment target (dev/staging/prod)51 │ └── Deployment # API deployed to environment52 └── MetadataSchema # Custom metadata definitions53```5455## Core Workflows5657### 1. Create API Center Service5859```csharp60using Azure.ResourceManager.ApiCenter;61using Azure.ResourceManager.ApiCenter.Models;6263ResourceGroupResource resourceGroup = await client64 .GetDefaultSubscriptionAsync()65 .Result66 .GetResourceGroupAsync("my-resource-group");6768ApiCenterServiceCollection services = resourceGroup.GetApiCenterServices();6970ApiCenterServiceData data = new ApiCenterServiceData(AzureLocation.EastUS)71{72 Identity = new ManagedServiceIdentity(ManagedServiceIdentityType.SystemAssigned)73};7475ArmOperation<ApiCenterServiceResource> operation = await services76 .CreateOrUpdateAsync(WaitUntil.Completed, "my-api-center", data);7778ApiCenterServiceResource service = operation.Value;79```8081### 2. Create Workspace8283```csharp84ApiCenterWorkspaceCollection workspaces = service.GetApiCenterWorkspaces();8586ApiCenterWorkspaceData workspaceData = new ApiCenterWorkspaceData87{88 Title = "Engineering APIs",89 Description = "APIs owned by the engineering team"90};9192ArmOperation<ApiCenterWorkspaceResource> operation = await workspaces93 .CreateOrUpdateAsync(WaitUntil.Completed, "engineering", workspaceData);9495ApiCenterWorkspaceResource workspace = operation.Value;96```9798### 3. Create API99100```csharp101ApiCenterApiCollection apis = workspace.GetApiCenterApis();102103ApiCenterApiData apiData = new ApiCenterApiData104{105 Title = "Orders API",106 Description = "API for managing customer orders",107 Kind = ApiKind.Rest,108 LifecycleStage = ApiLifecycleStage.Production,109 TermsOfService = new ApiTermsOfService110 {111 Uri = new Uri("https://example.com/terms")112 },113 ExternalDocumentation =114 {115 new ApiExternalDocumentation116 {117 Title = "Documentation",118 Uri = new Uri("https://docs.example.com/orders")119 }120 },121 Contacts =122 {123 new ApiContact124 {125 Name = "API Support",126 Email = "api-support@example.com"127 }128 }129};130131// Add custom metadata132apiData.CustomProperties = BinaryData.FromObjectAsJson(new133{134 team = "orders-team",135 costCenter = "CC-1234"136});137138ArmOperation<ApiCenterApiResource> operation = await apis139 .CreateOrUpdateAsync(WaitUntil.Completed, "orders-api", apiData);140141ApiCenterApiResource api = operation.Value;142```143144### 4. Create API Version145146```csharp147ApiCenterApiVersionCollection versions = api.GetApiCenterApiVersions();148149ApiCenterApiVersionData versionData = new ApiCenterApiVersionData150{151 Title = "v1.0.0",152 LifecycleStage = ApiLifecycleStage.Production153};154155ArmOperation<ApiCenterApiVersionResource> operation = await versions156 .CreateOrUpdateAsync(WaitUntil.Completed, "v1-0-0", versionData);157158ApiCenterApiVersionResource version = operation.Value;159```160161### 5. Create API Definition (Upload OpenAPI Spec)162163```csharp164ApiCenterApiDefinitionCollection definitions = version.GetApiCenterApiDefinitions();165166ApiCenterApiDefinitionData definitionData = new ApiCenterApiDefinitionData167{168 Title = "OpenAPI Specification",169 Description = "Orders API OpenAPI 3.0 definition"170};171172ArmOperation<ApiCenterApiDefinitionResource> operation = await definitions173 .CreateOrUpdateAsync(WaitUntil.Completed, "openapi", definitionData);174175ApiCenterApiDefinitionResource definition = operation.Value;176177// Import specification178string openApiSpec = await File.ReadAllTextAsync("orders-api.yaml");179180ApiSpecImportContent importContent = new ApiSpecImportContent181{182 Format = ApiSpecImportSourceFormat.Inline,183 Value = openApiSpec,184 Specification = new ApiSpecImportSpecification185 {186 Name = "openapi",187 Version = "3.0.1"188 }189};190191await definition.ImportSpecificationAsync(WaitUntil.Completed, importContent);192```193194### 6. Export API Specification195196```csharp197ApiCenterApiDefinitionResource definition = await client198 .GetApiCenterApiDefinitionResource(definitionResourceId)199 .GetAsync();200201ArmOperation<ApiSpecExportResult> operation = await definition202 .ExportSpecificationAsync(WaitUntil.Completed);203204ApiSpecExportResult result = operation.Value;205206// result.Format - e.g., "inline"207// result.Value - the specification content208```209210### 7. Create Environment211212```csharp213ApiCenterEnvironmentCollection environments = workspace.GetApiCenterEnvironments();214215ApiCenterEnvironmentData envData = new ApiCenterEnvironmentData216{217 Title = "Production",218 Description = "Production environment",219 Kind = ApiCenterEnvironmentKind.Production,220 Server = new ApiCenterEnvironmentServer221 {222 ManagementPortalUris = { new Uri("https://portal.azure.com") }223 },224 Onboarding = new EnvironmentOnboardingModel225 {226 Instructions = "Contact platform team for access",227 DeveloperPortalUris = { new Uri("https://developer.example.com") }228 }229};230231ArmOperation<ApiCenterEnvironmentResource> operation = await environments232 .CreateOrUpdateAsync(WaitUntil.Completed, "production", envData);233```234235### 8. Create Deployment236237```csharp238ApiCenterDeploymentCollection deployments = workspace.GetApiCenterDeployments();239240// Get environment resource ID241ResourceIdentifier envResourceId = ApiCenterEnvironmentResource.CreateResourceIdentifier(242 subscriptionId, resourceGroupName, serviceName, workspaceName, "production");243244// Get API definition resource ID245ResourceIdentifier definitionResourceId = ApiCenterApiDefinitionResource.CreateResourceIdentifier(246 subscriptionId, resourceGroupName, serviceName, workspaceName,247 "orders-api", "v1-0-0", "openapi");248249ApiCenterDeploymentData deploymentData = new ApiCenterDeploymentData250{251 Title = "Orders API - Production",252 Description = "Production deployment of Orders API v1.0.0",253 EnvironmentId = envResourceId,254 DefinitionId = definitionResourceId,255 State = ApiCenterDeploymentState.Active,256 Server = new ApiCenterDeploymentServer257 {258 RuntimeUris = { new Uri("https://api.example.com/orders") }259 }260};261262ArmOperation<ApiCenterDeploymentResource> operation = await deployments263 .CreateOrUpdateAsync(WaitUntil.Completed, "orders-api-prod", deploymentData);264```265266### 9. Create Metadata Schema267268```csharp269ApiCenterMetadataSchemaCollection schemas = service.GetApiCenterMetadataSchemas();270271string jsonSchema = """272{273 "type": "object",274 "properties": {275 "team": {276 "type": "string",277 "title": "Owning Team"278 },279 "costCenter": {280 "type": "string",281 "title": "Cost Center"282 },283 "dataClassification": {284 "type": "string",285 "enum": ["public", "internal", "confidential"],286 "title": "Data Classification"287 }288 },289 "required": ["team"]290}291""";292293ApiCenterMetadataSchemaData schemaData = new ApiCenterMetadataSchemaData294{295 Schema = jsonSchema,296 AssignedTo =297 {298 new MetadataAssignment299 {300 Entity = MetadataAssignmentEntity.Api,301 Required = true302 }303 }304};305306ArmOperation<ApiCenterMetadataSchemaResource> operation = await schemas307 .CreateOrUpdateAsync(WaitUntil.Completed, "api-metadata", schemaData);308```309310### 10. List and Search APIs311312```csharp313// List all APIs in a workspace314ApiCenterWorkspaceResource workspace = await client315 .GetApiCenterWorkspaceResource(workspaceResourceId)316 .GetAsync();317318await foreach (ApiCenterApiResource api in workspace.GetApiCenterApis())319{320 Console.WriteLine($"API: {api.Data.Title}");321 Console.WriteLine($" Kind: {api.Data.Kind}");322 Console.WriteLine($" Stage: {api.Data.LifecycleStage}");323324 // List versions325 await foreach (ApiCenterApiVersionResource version in api.GetApiCenterApiVersions())326 {327 Console.WriteLine($" Version: {version.Data.Title}");328 }329}330331// List environments332await foreach (ApiCenterEnvironmentResource env in workspace.GetApiCenterEnvironments())333{334 Console.WriteLine($"Environment: {env.Data.Title} ({env.Data.Kind})");335}336337// List deployments338await foreach (ApiCenterDeploymentResource deployment in workspace.GetApiCenterDeployments())339{340 Console.WriteLine($"Deployment: {deployment.Data.Title}");341 Console.WriteLine($" State: {deployment.Data.State}");342}343```344345## Key Types Reference346347| Type | Purpose |348|------|---------|349| `ApiCenterServiceResource` | API Center service instance |350| `ApiCenterWorkspaceResource` | Logical grouping of APIs |351| `ApiCenterApiResource` | Individual API |352| `ApiCenterApiVersionResource` | Version of an API |353| `ApiCenterApiDefinitionResource` | API specification (OpenAPI, etc.) |354| `ApiCenterEnvironmentResource` | Deployment environment |355| `ApiCenterDeploymentResource` | API deployment to environment |356| `ApiCenterMetadataSchemaResource` | Custom metadata schema |357| `ApiKind` | rest, graphql, grpc, soap, webhook, websocket, mcp |358| `ApiLifecycleStage` | design, development, testing, preview, production, deprecated, retired |359| `ApiCenterEnvironmentKind` | development, testing, staging, production |360| `ApiCenterDeploymentState` | active, inactive |361362## Best Practices3633641. **Organize with workspaces** — Group APIs by team, domain, or product3652. **Use metadata schemas** — Define custom properties for governance3663. **Track lifecycle stages** — Keep API status current (design → production → deprecated)3674. **Document environments** — Include onboarding instructions and portal URIs3685. **Version consistently** — Use semantic versioning for API versions3696. **Import specifications** — Upload OpenAPI/GraphQL specs for discovery3707. **Link deployments** — Connect APIs to their runtime environments3718. **Use managed identity** — Enable SystemAssigned identity for secure integrations372373## Error Handling374375```csharp376using Azure;377378try379{380 ArmOperation<ApiCenterApiResource> operation = await apis381 .CreateOrUpdateAsync(WaitUntil.Completed, "my-api", apiData);382}383catch (RequestFailedException ex) when (ex.Status == 409)384{385 Console.WriteLine("API already exists with conflicting configuration");386}387catch (RequestFailedException ex) when (ex.Status == 400)388{389 Console.WriteLine($"Invalid request: {ex.Message}");390}391catch (RequestFailedException ex)392{393 Console.WriteLine($"Azure error: {ex.Status} - {ex.Message}");394}395```396397## Related SDKs398399| SDK | Purpose | Install |400|-----|---------|---------|401| `Azure.ResourceManager.ApiCenter` | API Center management (this SDK) | `dotnet add package Azure.ResourceManager.ApiCenter` |402| `Azure.ResourceManager.ApiManagement` | API gateway and policies | `dotnet add package Azure.ResourceManager.ApiManagement` |403404## Reference Links405406| Resource | URL |407|----------|-----|408| NuGet Package | https://www.nuget.org/packages/Azure.ResourceManager.ApiCenter |409| API Reference | https://learn.microsoft.com/dotnet/api/azure.resourcemanager.apicenter |410| Product Documentation | https://learn.microsoft.com/azure/api-center/ |411| GitHub Source | https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/apicenter/Azure.ResourceManager.ApiCenter |412
Full transparency — inspect the skill content before installing.