Safwan Masarik
Safwan Masarik

Reputation: 131

Do we need multiple Azure API management instances? for DEV, UAT, PROD environment? [yes we do. contains solution]

Do we need multiple Azure API management instances? for DEV, UAT, PROD environment? If we do, then how do we source control the dev instance and release it to uat & prod programmatically. My findings on the net and own practice can be summarized as:-

  1. Source control for the dev instance can be obtained, however pushing the same instance to uat apim instance will result in key error, hence the source code for dev apim instance can only be used by dev instance.
  2. Many developer opt to  go to generate the OpenAPI template  from dev apim instance, then import this OpenAPI template into uat apim instance. This still results in manual updates for the backend routing for all the apis (if u got 100 api, wow thats a lot of copy pasting and update to uat api routing).

Upvotes: 4

Views: 2315

Answers (2)

silent
silent

Reputation: 16108

"do you need multiple instances"? Technically no, you can all do in one instance.

Would I advise you to seperate instances and have dedicated ones per env? Oh yes! (this btw, applies to basically to any component). To save on costs you can probably use Developer SKU for all but prod (depending on what you do on UAT, of course).

How to carry changes from dev to the other stages: This is a topic with many possible ways. What I have implemented in the past in the following:

  • Developers wanted to use Dev to make manual changes and try them out until they were satisfied.
  • We used the Git integration on all instances. Once changes on Dev were ready to move to UAT/Test, a commit in the integrated Git was done. This triggered a workflow which would pull the latest version from Dev and push it into the Git repo of UAT.
  • Do the same for Prod (from UAT) once ready to go live.

Upvotes: 2

Safwan Masarik
Safwan Masarik

Reputation: 131

I've managed to solve this. Guide is below. Special thanks to silent for pointing to me to the right direction.

Setup API Management for source control release

Glossary Meaning
pt..5..apim01 Development api management instance
pt..4..apim01 UAT api management instance
https://pt..5..func01.azurewebsites.net/api Development azure function endpoint
https://pt..4..func01.azurewebsites.net/api UAT azure function endpoint
  1. In dev API management, if this azure function backend exist, then delete it.

Note*: This az function backend was automatically created when linking the Azure Function and API Management within Azure Function API tab. This is not useful when we opt for custom front-end api endpoint.

dev apim backend

  1. These azure function key should also be removed, it came together when linking Azure Function and API Management within Azure Function API tab.

Having this key here will prevent source control deployment. You will have error like these (will show deployment in later steps).

key not found

delete azure function key in named values

  1. Add a function endpoint named values.

Named values is like global variables.

  • coz my reputation here is still noob, SO does not allow me to upload more images. will update images when I can, for now trust your imaginations.
  1. Update api backend redirect with the named value.
  • From this, pic 1

  • To this, pic 2

  1. Now for source control deployment, go to the Repository tab in Dev APIM.
  • pic 1 (Save to Repository)
  1. Generate credential and Clone the repo to local.
  • pic 1 (Access Credential)
  • pic 2 (Generate Password)
  • pic 3 (Clone the repo to your local machine)
  1. Clone the repo for both dev and uat environment, to your local machine with steps above. Final folder structure like below:-
Directory: C:\..\repos\MY_APIM

pt..4..apim01.scm.azure-api.net
pt..5..apim01.scm.azure-api.net
  1. Now copy the content of dev folder and paste/replace the contents in uat folder.

  2. Git Push the changes to UAT apim master branch

  3. Make sure same named values are created in UAT apim, with right values.

  • pic 1 (the function-endpoint variable we created)
  1. Now in uat apim, perform Deploy to API Management. This will deploy the changes we recently pushed to api uat master branch.
  • pic 1 (Deploy to API Management)
  1. Upon successful deployment.
  • pic 1 (Successful deployment)

Upvotes: 2

Related Questions