- Print
- DarkLight
- PDF
Step 6 - Making changes and deploying APIM - Local Development
In this section we will discuss some of the APIM changes and development cycle. I think there will be some cases where you API may require a few different steps to the one I have. I am working with an API which is moderately complex but not overly so.
For me there are 2 API's and 2 products. Each product has an API. For the API's I have implemented the policy at API level rather than operation or product level. There will be scenarios where you need different combinations of these.
In the below picture you can see I have a Visual Studio project which contains files for my API. Although i have obscured some of the naming for the files there is basically:
- 2 x XML files which contain the policy for the API
- 2 x Swagger files which contain the API definition
The idea is as follows:
- Terraform will setup my APIM instance
- Terraform will create my API's and import the json files to build them
- Terraform import the API policy files
- I will edit my API through the Azure portal and then export the policy and API definition files and save them in my Visual Studio solution
- Terraform will create my API products and assign API's to them
There are a few things I will do manually because they are difficult or not supported to automate and there isnt huge value in trying to figure out how to automate them.
The first of these is the API product subscriptions. I think with the APIM consumption tier there may be a difference in the management API for this. There are Terraform tasks to setup users and subscriptions. They work ok on the development tier but I had some problems on the consumption tier. My workaround for this was that after the first build of the infrastructure because Terraform would be managing the state and deploying changes I would choose to just setup the users and subscriptions manually as I expected this to be a one off activity.
At this point I should now be in a position where I edit the APIM in my development instance. I export changes to Visual Studio and I can rerun Terraform to check the changes can be deployed ok.
In my APIM policy I am injecting the header to add the function key we created in step 2 so my APIM can forward calls to the function app and also using the url rewrite as required to map operations. Below is an example of this.