Skip to content

This provides some reference use cases while using Azure API Center

License

Notifications You must be signed in to change notification settings

Azure-Samples/APICenter-Reference

Repository files navigation

API Center Reference

Throughout this reference sample, we'd like to give developer experiences how to use API Center (APIC) and seamless integration with API Management (APIM), as well as inner-loop development velocity increase.

  • API Inventory
    • To Showcase API Management integration to quickly build API inventory from many API Management instances
    • To register APIs manually or through GitHub Actions workflow
  • API Governance
    • To perform shift-left API governance functionality in VS Code
    • To run APIC Analyzer for server-side linting
    • To manage custom metadata
  • API Discovery and Consumption
    • To integrate the client SDK in .NET & JavaScript
    • To prepare the server app scaffolding in .NET and JavaScript
    • To manage API Center OSS portal

Prerequisites

Getting Started

Provisioning and deploying all the resources are as easy as running a few commands. Follow the steps below to get started.

  1. Fork this repository.

  2. Clone the forked repository to your local machine or Open in GitHub Codespaces

  3. Log in with the following command. Then, you will be able to use the azd cli to quickly provision and deploy the application.

    # Authenticate with Azure Developer CLI
    azd auth login
    
    # Authenticate with Azure CLI
    az login
  4. Run azd provision to provision all the resources to Azure and deploy the code to those resources.

    azd provision
  5. After the deployment is completed, navigate to Azure Portal and find the API Center instance. Then, you'll see all the APIs registered.

    APIs registered on API Center

  6. Navigate to the API Analysis blade and see the analysis results.

    API Analysis

  7. Find the Azure Static Web App instance name ending with -portal and open the app to see the API Center portal.

    API Center Portal

  8. Login to the portal and you'll see all the APIs registered to the API Center.

    API Center Portal

  9. If you want to see how APIs registered in API Center are integrated with the existing applications, run the following command to deploy both .NET apps and node.js apps to Azure.

    azd deploy
  10. If you want to run both azd provision and azd deploy in one go, run the following command:

    azd up

CI/CD Pipeline Integration

If you want to integrate the CI/CD pipeline with GitHub Actions, you can use the following command to create a GitHub repository and push the code to the repository.

  1. First of all, log in to GitHub.

    # Authenticate with GitHub CLI
    gh auth login
  2. Run the following commands to update your GitHub repository variables.

    # bash/zsh
    AZURE_CLIENT_ID=$(./infra/scripts/get-azdvariable.sh --key AZURE_CLIENT_ID)
    azd pipeline config --principal-id $AZURE_CLIENT_ID
    # PowerShell
    $AZURE_CLIENT_ID = $(./infra/scripts/Get-AzdVariable.ps1 -Key AZURE_CLIENT_ID)
    azd pipeline config --principal-id $AZURE_CLIENT_ID
  3. Now, you're good to go! Push the code to the GitHub repository or manually run the GitHub Actions workflow to get your portal deployed.

Clean Up Resources

Once you complete playing around with the resources, you can clean up all the resources provisioned by running the following command to avoid unnecessary cost shock.

azd down --purge --force

Other Integrations

There are several ways to integrate API Center with your solutions. You can choose the one that fits your needs.

Resources