Loading...

Working with API management DevOps resource kit

Working with API management DevOps resource kit

This blog helps to set up the Azure API Management-devops-resource-kit , gives details on how to run the creator and extractor tools to generate ARM templates and lists out common questions and answers.

 

The generated ARM templated using APIM DevOps toolkit can further be integrated with DevOps tool for automated deployment in different environments.

 

Understanding DevOps

 

  • It is a group of procedures, equipment, and cultural ideals that integrate and automate the procedures between IT and software development teams.
  • It increases the effectiveness, speed, and security of software development and delivery compared to conventional approaches by combining development and operations.
  • DevOps Life Cycle contains phases shown in below diagram:
     
     

    Devops1.png

 

DevOPS tools

 

  • DevOps Tool is an application that helps automate the software development process. It mainly focuses on communication and collaboration between product management, software development, and operations professionals.
  • enables teams to automate most of the software development processes like build, conflict management, dependency management, deployment, etc. and helps reduce manual efforts.
  • Example of tools - Azure devops, Jenkins, Ansible, Puppet

 

azure-api-management-devops-resource-kit

 

  • Contains Creator and extractor tools with samples.
  • These tools help us to create ARM templates which can be integrated in dev-ops pipeline.
  • The deployment of the templates can be automated using Github ActionsAzure PipelinePowerShellAzure CLI or other tools.
  • To start using this kit, we need to download its code.

 

Code Set-up

 

          Devops2.png

           

           Devops3.png

  • Downloaded code:

Devops4.png

  • Next step is to open code folder in Visual Studio code as shown below:

Devops5.png

  • Restore packages using dotnet restore command in Terminal.

Devops6.png

  • ArmTemplates folder contain “Creator” and “Extractor” tools:

Devops7.png

  • Example folder contains pre-created files which we can use to understand the functioning of azure-api-management-devops-resource-kit

Devops8.png

 

Creator tool

 

This utility creates Resource Manager templates for an API based on the OpenAPI Specification of the API. Optionally, you can provide policies you wish to apply to the API and its operations in separate files.

Create the config file using the configuration settings given in: https://github.com/Azure/azure-api-management-devops-resource-kit/blob/main/src/README.md#Creator

 

Common Scenario:

Let’s say we have OpenAPI specification (swagger file) and we want to generate APIM ARM template out of it which will help us in creating APIM in subsequent environments like staging, PROD.

 

Solution:

  • In this scenario we must use creator tool to generate ARM templates.
  • To get an understanding of Creator, we will use default file provided as below:
  • Here Valid.yml is the Creator tool’s Configuration file.

Devops9.png

  • This file states apimServiceName,  apiVersionSets, apis and outputlocation settings.
  • Creator tool will create ARM template using these settings and will place the generated files in the folder mentioned in outputlocation settings.
  • We can run creator tool using below command:
    • dotnet run create --configFile CONFIG_YAML_FILE_LOCATION
  • We will use Valid.yml which is already provided in the solution, and it’s customized as per requirement.
  • We will use swaggerPetstore.json which is the OpenAPI specification file which is already provided in the solution.

Devops10.png

  • Open command prompt and navigate to the ARMTemplates folder location and run below command. (Path will change)
    • dotnet run create --configFile C:\Aditi\DevOps\azure-api-management-devops-resource-kit-main\azure-api-management-devops-resource-kit-main\example\demo\Input\valid.yml

Devops11.png

  • After running creator command, tool creates ARM templates and places them in the location mentioned in the valid.yml file.

Devops12.png

For more details on creator tool, settings etc. Please refer https://github.com/Azure/azure-api-management-devops-resource-kit/blob/main/src/README.md#Creator

 

Extractor tool

 

This utility generates Resource Manager templates by extracting existing configurations of one or more APIs in an API Management instance.

Example Scenario:

APIM is already created on Azure, and we want to extract ARM template out of it for deployments in subsequent environments.

  • Existing APIM

Devops13.png

  • Create extractor settings file. Example – extractorSettings.json

Devops14.png

  • Open command prompt and navigate to the ARMTemplates folder location and run below command. (Path will change)
  • “dotnet run extract --extractorConfig C:\Aditi\DevOps\azure-api-management-devops-resource-kit-main\azure-api-management-devops-resource-kit-main\example\ExtratorSample_Aditi\extractorSetting.json”
  • Output:

Devops15.png

For more details on Extractor commands, settings file examples, please refer https://github.com/Azure/azure-api-management-devops-resource-kit/blob/main/src/README.md#extractor

 

Notes

 

  • If while configuring code, “dotnet restore” does not work and if you start getting errors while calling “dotnet restore”:
  • It means that required packages are not getting restored for below C# solution:

Devops16.png

  • In this case open ArmTemplates.csprj in Visual studio:

Devops17.png

  • Select “Manage NuGet Packages for Solution”

Devops18.png

  • Package source might be having “OfflinePackages” only as package source.

Devops19.png

  • To restore packages, we need to add online package source which will connect to “Nuget.Org” and download the required packages.
  • Click on “Settings” icon besides drop down and click on “Plus” icon from below window.
  • Make an entry matching below screenshot:

Devops20.png

  • After adding this entry, right click on solution and click on “Restore NuGet Packages”

Devops21.png

  • This will restore packages for the ArmTemplates solution, and you are good to run the Creator and Extractor commands now.

 

Common listed questions and answers:

 

Difference between Repository and APIM CICD approach.

Response:                                                                               

  • APIM Git repository is mainly used for backup and does not contain ARM templates.
  • Azure APIM devops resource kit helps us to generate ARM templates using creator and extractor tools. This approach is recommended for large deployments.

 

How to extract APIM with Master /shared/ Service templates and linked templates.

Response: 

  • Please find below sample configuration to generate master template:
  • Run Extractor tool with below configuration.
  • To generate master template:

{

    "sourceApimName": "DevAPIMInternal",

    "destinationApimName": "DevAPIMInternal2",

    "resourceGroup": "apim-rg",

    "linkedTemplatesBaseUrl": true,

    "fileFolder": "C:/Test/APIM_DevOPs/azure-api-management-devops-resource-kit-      main/example/ExtratorSample/Output/linkedTemplates"

}           

  • Path specified in “fileFolder”, will be used to place generated templates using the tool.

Devops22.png

 

Definitions

Service Templates

Contains all service level configurations of the API such as custom domain names, no. of scaling units, pricing tier, managed identity etc.

 

API Templates

For each APIM there are one or more api templates for the configurations of this API  such as API definitions, policies, named values, diagnostic settings etc. Each of these templates can be deployed individually. To deploy single API, deploy template for that API. To deploy everything all together user master template which links to everything.

 

Shared Templates

For shared resources such as products, groups.

 

 

How can we deploy multiple apis using creator tool (how to specify multiple apis under “api:” array of creator tool?

Response:

Please refer below section from valid.yml (creator configuration file) where 2 apis have been specified in the “api:” array.

Devops23.png

 

Generated output:

Devops24.png

 

References

 

Published on:

Learn more
Need help with this product?

We can help you with Working with API management DevOps resource kit

If you want help implementing, troubleshooting, or improving this product, contact us and we’ll point you in the right direction.

Azure PaaS Blog articles
Azure PaaS Blog articles

Azure PaaS Blog articles

Share post:

Related posts

Azure Storage - TLS 1.0 and 1.1 retirement

Overview TLS 1.0 and 1.1 retirement on Azure Storage was previously announced for Nov 1st, 2024, and it was postponed recently to 1 year later...

1 year ago

Efficient Management of Append and Page Blobs Using Azure Storage Actions

  Overview In Azure Storage, Blob Lifecycle Management (BLM) allows you to automate the management of your data based on rules defined by...

1 year ago

[Azure AI Search] Internal Server Error when creating CMK encrypted objects

Scenario Customers follow the Microsoft doc to create CMK encrypted objects (data source, index etc.), but get the 500 Internal Serv...

1 year ago

Optimizing Azure Table Storage: Automated Data Cleanup using a PowerShell script with Azure Automate

Scenario This blog’s aim is to manage Table Storage data efficiently. Imagine you have a large Azure Table Storage that accumulates logs from ...

1 year ago

Optimizing Azure Table Storage: Automated Data Clean-up using a PowerShell script with Azure Automat

Scenario This blog’s aim is to manage Table Storage data efficiently. Imagine you have a large Azure Table Storage that accumulates logs from ...

1 year ago

Restoring Soft-Deleted Blobs with multithreading in Azure Storage Using C#

Blob soft delete is an essential feature that safeguards your data against accidental deletions or overwrites. By retaining deleted data for a...

1 year ago

Performing simple Azure Table Storage REST API operations using curl command.

The blog provides guidance to perform simple Table Storage REST API operations such as Create table, Delete Table, Insert entity, Delete entit...

2 years ago

Bulk delete all the old jobs from the batch account

Deleting a Job also deletes all Tasks that are part of that Job, and all Job statistics. This also overrides the retention period for Task dat...

2 years ago

Utilizing Azure Storage and Runbooks for scheduled automated backups of Azure SQL Databases

In this article, we are going to provide detailed steps to create a scheduled Azure SQL Database backup to storage account using automation. T...

2 years ago

[Azure Service Bus] JMS messages getting dead-lettered

The article discusses a problem where numerous messages end up in the dead letter queue (DLQ) when the JMS service bus consumer connects to th...

2 years ago

Newsletter

Get the latest Dynamics 365 and Power Platform content in your inbox

A curated digest of community blogs, product news, videos, and podcasts — delivered without the noise.

Weekly updates Unsubscribe anytime Fresh community picks
We use your email only for the newsletter and you can unsubscribe at any time.
By subscribing, you agree to the privacy policy.