Skip to content

Commit bf2c697

Browse files
committed
Merge branch 'master' of https://github.com/Microsoft/DevOpsForAI into develop
2 parents 91abe12 + 5216af8 commit bf2c697

21 files changed

+142
-59
lines changed

docs/getting_started.md

Lines changed: 139 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,147 @@ If you already have Azure DevOps account, create a new project.
1414

1515
### 3. Create Service Principal to Login to Azure and create resources
1616

17-
To create service principal, register an application entity in Azure Active Directory (Azure AD) and grant it the Contributor or Owner role of the subscription or the resource group where the web service belongs to. See [how to create service principal](https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal) and assign permissions to manage Azure resource
17+
To create service principal, register an application entity in Azure Active Directory (Azure AD) and grant it the Contributor or Owner role of the subscription or the resource group where the web service belongs to. See [how to create service principal](https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal) and assign permissions to manage Azure resource.
18+
Please make note the following values after creating a service principal, we will need them in subsequent steps
19+
- Azure subscription id (subscriptionid)
20+
- Service principal username (spidentity)(application id)
21+
- Service principal password (spsecret) (auth_key)
22+
- Service principal tenant id (sptenant)
23+
-
1824

19-
**Note:** You must have sufficient permissions to register an application with your Azure AD tenant, and assign the application to a role in your Azure subscription. Contact your subscription adminstator if you don't have the permissions. Normally a subscription admin will create a Service principal and will provide you the details.
25+
**Note:** You must have sufficient permissions to register an application with your Azure AD tenant, and assign the application to a role in your Azure subscription. Contact your subscription adminstator if you don't have the permissions. Normally a subscription admin can create a Service principal and can provide you the details.
2026

2127

28+
### 4. Store secret in Key Vault and link it as variable group in Azure DevOps to be used by piplines.
29+
Our pipeline require the following variables to autheticate with Azure.
30+
- spidentity
31+
- spsecret
32+
- sptenant
33+
- subscriptionid
2234

35+
We noted the value of these variables in previous steps.
2336

37+
**NOTE:** These values should be treated as secret as they allow access to your subscription.
38+
39+
We make use of variable group inside Azure DevOps to store variables and their values that we want to make available across multiple pipelines. You can either store the values directly here or connect to an Azure Key Vault in your subscription. Please refer to the documentation [here](https://docs.microsoft.com/en-us/azure/devops/pipelines/library/variable-groups?view=azure-devops&tabs=yaml#link-secrets-from-an-azure-key-vault) to learn more about how to create a variable group and [link](https://docs.microsoft.com/en-us/azure/devops/pipelines/library/variable-groups?view=azure-devops&tabs=designer#link-secrets-from-an-azure-key-vault) it to your pipeline.
40+
41+
Please name your variable group **AzureKeyVaultSecrets**, we are using this name within our build yaml file.
42+
43+
Up until now you shouls have
44+
- forked (or cloned) the repo,
45+
- created a devops account or use an existing one
46+
- got service principal details and subscription id.
47+
- set them as variable group within devops.
48+
49+
We now have 3 pipelines that we would set up
50+
- Build Pipeline (azure-pipelines.yml): Runs tests and sets up infrastructure
51+
- Retraining trigger pipeline(/template/retraining-template.json): This pipeline submits a pipeline job to Azure ML Pipelines and trains a new model and publishes image, if new model is better after evaluation.
52+
- Release pipeline(/template/release-template.json) : This pipeline releases our image and deploys it to QA and Prod environment.
53+
54+
55+
56+
### 5. Set up Build Pipeline
57+
1. Select your devops organization and project by clicking dev.azure.com
58+
2. Once you are in the right devops project, click Pipelines on the left hand menu and select Builds
59+
3. In the Build Menu, click **New** dropdown and then select **New build pipeline**
60+
![new build pipeline](./images/new-build-pipeline.png)
61+
4. On the Connect option page, select **GitHub**
62+
![build connnect step](./images/build-connect.png)
63+
64+
5. On the Select option page, select the GitHub repository where you forked the code.
65+
![select repo](./images/build-selectrepo.png)
66+
67+
6. Since the repository contains azure-pipelines.yml at the root level, Azure DevOps recognizes it and auto imports it. Click run and this will start the build pipeline.
68+
![select repo](./images/build-createpipeline.png)
69+
70+
7. Your build run would look similar to the following image
71+
![select repo](./images/build-run.png)
72+
73+
Great, you now have the build pipeline setup, you can either manually trigger it or it gets automatically triggered everytime there is a change in the master branch.
74+
75+
### 6. Set up Retraining trigger release pipeline
76+
77+
**Note:** For setting up release pipelines, first download the [release-pipelines](../release-pipelines) to your local filesystem so you can import it.
78+
79+
1. Select the Release tab from the menu on the left, then click the New dropdown on top and click on **Import Release pipeline**
80+
![import release pipeline](./images/release-import.png)
81+
82+
1. On the next screen, navigate to release-pipelines folder and select retrainingtrigger.json pipeline file, click import. You should now see the following screen. Under Stages click on the Retrain stage, where it shows the red error sign.
83+
![release retraining triggger](./images/release-retrainingtrigger.png)
84+
85+
Click on agent job and then from the drop down for Agent Pool on the right side select **Hosted Ubuntu 1604** agent to execute your run and click **Save** button on top right.
86+
![release retraining agent](./images/release-retrainingagent.png)
87+
88+
1. We want the retraining pipeline to be triggered every time build pipeline is complete. To create this dependency, we will link the artifact from build pipeline as a trigger for retraining trigger release pipeline. To do so, click on the pipeline tab and then hit **Add an artifact** option under Artifacts.
89+
![release pipeline view](./images/release-retrainingpipeline.png)
90+
91+
1. This will open up a pop up window, on this screen:
92+
- for source type, select **Build**
93+
- for project, select your project in Azure DevOps that you created in previous steps.
94+
- For Source select the source build pipeline.
95+
- Other fields will get auto populated, you can leave them as it is.
96+
![release retraining artifact](./images/release-retrainingartifact.png)
97+
98+
1. Artifact is now added for retraining trigger pipeline, hit the **save** button on top right and then click **ok**. You now have the retraining trigger pipeline all set up and it will get executed everytime your build pipeline finishes its run. If you want to run this pipeline on a schedule, you can set one by clicking on **Schedule set** in Artifacts section.
99+
![release retraining artifact](./images/release-retrainingartifactsuccess.png)
100+
101+
To view the newly created pipeline, click on the release tab on the left hand side and it will show the retraining trigger pipeline.
102+
103+
### 7. Set up release (Deployment) pipeline
104+
105+
**Note:** For setting up release pipelines, first download the [release-pipelines](../release-pipelines) to your local filesystem so you can import it.
106+
107+
**Also Note:** Before creating this pipeline, make sure that the build pipeline and retraining trigger release pipeline have been executed, as they will be creating resources during their run like docker images that we will deploy as part of this pipeline. So it is important for them to have successful runs before the setup here.
108+
109+
Let's set up the release deployment pipeline now.
110+
1. As done in previous step, Select the Release tab from the menu on the left, then click the New dropdown on top and click on **Import Release pipeline**
111+
![import release pipeline](./images/release-import.png)
112+
113+
1. On the next screen, navigate to release-pipelines folder and select **releasedeployment.json** pipeline file, click import. You should now see the following screen. Under Stages click on the QA environment's **view stage task", where it shows the red error sign.
114+
![release retraining triggger](./images/release-deployment.png)
115+
116+
Click on agent job and then from the drop down for Agent Pool on the right side select **Hosted Ubuntu 1604** agent to execute your run and click **Save** button on top right.
117+
![release retraining agent](./images/release-deploymentqaagent.png)
118+
119+
Follow the same steps for **Prod Environment** and select **Hosted Ubuntu 1604** for agent pool and save the pipeline.
120+
![release retraining agent](./images/release-deploymentprodagent.png)
121+
122+
1. We now need to add artifact that will trigger this pipeline, it gets triggered everytime there is a new image that gets published to Azure container registry (ACR) as part of retraining pipeline. We will also add our build output as artifact since that contains our configuration and code files that we require in this pipeline.
123+
124+
![release retraining agent](./images/release-deploymentacr.png)
125+
126+
Here are the steps to add ACR as an artifact
127+
- Click on pipeline tab to go back to pipeline view and click **Add an artifact**. This will open a pop up window
128+
- For Source type, click on **more artifact types** dropdown and select **Azure Container Registry**
129+
- For service connection, select an existing service connection to Azure, if you don't see anything in the dropdown, click on Manage and create one.
130+
**Note:** You must have sufficient privileges to create a service connection, if not contact your subscription adminstrator.
131+
- For Resource Group, select **DevOps_AzureML_Demo**, this is the default resource group name that we are using and if the previous pipelines executed properly you will see this resource group in the drop down.
132+
- Under Azure container registry dropdown, select the container registry, there should be only one container registry entry.
133+
- For repository, select **diabetes-model-score** repository.
134+
- For Default version, keep it to **latest**
135+
- For Source alias, keep the default generated name.
136+
- Click Add
137+
- Click on lighting sign to enable the **Continous Deployment Trigger**, click Save.
138+
![release retraining artifact](./images/release-deploymentcitrigger.png)
139+
140+
Here are the steps to add build output as artifact
141+
![release retraining artifact](./images/release-retrainingartifact.png)
142+
- Click on pipeline tab to go back to pipeline view and click **Add an artifact**. This will open a pop up window
143+
- For source type, select **Build**
144+
- For project, select your project in Azure DevOps that you created in previous steps.
145+
- For Source, select the source build pipeline.
146+
- Other fields will get auto populated, you can leave them as it is.
147+
148+
149+
1. We now have QA environment continously deployed each time there is a new image available in container registry. You can select pre-deployment conditions for prod environment, normally you don't want it to be auto deployed, so select manual only trigger here.
150+
151+
![release retraining artifact](./images/release-deploymentprodtrigger.png)
152+
153+
To deploy a release manually, follow the document [here](https://docs.microsoft.com/en-us/azure/devops/pipelines/get-started-designer?view=azure-devops&tabs=new-nav#deploy-a-release)
154+
155+
156+
Congratulations, you now have three pipelines set up end to end.
157+
- Build pipeline: triggered on code change to master branch on GitHub.
158+
- Release Trigger pipeline: triggered on build pipeline execution and produces a new model image if better than previous one.
159+
- Release Deployment pipeline: QA environment is auto triggered when there is a new image.
160+
Prod is manual only and user decides when to release to this environment.

docs/images/build-connect.png

169 KB
Loading
205 KB
Loading

docs/images/build-run.png

216 KB
Loading

docs/images/build-selectrepo.png

92.9 KB
Loading

docs/images/new-build-pipeline.png

147 KB
Loading

docs/images/release-deployment.png

165 KB
Loading
263 KB
Loading
203 KB
Loading
211 KB
Loading

0 commit comments

Comments
 (0)