THIS PART IS UNDER CONSTRUCTION. LAST UPDATE 06/15/2020.

API Management - Hands-on Lab Script - part 8

Please see aka.ms/apimdevops for more guidance and tools around automating deployment across multiple API Management environments.

Continuos Integration and Continuos Deployment using Azure DevOps

The following instructions demonstrate how to deploy the contents of this example repository using Azure DevOps Repos and Azure DevOps Pipelines.

Pre-reqs

To execute this solution you will need:

Architecture

This is one example of how to use Azure DevOps Repo and Azure DevOps Pipelines to enable a Continuous Integration and Continuous Deployment (CI/CD) for API's on an Azure API Management Service. There’re other ways to do this, but this is a "Keep it Simple" to help you start. (Planning to have another version using Github and Github Actions soon).

This is our Development API management. In general, developers will create their API's in one instance of APIM to test it.

Create your API’s on API Management Development environment. (How to create API’s on API Management)

APIM DevOps Toolkit

Running the Extractor

After a developer creates and tests APIs in API management, it is time to extract those APIs using this DevOps Resource Kit.

Below are the steps to run the extractor from source code:

dotnet restore 

az login

az account set \--subscription \<subscription\_id\>

Extractor Arguments

You have two choices when specifying your settings:

1. By using a JSON file with key-values where the keys matches the table below. Use the `extractorConfig` argument:

`extract --extractorConfig c:/temp/extractSettings.json`. See more examples.

2. Pass the arguments on the command line. For instance `extract --sourceApimName my-feature-apim --destinationApimName company-stable-apim --resourceGroup my-feature-rg --fileFolder c:\temp\apim-extract --apiName MyFeatureV1Api`.

For this example, we will only use the option #2

So, run the application with:


dotnet run extract --sourceApimName <DEV-APIM-NAME> --destinationApimName <DESTINATION-APIM-NAME> --resourceGroup <RESOURCE-GROUP-NAME> --fileFolder c:\\temp\\apim-extract.

Where:

DEV-APIM-NAME: API Management where you created your API

DESTINATION-APIM-NAME: It's just a convention to set the DESTINATION-API-NAME in front of the generated files.

RESOURCE-GROUP-NAME: Resource group where the DEV-APIM-NAME is hosted.

**–fileFolder (NOTE: git clone and create the local repos before executing the dotnet run extract)

For more information on how to run the application and parameters, go to this page.

After executing the command above, you will see something similar to this:

Then you see the JSON files extracted:

Now, push them to your Azure DevOps Repo

git add *
git commit -a -m "add extracted *.json files to devops repository
git push

Build Pipeline

We will use a Build Pipeline to pull the extracted files from a repo and put it on Azure DevOps Artefacts Folder.

1 - Add these tasks to your build:

2 - Configure the fields as show bellow:

A screenshot of a cell phone Description automatically
generated

A screenshot of a cell phone Description automatically
generated

Release Pipeline

You can use this document as a reference on how to create a release pipeline.

1 - Add an Azure Deployment tasks for each file generated by the extractor, following the order:

- Products.template.json
- Tags.template.json
- namedValues.template.json
- apis.template.json
- globalServicePolice.template.json

2 - Set “Override template parameters” field with “-ApimServiceName <QA-APIM-NAME>"

3 - Set set Deployment mode to Incremental

When you finish the steps above, you will see something like this:

Clone your QA environment and update the Resource Group and ApimServiceName value on “Override template parameters” field to reflect your “production” APIM.

Now you will see your Release Pipeline like this:

By using a combination of manual deployment approvals, gates, and manual intervention within a release pipeline in Azure Pipelines, you can quickly and easily configure a release pipeline with all the control and auditing capabilities you require for your DevOps CI/CD processes. You will find more information on this link.


Home | Prev