|
| 1 | +--- |
| 2 | +title: Build and Register APIs - VS Code Extension |
| 3 | +description: Learn how API developers can use the Azure API Center extension for Visual Studio Code to build and register APIs in their organization's API center. |
| 4 | + |
| 5 | +ms.service: azure-api-center |
| 6 | +ms.topic: how-to |
| 7 | +ms.date: 08/28/2025 |
| 8 | +ms.update-cycle: 180-days |
| 9 | + |
| 10 | +ms.collection: ce-skilling-ai-copilot |
| 11 | +ms.custom: |
| 12 | +# Customer intent: As an API developer, I want to use my Visual Studio Code environment to register APIs in my organization's API center as part of my development workflow. |
| 13 | +--- |
| 14 | + |
| 15 | +# Build and register APIs with the Azure API Center extension for VS Code |
| 16 | + |
| 17 | +API producer developers in your organization can build and register APIs in your [API center](overview.md) inventory by using the Azure API Center extension for Visual Studio Code. API developers can: |
| 18 | + |
| 19 | +* Add an existing API to an API center as a one-time operation, or integrate a development pipeline to register APIs as part of a CI/CD workflow. |
| 20 | +* Use GitHub Copilot to generate new OpenAPI specs from API code. |
| 21 | + |
| 22 | +API consumer developers can also take advantage of features in the extension to [discover and consume APIs](discover-apis-vscode-extension.md) in the API center and ensure [API governance](govern-apis-vscode-extension.md). |
| 23 | + |
| 24 | +[!INCLUDE [vscode-extension-basic-prerequisites](includes/vscode-extension-basic-prerequisites.md)] |
| 25 | + |
| 26 | +The following Visual Studio Code extensions are needed for the specified scenarios: |
| 27 | + |
| 28 | +* [GitHub Actions](https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-github-actions) to register APIs using a CI/CD pipeline with GitHub Actions |
| 29 | +* [Azure Pipelines](https://marketplace.visualstudio.com/items?itemName=ms-azure-devops.azure-pipelines) to register APIs using a CI/CD pipeline with Azure Pipelines |
| 30 | +* [GitHub Copilot](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot) to generate OpenAPI specification files from API code |
| 31 | + |
| 32 | +[!INCLUDE [vscode-extension-setup](includes/vscode-extension-setup.md)] |
| 33 | + |
| 34 | +## Register an API manually |
| 35 | + |
| 36 | +The following steps register an API in your API center as a one-time operation. |
| 37 | + |
| 38 | +1. Use the **Ctrl+Shift+P** keyboard shortcut to open the Command Palette. Type **Azure API Center: Register API** and hit **Enter**. |
| 39 | +1. Select **Manual**. |
| 40 | +1. Select the API center to register APIs with. |
| 41 | +1. Answer prompts with information including API title, type, version title, version lifecycle, definition title, specification name, and definition file to complete API registration. |
| 42 | + |
| 43 | +The API is added to your API center inventory. |
| 44 | + |
| 45 | +## Register APIs using CI/CD pipeline |
| 46 | + |
| 47 | +The following steps register an API in your API center with a CI/CD pipeline. With this option, add a preconfigured GitHub or Azure DevOps pipeline to your active Visual Studio Code workspace that is run as part of a CI/CD workflow on each commit to source control. It's recommended to inventory APIs with your API center using CI/CD to ensure API metadata including specification and version stay current in your API center as the API continues to evolve over time. |
| 48 | + |
| 49 | +1. Use the **Ctrl+Shift+P** keyboard shortcut to open the Command Palette. Type **Azure API Center: Register API** and hit **Enter**. |
| 50 | +1. Select **CI/CD**. |
| 51 | +1. Select either **GitHub** or **Azure DevOps**, depending on your preferred source control mechanism. A Visual Studio Code workspace must be open for the Azure API Center extension to add a pipeline to your workspace. After the file is added, complete steps documented in the CI/CD pipeline file itself to configure required environment variables and identity. On push to source control, the API is registered in your API center. |
| 52 | + |
| 53 | +To learn more about setting up a GitHub Actions workflow, see [Register APIs in your API center using GitHub Actions](register-apis-github-actions.md). |
| 54 | + |
| 55 | +## Generate OpenAPI spec from API code |
| 56 | + |
| 57 | +Use the power of [GitHub Copilot](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot) with the Azure API Center extension for Visual Studio Code to create an OpenAPI specification file from your API code. Right-click on the API code, select **Copilot** from the options, and select **Generate API documentation**. GitHub Copilot creates an OpenAPI specification file. |
| 58 | + |
| 59 | +:::image type="content" source="media/build-register-apis-vscode-extension/generate-api-documentation.gif" alt-text="Animation showing how to use GitHub Copilot to generate an OpenAPI spec from code." lightbox="media/build-register-apis-vscode-extension/generate-api-documentation.gif"::: |
| 60 | + |
| 61 | +You can also generate an OpenAPI specification from all of the files in your current project. Use the **Azure API Center: Generate OpenAPI Spec from Entire Project** command from the Command Palette. |
| 62 | + |
| 63 | +After generating the OpenAPI specification file and checking for accuracy, you can register the API with your API center using the **Azure API Center: Register API** command. |
| 64 | + |
| 65 | +> [!TIP] |
| 66 | +> API developers can also generate new OpenAPI specs using natural language prompts with the API Center plugin for GitHub Copilot for Azure. To learn more, see [Design and develop APIs](design-api-github-copilot-azure.md). |
| 67 | +
|
| 68 | +## Related content |
| 69 | + |
| 70 | +* [Azure API Center - key concepts](key-concepts.md) |
| 71 | +* [Discover and consume APIs with the Azure API Center extension for Visual Studio Code](discover-apis-vscode-extension.md) |
| 72 | +* [Govern APIs with the Azure API Center extension for Visual Studio Code](govern-apis-vscode-extension.md) |
| 73 | +* [Enable API Center portal view in Visual Studio Code](enable-api-center-portal-vs-code-extension.md) |
| 74 | +* [What is GitHub Copilot for Azure?](/azure/developer/github-copilot-azure/introduction) |
0 commit comments