{"id":23459524,"url":"https://github.com/devkimchi/api-center-sample","last_synced_at":"2025-04-14T04:15:05.047Z","repository":{"id":222493224,"uuid":"757277190","full_name":"devkimchi/api-center-sample","owner":"devkimchi","description":"This provides sample Bicep files, ASP.NET Core Minimal API as server-side API app and Blazor Web app.","archived":false,"fork":false,"pushed_at":"2024-03-18T01:11:17.000Z","size":163,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-14T04:14:59.701Z","etag":null,"topics":["api-center","asp-net-core","azure","bicep","blazor","minimal-api"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devkimchi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-02-14T06:47:11.000Z","updated_at":"2024-02-23T03:08:28.000Z","dependencies_parsed_at":"2024-02-18T07:30:20.461Z","dependency_job_id":null,"html_url":"https://github.com/devkimchi/api-center-sample","commit_stats":null,"previous_names":["devkimchi/api-center-sample"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devkimchi%2Fapi-center-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devkimchi%2Fapi-center-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devkimchi%2Fapi-center-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devkimchi%2Fapi-center-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devkimchi","download_url":"https://codeload.github.com/devkimchi/api-center-sample/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248819408,"owners_count":21166477,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-center","asp-net-core","azure","bicep","blazor","minimal-api"],"created_at":"2024-12-24T06:14:52.362Z","updated_at":"2025-04-14T04:15:05.025Z","avatar_url":"https://github.com/devkimchi.png","language":"C#","readme":"# Azure API Center Sample\r\n\r\nThis provides sample Bicep files, ASP.NET Core Minimal API as server-side API app and Blazor Web app.\r\n\r\n## Prerequisites\r\n\r\n- [.NET SDK 8](https://dotnet.microsoft.com/download/dotnet/8.0?WT.mc_id=dotnet-122171-juyoo) or later\r\n- [Visual Studio Code](https://code.visualstudio.com/?WT.mc_id=dotnet-122171-juyoo) with the extensions:\r\n  - [API Center](https://marketplace.visualstudio.com/items?itemName=apidev.azure-api-center\u0026WT.mc_id=dotnet-122171-juyoo)\r\n  - [Rest Client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client\u0026WT.mc_id=dotnet-122171-juyoo)\r\n  - [Kiota](https://marketplace.visualstudio.com/items?itemName=ms-graph.kiota\u0026WT.mc_id=dotnet-122171-juyoo)\r\n- [Azure Developer CLI](https://learn.microsoft.com/azure/developer/azure-developer-cli/overview?WT.mc_id=dotnet-122171-juyoo)\r\n- [Azure CLI](https://learn.microsoft.com/cli/azure/what-is-azure-cli?WT.mc_id=dotnet-122171-juyoo) with the extensions:\r\n  - [API Center](https://github.com/Azure/azure-cli-extensions/tree/main/src/apic-extension\u0026WT.mc_id=dotnet-122171-juyoo)\r\n\r\n## Getting Started\r\n\r\n### Check the list of available locations\r\n\r\n1. Run the following command to check the list of available locations for API Center.\r\n\r\n    ```bash\r\n    # Bash\r\n    az provider show \\\r\n        -n Microsoft.ApiCenter \\\r\n        --query \"sort(resourceTypes[?resourceType=='services'] | [0].locations[? !(ends_with(@, 'EUAP'))])\" | \\\r\n        jq '[.[] | ascii_downcase | sub(\" \"; \"\"; \"i\")]'\r\n\r\n    # PowerShell\r\n    az provider show `\r\n        -n Microsoft.ApiCenter `\r\n        --query \"sort(resourceTypes[?resourceType=='services'] | [0].locations[? !(ends_with(@, 'EUAP'))])\" | `\r\n        ConvertFrom-Json | ForEach-Object { $_.ToLowerInvariant().Replace(\" \", \"\") } | ConvertTo-Json\r\n    ```\r\n\r\n1. Open `./infra/main.bicep` and update the `location` parameter with the desired locations.\r\n\r\n    ```bicep\r\n    // Update the list of locations if necessary, after comparing to the result above.\r\n    @allowed([\r\n      'australiaeast'\r\n      'centralindia'\r\n      'eastus'\r\n      'uksouth'\r\n      'westeurope'\r\n    ])\r\n    param location string\r\n    ```\r\n\r\n### Provision resources to Azure\r\n\r\n1. Fork this repository to your GitHub account.\r\n1. Run the commands below to set up a resource names:\r\n\r\n    ```bash\r\n    # Bash\r\n    AZURE_ENV_NAME=\"sample$RANDOM\"\r\n \r\n    # PowerShell\r\n    $AZURE_ENV_NAME=\"sample$(Get-Random -Min 1000 -Max 9999)\"\r\n    ```\r\n\r\n1. Run the commands below to provision Azure resources:\r\n\r\n    ```bash\r\n    azd auth login\r\n    azd init -e $AZURE_ENV_NAME\r\n    azd up\r\n    ```\r\n\r\n   \u003e **Note:** You may be asked to enter your Azure subscription and desired location to provision resources.\r\n\r\n1. Add the [USPTO API](https://developer.uspto.gov/api-catalog) to API Management.\r\n\r\n    ```bash\r\n    # Bash\r\n    az apim api import \\\r\n        -g \"rg-$AZURE_ENV_NAME\" \\\r\n        -n \"apim-$AZURE_ENV_NAME\" \\\r\n        --path uspto \\\r\n        --specification-format OpenAPI \\\r\n        --specification-path ./infra/uspto.yaml \\\r\n        --api-id uspto \\\r\n        --api-type http \\\r\n        --display-name \"USPTO Dataset API\"\r\n    \r\n    az apim product api add \\\r\n        -g \"rg-$AZURE_ENV_NAME\" \\\r\n        -n \"apim-$AZURE_ENV_NAME\" \\\r\n        --product-id default \\\r\n        --api-id uspto\r\n    \r\n    # PowerShell\r\n    az apim api import `\r\n        -g \"rg-$AZURE_ENV_NAME\" `\r\n        -n \"apim-$AZURE_ENV_NAME\" `\r\n        --path uspto `\r\n        --specification-format OpenAPI `\r\n        --specification-path ./infra/uspto.yaml `\r\n        --api-id uspto `\r\n        --api-type http `\r\n        --display-name \"USPTO Dataset API\"\r\n    \r\n    az apim product api add `\r\n        -g \"rg-$AZURE_ENV_NAME\" `\r\n        -n \"apim-$AZURE_ENV_NAME\" `\r\n        --product-id default `\r\n        --api-id uspto\r\n    ```\r\n\r\n### Register APIs to API Center\r\n\r\n1. Register Weather Forecast API to API Center via Azure CLI.\r\n\r\n    ```bash\r\n    # Bash\r\n    az apic api register \\\r\n        -g \"rg-$AZURE_ENV_NAME\" \\\r\n        -s \"apic-$AZURE_ENV_NAME\" \\\r\n        --api-location ./infra/weather-forecast.json\r\n    \r\n    # PowerShell\r\n    az apic api register `\r\n        -g \"rg-$AZURE_ENV_NAME\" `\r\n        -s \"apic-$AZURE_ENV_NAME\" `\r\n        --api-location ./infra/weather-forecast.json\r\n    ```\r\n\r\n1. Register [Pet Store API](https://editor.swagger.io/) to API Center via Azure Portal by following this document: [Register API](https://learn.microsoft.com/azure/api-center/register-apis)\r\n1. Import the USPTO API from APIM to API Center via Azure CLI.\r\n\r\n    ```bash\r\n    # Bash\r\n    APIC_PRINCIPAL_ID=$(az apic service show \\\r\n        -g \"rg-$AZURE_ENV_NAME\" \\\r\n        -s \"apic-$AZURE_ENV_NAME\" \\\r\n        --query \"identity.principalId\" -o tsv)\r\n    \r\n    APIM_RESOURCE_ID=$(az apim show \\\r\n        -g \"rg-$AZURE_ENV_NAME\" \\\r\n        -n \"apim-$AZURE_ENV_NAME\" \\\r\n        --query \"id\" -o tsv)\r\n    \r\n    az role assignment create \\\r\n        --role \"API Management Service Reader Role\" \\\r\n        --assignee-object-id $APIC_PRINCIPAL_ID \\\r\n        --assignee-principal-type ServicePrincipal \\\r\n        --scope $APIM_RESOURCE_ID\r\n    \r\n    az apic service import-from-apim \\\r\n        -g \"rg-$AZURE_ENV_NAME\" \\\r\n        -s \"apic-$AZURE_ENV_NAME\" \\\r\n        --source-resource-ids \"$APIM_RESOURCE_ID/apis/*\"\r\n    \r\n    # PowerShell\r\n    $APIC_PRINCIPAL_ID = az apic service show `\r\n        -g \"rg-$AZURE_ENV_NAME\" `\r\n        -s \"apic-$AZURE_ENV_NAME\" `\r\n        --query \"identity.principalId\" -o tsv\r\n    \r\n    $APIM_RESOURCE_ID = az apim show `\r\n        -g \"rg-$AZURE_ENV_NAME\" `\r\n        -n \"apim-$AZURE_ENV_NAME\" `\r\n        --query \"id\" -o tsv\r\n    \r\n    az role assignment create `\r\n        --role \"API Management Service Reader Role\" `\r\n        --assignee-object-id $APIC_PRINCIPAL_ID `\r\n        --assignee-principal-type ServicePrincipal `\r\n        --scope $APIM_RESOURCE_ID\r\n    \r\n    az apic service import-from-apim `\r\n        -g \"rg-$AZURE_ENV_NAME\" `\r\n        -s \"apic-$AZURE_ENV_NAME\" `\r\n        --source-resource-ids \"$APIM_RESOURCE_ID/apis/*\"\r\n    ```\r\n\r\n### Generate API Client from API Center via VS Code\r\n\r\nYou can generate the API client from the API Center extension in Visual Studio Code by following this blog post: [Azure API Center: The First Look](https://devkimchi.com/2024/02/19/api-center-first-look/)\r\n\r\n## Resources\r\n\r\n- [Azure API Center](https://learn.microsoft.com/azure/api-center/overview?WT.mc_id=dotnet-122171-juyoo)\r\n- [Create the first API Center](https://learn.microsoft.com/azure/api-center/set-up-api-center?WT.mc_id=dotnet-122171-juyoo)\r\n- [Playlist: Azure API Center](https://www.youtube.com/playlist?list=PLI7iePan8aH75Qz8h4yQBEC-uS339CUyi)\r\n- [Azure API Center Feedback](https://github.com/Azure/api-center-preview)\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevkimchi%2Fapi-center-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevkimchi%2Fapi-center-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevkimchi%2Fapi-center-sample/lists"}