Deploy Azure Web API into Azure API Management with PowerShell
In this blogpost I am going to share the deployment script with PowerShell to deploy Web API’s into the Azure API Management.
Using this script you should be able to create, APIM Products, Product Groups, Add Product to Product group, create new product policies, Create new API, Add new API Revision, add new API Version etc.
The PowerShell demonstrate the end to end deployment of web API’s.
Here the PowerShell Implementation and explanation:
Create new PowerShell file apim-deploy.ps1 entry point method
Add new json file (input.json), this file I am using as input to my script, the file contains meta data information about your APIs which needs to deploy into the APIM.
This input file can be used to deploy multiple products, APIs, policies at the same time.
Now lets add PowerShell Main method which search for the input file in the root directory , read the content of the file and process the content one by one
in the above ps script file we are calling method to add new project, here is the definition of that method which helps to add the product into the APIM
Add product internally makes a call to a method Add-ProductToGroup method which adds Product to a product group.
here is the method to add a product to the product group
Next, we would like to add new APIs to Product, to do that first of we have method that checks if API already available in API….
Here the Get-API method sample code
Add API With Version and Revision
Now lets add a new API, Add-NewAPI method this add new API into API management also adds a new API revision as well if revision value is specified in input.json file.
Above method (Add-NewAPI) makes call to add API version, lets see how to add new version to your API, for this we have another method Add-NewAPIVersion
Finally lets add API policies to APIs and Products, we have below method which add policy to API and product both depends on the parameters which you provide
Method currently accepts the policy file name as parameter and it read the policy content from your working directory and attach the policy, this means you need to have the policy content available into the working directory, if you want you can update the method to accept policy content as parameter and apply policy based on the policy content.
Please Subscribe to my YouTube Channel
API Management | Microsoft Azure
Azure API Management offers a scalable, multi-cloud API management platform for securing, publishing and analysing…
This topic displays help topics for the Azure API Management Cmdlets. Creates an object of PsApiManagementServiceFabric…
Versions & Revisions | Azure blog and updates | Microsoft Azure
Today we are excited to announce the public preview of support for Versions and Revisions in Azure API Management! This…
I hope this was useful.