Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 470ad26

Browse files
SSanjeeviodaibertRupengLiu
authored
Parameterized API URLs, App insights, NamedValues environment specific for Creator Tool (#459)
* Azure DevOps Pipeline example * First commit release pipeline * Fixed some typos * Change image size to fit correct on github page. * Change images size. * Fixed image size * Added new images * Fixed images folder * Fixed typos * Fixed typos * Fixed typo * Added image files * Fixed title size * Added a reference to AzDO Pipeline example * Updated AzDO-Example.md * Pick changes from Concurrency changes * Added Feature to parameterize named values and application insights and backend url using cli inputs Features added: 1. Application insights parameterized. 2. named values parameterized. 3. API urls parameterized. * Update Architecture.png * fix build failure * Fixed merge issue * Added Read me file for newly added parameters Co-authored-by: Osvaldo Daibert <odaibert@microsoft.com> Co-authored-by: Rupeng Liu <rupliu@microsoft.com>
1 parent 6cd0961 commit 470ad26

39 files changed

+755
-137
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ We realize there are two challenges for API developers when working with Resourc
4343

4444
* Second, for customers who have already been using API Management, another challenge is how to extract existing configurations into Resource Manager templates. For those customers, We have created another tool called [**Extractor**](./src/APIM_ARMTemplate/README.md#extractor) to help them generate templates by extracting configurations from their exisitng API Management instances.
4545

46-
Once API developers have finished developing and testing an API, and have generated the API template, they can submit a pull request to merge the changes to the publisher repository. API publishers can validate the pull request and make sure the changes are safe and compliant. For example, they can check if only HTTPS is allowed to communicate with the API. Most of these validations can be automated as a step in the CI/CD pipeline. Once the changes are approved and merged successfully, API publishers can choose to deploy them to the Production instance either on schedule or on demand. The deployment of the templates can be automated using [Github Actions](https://github.com/Azure/apimanagement-devops-samples), [Azure Pipeline](https://docs.microsoft.com/en-us/azure/devops/pipelines/?view=azure-devops), [PowerShell](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-template-deploy), [Azure CLI](Azure-cli-example.md) or other tools.
46+
Once API developers have finished developing and testing an API, and have generated the API template, they can submit a pull request to merge the changes to the publisher repository. API publishers can validate the pull request and make sure the changes are safe and compliant. For example, they can check if only HTTPS is allowed to communicate with the API. Most of these validations can be automated as a step in the CI/CD pipeline. Once the changes are approved and merged successfully, API publishers can choose to deploy them to the Production instance either on schedule or on demand. The deployment of the templates can be automated using [Github Actions](https://github.com/Azure/apimanagement-devops-samples), [Azure Pipeline](https://docs.microsoft.com/en-us/azure/devops/pipelines/?view=azure-devops), [PowerShell](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-template-deploy), [Azure CLI](Azure-cli-example.md) or other tools. An example using Azure DevOps can be find [here](docs/AzDO-Example.md)
4747

4848
With this approach, the deployment of API changes into API Management instances can be automated and it is easy to promote changes from one environment to another. Since different API development teams will be working on different sets of API templates and files, it prevents interference between different teams.
4949

docs/AzDO-Example.md

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# Continuos Integration and Continuos Deployment using Azure DevOps
2+
3+
The following instructions demonstrate how to deploy the contents of this example repository using Azure DevOps Repos and Azure DevOps Pipelines.
4+
5+
## Pre-reqs
6+
7+
To execute this solution you will need:
8+
9+
- Azure DevOps Account
10+
- An Azure DevOps Repo configured ([how to configure an Azure DevOps Repo](https://docs.microsoft.com/en-us/azure/devops/repos/get-started/sign-up-invite-teammates?view=azure-devops))
11+
- Three API Management deployed (DEV, QA and PROD) ([how to deploy a Create a new Azure API Management service instance](https://docs.microsoft.com/en-us/azure/api-management/get-started-create-service-instance))
12+
- Some API(s) on your API Management ([Add an API manually](https://docs.microsoft.com/en-us/azure/api-management/add-api-manually))
13+
14+
## Architecture
15+
16+
![](images/Architecture.png)
17+
18+
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).
19+
20+
This is our Development API management. In general, developers will create their API\'s in one instance of APIM to test it.
21+
22+
Create your API's on API Management Development environment. ([How to create API's on API Management](https://docs.microsoft.com/en-us/azure/api-management/import-and-publish))
23+
24+
![](images/apim-dev.png)
25+
26+
## APIM DevOps Toolkit
27+
28+
**Running the Extractor**
29+
30+
After a developer creates and tests APIs in API management, it is time to extract those APIs using this DevOps Resource Kit.
31+
32+
Below are the steps to run the extractor from source code:
33+
34+
- Clone this repository and navigate to {path\_to\_folder}/src/APIM\_ARMTemplate/apimtemplate
35+
- Restore its packages using
36+
37+
```
38+
dotnet restore
39+
```
40+
41+
- Make sure you have signed in using Azure CLI and have switched to the subscription containing the API Management instance from which the configurations will be extracted.
42+
43+
```
44+
45+
az login
46+
47+
az account set \--subscription \<subscription\_id\>
48+
49+
```
50+
51+
**Extractor Arguments**
52+
53+
You have two choices when specifying your settings:
54+
55+
1\. By using a json file with key-values where the keys matches the table below. Use the \`extractorConfig\` argument:
56+
57+
\`extract \--extractorConfig c:/temp/extractSettings.json\`. [See more examples.](#extractorParameterFileExamples)
58+
59+
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\`.
60+
61+
For this example, we will only use the option \#2
62+
63+
So, run the application with:
64+
65+
```
66+
67+
dotnet run extract --sourceApimName <DEV-APIM-NAME> --destinationApimName <DESTINATION-APIM-NAME> --resourceGroup <RESOURCE-GROUP-NAME> --fileFolder c:\\temp\\apim-extract.
68+
69+
```
70+
71+
Where:
72+
73+
**DEV-APIM-NAME:** API Management where you created your API
74+
75+
**DESTINATION-APIM-NAME:** It\'s just a convention to set the DESTINATION-API-NAME in front of the generated files.
76+
77+
**RESOURCE-GROUP-NAME:** Resource group where the DEV-APIM-NAME is hosted.
78+
79+
***For more information on how to run the application and parameters, [go to this page](https://github.com/Azure/azure-api-management-devops-resource-kit/blob/master/src/APIM_ARMTemplate/README.md#extractor).***
80+
81+
After executing the command above, you will see something similar to this:
82+
83+
![A screenshot of text Description automatically
84+
generated](images/extractor.png)
85+
86+
Then you see the json files extracted:
87+
88+
![A close up of text on a white background Description automatically
89+
generated](images/extracted-files.png)
90+
91+
Now, push them to your Azure DevOps Repo
92+
93+
```
94+
git push
95+
```
96+
97+
# Build Pipeline
98+
99+
We will use a **Build Pipeline** to pull the extracted files from a repo and put it on Azure DevOps Artefacts Folder.
100+
101+
1 - Add these tasks to your build:
102+
- Get Sources
103+
- Copy Publish Artifacts
104+
105+
2 - Configure the fields as show bellow:
106+
107+
![A screenshot of a cell phone Description automatically
108+
generated](images/build-pipeline1.png)
109+
110+
![A screenshot of a cell phone Description automatically
111+
generated](images/build-pipeline2.png)
112+
113+
# Release Pipeline
114+
115+
You can use [this](https://docs.microsoft.com/en-us/azure/devops/pipelines/release/?view=azure-devops) document as a reference on how to create a release pipeline.
116+
117+
1 - Add an [**Azure Deployment tasks**](https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-resource-group-deployment?view=azure-devops) for each file generated by extractor, following the order:
118+
119+
```
120+
- Products.template.json
121+
- Tags.template.json
122+
- namedValues.template.json
123+
- apis.template.json
124+
- globalServicePolice.template.json
125+
```
126+
127+
2 - Set "Override template parameters" field with "-ApimServiceName \<QA-APIM-NAME>\"
128+
129+
3 - Set set [Deployment mode to Incremental](https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/deployment-tutorial-pipeline#create-a-devops-project)
130+
131+
![](images/release-qa-parameters.png)
132+
133+
When you finish the steps above, you will see something like this:
134+
135+
![](images/deploy-qa.png)
136+
137+
Clone your QA environment and update the **Resource Group** and **ApimServiceName** value on "Override template parameters" field to reflect your "production" APIM.
138+
139+
![](images/release-prod.png)
140+
141+
Now you will see your Release Pipeline like this:
142+
143+
![](images/release-pipeline.png)
144+
145+
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](https://docs.microsoft.com/en-us/azure/devops/pipelines/release/deploy-using-approvals?view=azure-devops).

docs/images/Architecture.png

136 KB
Loading

docs/images/apim-dev-apis.png

89.6 KB
Loading

docs/images/apim-dev.png

39.5 KB
Loading

docs/images/architecture.png

136 KB
Loading

docs/images/build-parameters.png

27.9 KB
Loading

docs/images/build-pipeline1.png

29.6 KB
Loading

docs/images/build-pipeline2.png

40.3 KB
Loading

docs/images/buildpipeline.png

330 KB
Loading

0 commit comments

Comments
 (0)