Skip to content

Commit 1b4594a

Browse files
authored
Merge pull request #267880 from RoseHJM/ade-azdo-cicd
ADE - CICD with Azure DevOps
2 parents 3a3a37c + 2734177 commit 1b4594a

File tree

2 files changed

+209
-2
lines changed

2 files changed

+209
-2
lines changed

articles/deployment-environments/toc.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,17 @@ items:
7878
href: how-to-configure-deployment-environments-user.md
7979
- name: Authenticate to REST APIs
8080
href: how-to-authenticate.md
81-
- name: Automate with GitHub Actions (CI/CD)
82-
href: tutorial-deploy-environments-in-cicd-github.md
81+
- name: Automate with CI/CD
82+
expanded: false
83+
items:
84+
- name: Automate with GitHub Actions (CI/CD)
85+
displayName: cicd, GitHub repo
86+
href: tutorial-deploy-environments-in-cicd-github.md
87+
- name: Automate with Azure Pipelines (CI/CD)
88+
displayName: cicd, Azure DevOps, Azure Repos
89+
href: tutorial-deploy-environments-in-cicd-azure-devops.md
8390
- name: Reference
91+
expanded: false
8492
items:
8593
- name: Install Azure CLI extension
8694
href: how-to-install-devcenter-cli-extension.md
@@ -89,6 +97,7 @@ items:
8997
- name: REST API
9098
href: /rest/api/devcenter/
9199
- name: Resources
100+
expanded: false
92101
items:
93102
- name: Azure roadmap
94103
href: https://azure.microsoft.com/roadmap/
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
---
2+
title: 'Tutorial: Deploy environments with Azure Pipelines'
3+
description: Learn how to integrate Azure Deployment Environments into your Azure Pipelines CI/CD pipeline and streamline your software development process.
4+
author: RoseHJM
5+
ms.author: rosemalcolm
6+
ms.service: deployment-environments
7+
ms.topic: tutorial
8+
ms.date: 02/26/2024
9+
10+
# customer intent: As a developer, I want to use an Azure Pipeline to deploy an ADE deployment environment so that I can integrate it into a CI/CD development environment.
11+
---
12+
13+
# Tutorial: Deploy environments in CI/CD by using Azure Pipelines
14+
15+
In this tutorial, you learn how to integrate Azure Deployment Environments (ADE) into your Azure Pipelines CI/CD pipeline.
16+
17+
Continuous integration and continuous delivery (CI/CD) is a software development approach that helps teams to automate the process of building, testing, and deploying software changes. CI/CD enables you to release software changes more frequently and with greater confidence.
18+
19+
Before beginning this tutorial, familiarize yourself with Deployment Environments resources and concepts by reviewing [Key concepts for Azure Deployment Environments](concept-environments-key-concepts.md).
20+
21+
In this tutorial, you learn how to:
22+
23+
> [!div class="checklist"]
24+
> * Create and configure an Azure Repos repository
25+
> * Connect the catalog to your dev center
26+
> * Configure service connection
27+
> * Create a pipeline
28+
> * Create an environment
29+
> * Test the CI/CD pipeline
30+
31+
## Prerequisites
32+
33+
- An Azure account with an active subscription.
34+
- [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
35+
- Owner permissions on the Azure subscription.
36+
- An Azure DevOps subscription.
37+
- [Create an account for free](https://azure.microsoft.com/services/devops/?WT.mc_id=A261C142F).
38+
- An Azure DevOps organization and project.
39+
- Azure Deployment Environments.
40+
- [Dev center and project](./quickstart-create-and-configure-devcenter.md).
41+
- [Sample catalog](https://github.com/Azure/deployment-environments) attached to the dev center.
42+
43+
## Create and configure an Azure Repos repository
44+
45+
1. Sign in to your Azure DevOps organization (`https://dev.azure.com/<your-organization>`), and select your project. Replace the `<your-organization>` text placeholder with your project identifier.
46+
1. Select **Repos** > **Files**.
47+
1. In **Import a repository**, select **Import**.
48+
1. In **Import a Git repository**, select or enter the following:
49+
- **Repository type**: Git
50+
- **Clone URL**: https://github.com/Azure/deployment-environments
51+
52+
53+
## Configure environment types
54+
55+
Environment types define the different types of environments your development teams can deploy. You can apply different settings for each environment type. You create environment types at the dev center level and referenced at the project level.
56+
57+
Create dev center environment types:
58+
59+
1. Sign in to the [Azure portal](https://portal.azure.com).
60+
1. In **Dev centers**, select your dev center.
61+
1. In the left menu under **Environment configuration**, select **Environment types**, and then select **Create**.
62+
1. Use the following steps to create three environment types: Sandbox, FunctionApp, WebApp.
63+
In **Create environment type**, enter the following information, and then select **Add**.
64+
65+
|Name |Value |
66+
|---------|----------|
67+
|**Name**|Enter a name for the environment type.|
68+
|**Tags**|Enter a tag name and a tag value.|
69+
70+
1. Confirm that the environment type was added by checking your Azure portal notifications.
71+
72+
Create project environment types:
73+
74+
1. In the left menu under **Manage**, select **Projects**, and then select the project you want to use.
75+
1. In the left menu under **Environment configuration**, select **Environment types**, and then select **Add**.
76+
1. Use the following steps to add the three environment types: Sandbox, FunctionApp, WebApp.
77+
In **Add environment type to \<project-name\>**, enter or select the following information:
78+
79+
|Name |Value |
80+
|---------|----------|
81+
|**Type**| Select a dev center level environment type to enable for the specific project.|
82+
|**Deployment subscription**| Select the subscription in which the environment is created.|
83+
|**Deployment identity** | Select either a system-assigned identity or a user-assigned managed identity to perform deployments on behalf of the user.|
84+
|**Permissions on environment resources** > **Environment creator role(s)**| Select the roles to give access to the environment resources.|
85+
|**Permissions on environment resources** > **Additional access** | Select the users or Microsoft Entra groups to assign to specific roles on the environment resources.|
86+
|**Tags** | Enter a tag name and a tag value. These tags are applied on all resources that are created as part of the environment.|
87+
88+
1. Confirm that the environment type was added by checking your Azure portal notifications.
89+
90+
91+
## Configure a service connection
92+
93+
In Azure Pipelines, you create a *service connection* in your Azure DevOps project to access resources in your Azure subscription. When you create the service connection, Azure DevOps creates a Microsoft Entra service principal object.
94+
95+
1. Sign in to your Azure DevOps organization (`https://dev.azure.com/<your-organization>`), and select your project. Replace the `<your-organization>` text placeholder with your project identifier.
96+
1. Select **Project settings** > **Service connections** > **+ New service connection**.
97+
1. In the **New service connection** pane, select the **Azure Resource Manager**, and then select **Next**.
98+
1. Select the **Service Principal (automatic)** authentication method, and then select **Next**.
99+
1. Enter the service connection details, and then select **Save** to create the service connection.
100+
101+
| Field | Value |
102+
| ----- | ----- |
103+
| **Scope level** | *Subscription*. |
104+
| **Subscription** | Select the Azure subscription that hosts your dev center resource. |
105+
| **Resource group** | Select the resource group that contains your dev center resource. |
106+
| **Service connection name** | Enter a unique name for the service connection. |
107+
| **Grant access permission to all pipelines** | Checked. |
108+
109+
1. From the list of service connections, select the one you created earlier, and then select **Manage Service Principal**.
110+
The Azure portal opens in a separate browser tab and shows the service principal details.
111+
1. In the Azure portal, copy the **Display name** value.
112+
You use this value in the next step to grant permissions for running load tests to the service principal.
113+
114+
### Grant the service connection access to the ADE project
115+
116+
Azure Deployment Environments uses role-based access control to grant permissions for performing specific activities on your ADE resource. To make changes from a CI/CD pipeline, you grant the Deployment Environments User role to the service principal.
117+
118+
1. In the [Azure portal](https://portal.azure.com/), go to your ADE project.
119+
1. Select **Access control (IAM)** > **Add** > **Add role assignment**.
120+
1. In the **Role** tab, select **Deployment Environments User** in the list of job function roles.
121+
1. In the **Members** tab, select **Select members**, and then use the display name you copied previously to search the service principal.
122+
1. Select the service principal, and then select **Select**.
123+
1. In the **Review + assign tab**, select **Review + assign** to add the role assignment.
124+
125+
You can now use the service connection in your Azure Pipelines workflow definition to access your ADE environments.
126+
127+
### Grant your account access to the ADE project
128+
129+
To view environments created by other users, including the service connection, you need to grant your account read access to the ADE project.
130+
131+
1. In the [Azure portal](https://portal.azure.com/), go to your ADE project.
132+
1. Select **Access control (IAM)** > **Add** > **Add role assignment**.
133+
1. In the **Role** tab, select **Deployment Environments Reader** in the list of job function roles.
134+
1. In the **Members** tab, select **Select members**, and then search for your own account.
135+
1. Select your account from the list, and then select **Select**.
136+
1. In the **Review + assign tab**, select **Review + assign** to add the role assignment.
137+
138+
You can now view the environments created by your Azure Pipelines workflow.
139+
140+
## Configure a pipeline
141+
142+
Edit the `azure-pipelines.yml` file in your Azure Repos repository to customize your pipeline.
143+
144+
In the pipeline, you define the steps to create the environment. In this pipeline, you define the steps to create the environment as a job, which is a series of steps that run sequentially as a unit.
145+
146+
To customize the pipeline you:
147+
- Specify the Service Connection to use, and The pipeline uses the Azure CLI to create the environment.
148+
- Use an Inline script to run an Azure CLI command that creates the environment.
149+
150+
The Azure CLI is a command-line tool that provides a set of commands for working with Azure resources. To discover more Azure CLI commands, see [az devcenter](/cli/azure/devcenter?view=azure-cli-latest&preserve-view=true).
151+
152+
1. In your Azure DevOps project, select **Repos** > **Files**.
153+
1. In the **Files** pane, from the `.ado` folder, select `azure-pipelines.yml` file.
154+
1. In the `azure-pipelines.yml` file, edit the existing content with the following code:
155+
- Replace `<AzureServiceConnectionName>` with the name of the service connection you created earlier.
156+
- In the `Inline script`, replace each of the following placeholders with values appropriate to your Azure environment:
157+
158+
| Placeholder | Value |
159+
| ------------------------------- | ----- |
160+
| `<dev-center-name>` | The name of your dev center. |
161+
| `<project-name>` | The name of your project. |
162+
| `<catalog-name>` | The name of your catalog. |
163+
| `<environment-definition-name>` | Do not change. Defines the environment definition that is used. |
164+
| `<environment-type>` | The environment type. |
165+
| `<environment-name>` | Specify a name for your new environment. |
166+
| `<parameters>` | Do not change. References the json file that defines parameters for the environment. |
167+
168+
1. Select **Commit** to save your changes.
169+
1. In the **Commit changes** pane, enter a commit message, and then select **Commit**.
170+
171+
172+
## Create an environment using a pipeline
173+
174+
Next, you run the pipeline to create the ADE environment.
175+
176+
1. In your Azure DevOps project, select **Pipelines**.
177+
1. Select the pipeline you created earlier, and then select **Run pipeline**.
178+
1. You can check on the progress of the pipeline run by selecting the pipeline name, and then selecting **Runs**. Select the run to see the details of the pipeline run.
179+
1. You can also check the progress of the environment creation in the Azure portal by selecting your dev center, selecting your project, and then selecting **Environments**.
180+
181+
182+
You can insert this job anywhere in a Continuous Integration (CI) and/or a Continuous Delivery (CD) pipeline. Get started with the [Azure Pipelines documentation](/azure/devops/pipelines/?view=azure-devops&preserve-view=true) to learn more about creating and managing pipelines.
183+
184+
## Clean up resources
185+
186+
When you're done with the resources you created in this tutorial, you can delete them to avoid incurring charges.
187+
188+
Use the following command to delete the environment you created in this tutorial:
189+
190+
```azurecli
191+
az devcenter dev environment delete --dev-center <DevCenterName> --project-name <DevCenterProjectName> --name <DeploymentEnvironmentInstanceToCreateName> --yes
192+
```
193+
194+
## Related content
195+
196+
- [Install the devcenter Azure CLI extension](how-to-install-devcenter-cli-extension.md)
197+
- [Create and access an environment by using the Azure CLI](how-to-create-access-environments.md)
198+
- [Microsoft Dev Box and Azure Deployment Environments Azure CLI documentation](https://aka.ms/CLI-reference)

0 commit comments

Comments
 (0)