You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/getting_started.md
+139-2Lines changed: 139 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,10 +14,147 @@ If you already have Azure DevOps account, create a new project.
14
14
15
15
### 3. Create Service Principal to Login to Azure and create resources
16
16
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
+
-
18
24
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.
20
26
21
27
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
22
34
35
+
We noted the value of these variables in previous steps.
23
36
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**
5. On the Select option page, select the GitHub repository where you forked the code.
65
+

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
+

69
+
70
+
7. Your build run would look similar to the following image
71
+

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**
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.
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.
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.
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.
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**
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.
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.
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.
- 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.
- 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.
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.
0 commit comments