Skip to content

Commit 00028a9

Browse files
Merge pull request #270698 from RoseHJM/ade-azd-how-to
ADE - AZD how-to
2 parents 85127da + 906891b commit 00028a9

13 files changed

+233
-3
lines changed
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
---
2+
title: Configure Azure Developer CLI templates for use with ADE
3+
description: Understand how ADE and AZD work together to provision application infrastructure and deploy application code to the new infrastructure.
4+
author: RoseHJM
5+
ms.author: rosemalcolm
6+
ms.service: dev-box
7+
ms.topic: how-to
8+
ms.date: 03/26/2024
9+
10+
# Customer intent: As a platform engineer, I want to use ADE and AZD together to provision application infrastructure and deploy application code to the new infrastructure.
11+
12+
---
13+
14+
# Configure Azure Developer CLI with Azure Deployment Environments
15+
16+
In this article, you create a new environment from an existing Azure Developer CLI (AZD) compatible template by using AZD. You learn how to configure Azure Deployment Environments (ADE) and AZD to work together to provision application infrastructure and deploy application code to the new infrastructure.
17+
18+
To learn the key concepts of how AZD and ADE work together, see [Use Azure Developer CLI with Azure Deployment Environments](concept-azure-developer-cli-with-deployment-environments.md).
19+
20+
## Prerequisites
21+
22+
- Create and configure a dev center with a project, environment types, and catalog. Use the following article as guidance:
23+
- [Quickstart: Create and configure a dev center for Azure Deployment Environments](/azure/deployment-environments/quickstart-create-and-configure-devcenter).
24+
25+
## Attach Microsoft quick start catalog
26+
27+
Microsoft provides a quick start catalog that contains a set of AZD compatible templates that you can use to create environments. You can attach the quick start catalog to your dev center at creation or add it later. The quick start catalog contains a set of templates that you can use to create environments.
28+
29+
## Examine an AZD compatible template
30+
31+
You can use an existing AZD compatible template to create a new environment, or you can add an azure.yaml file to your repository. In this section, you examine an existing AZD compatible template.
32+
33+
AZD provisioning for environments relies on curated templates from the catalog. Templates in the catalog might assign tags to provisioned Azure resources for you to associate your app services with in the azure.yaml file, or specify the resources explicitly. In this example, resources are specified explicitly.
34+
35+
For more information on tagging resources, see [Tagging resources for Azure Deployment Environments](/azure/developer/azure-developer-cli/ade-integration#tagging-resources-for-azure-deployment-environments).
36+
37+
1. In the [Azure portal](https://portal.azure.com), navigate to your dev center.
38+
39+
1. In the left menu under **Environment configuration**, select **Catalogs**, and then copy the quick start catalog **Clone URL**.
40+
41+
:::image type="content" source="media/how-to-configure-azure-developer-cli-deployment-environments/catalog-url.png" alt-text="Screenshot of Azure portal showing the catalogs attached to a dev center, with clone URL highlighted." lightbox="media/how-to-configure-azure-developer-cli-deployment-environments/catalog-url.png":::
42+
43+
1. To view the quick start catalog in GitHub, paste the **Clone URL** into the address bar and press Enter.
44+
45+
1. In the GitHub repository, navigate to the **Environment-Definitions/ARMTemplates/Function-App-with-Cosmos_AZD-template** folder.
46+
47+
1. Open the **environment.yaml** file. At the end of the file, you see the allowed repositories that contain sample application source code.
48+
49+
:::image type="content" source="media/how-to-configure-azure-developer-cli-deployment-environments/application-source-templates.png" alt-text="Screenshot of GitHub repository, showing the environment.yaml file with source templates highlighted." lightbox="media/how-to-configure-azure-developer-cli-deployment-environments/application-source-templates.png":::
50+
51+
1. Copy the **https://github.com/azure-samples/todo-python-mongo-swa-func** repository URL, and then navigate to the repository in GitHub.
52+
53+
1. In the root of the repository, open the **azure.yaml** file.
54+
55+
1. In the azure.yaml file, in the **services** section, you see the **web** and **API** services that are defined in the template.
56+
57+
> [!NOTE]
58+
> Not all AZD compatible catalogs use the linked templates structure shown in the example. You can use a single catalog for all your environments by including the azure.yaml file. Using multiple catalogs and code repositories allows you more flexibility in configuring secure access for platform engineers and developers.
59+
60+
If you're working with your own catalog & environment definition, you can create an azure.yaml file in the root of your repository. Use the azure.yaml file to define the services that you want to deploy to the environment.
61+
62+
## Create an environment from an existing template
63+
64+
Use an existing AZD compatible template to create a new environment.
65+
66+
### Prepare to work with AZD
67+
68+
When you work with AZD for the first time, there are some one-time setup tasks you need to complete. These tasks include installing the Azure Developer CLI, signing in to your Azure account, and enabling AZD support for Azure Deployment Environments.
69+
70+
#### Install the Azure Developer CLI extension for Visual Studio Code
71+
72+
When you install AZD, the AZD tools are installed within an AZD scope rather than globally, and are removed if AZD is uninstalled. You can install AZD in Visual Studio Code or from the command line.
73+
74+
# [Visual Studio Code](#tab/visual-studio-code)
75+
76+
To enable Azure Developer CLI features in Visual Studio Code, install the Azure Developer CLI extension, version v0.8.0-alpha.1-beta.3173884. Select the **Extensions** icon in the Activity bar, search for **Azure Developer CLI**, and then select **Install**.
77+
78+
:::image type="content" source="media/how-to-create-environment-with-azure-developer/install-azure-developer-cli-small.png" alt-text="Screenshot of Visual Studio Code, showing the Sign in command in the command palette." lightbox="media/how-to-create-environment-with-azure-developer/install-azure-developer-cli-large.png":::
79+
80+
# [Azure Developer CLI](#tab/azure-developer-cli)
81+
82+
83+
```bash
84+
powershell -ex AllSigned -c "Invoke-RestMethod 'https://aka.ms/install-azd.ps1' | Invoke-Expression"
85+
```
86+
---
87+
88+
#### Sign in with Azure Developer CLI
89+
90+
Access your Azure resources by logging in. When you initiate a log in, a browser window opens and prompts you to log in to Azure. After you sign in, the terminal displays a message that you're signed in to Azure.
91+
92+
Sign in to AZD using the command palette:
93+
94+
# [Visual Studio Code](#tab/visual-studio-code)
95+
96+
:::image type="content" source="media/how-to-create-environment-with-azure-developer/azure-developer-sign-in.png" alt-text="Screenshot of Visual Studio Code, showing the Extensions pane with the Azure Developer CLI and Install highlighted." lightbox="media/how-to-create-environment-with-azure-developer/azure-developer-sign-in.png":::
97+
98+
The output of commands issued from the command palette is displayed in an **azd dev** terminal like the following example:
99+
100+
:::image type="content" source="media/how-to-create-environment-with-azure-developer/press-any-key.png" alt-text="Screenshot of the AZD developer terminal, showing the press any key to close message." lightbox="media/how-to-create-environment-with-azure-developer/press-any-key.png":::
101+
102+
# [Azure Developer CLI](#tab/azure-developer-cli)
103+
104+
Sign in to Azure at the CLI using the following command:
105+
106+
```bash
107+
azd auth login
108+
```
109+
110+
:::image type="content" source="media/how-to-create-environment-with-azure-developer/login.png" alt-text="Screenshot showing the azd auth login command and its result in the terminal." lightbox="media/how-to-create-environment-with-azure-developer/login.png":::
111+
112+
---
113+
114+
#### Enable AZD support for ADE
115+
116+
When `platform.type` is set to `devcenter`, all AZD remote environment state and provisioning uses dev center components. AZD uses one of the infrastructure templates defined in your dev center catalog for resource provisioning. In this configuration, the *infra* folder in your local templates isn’t used.
117+
118+
# [Visual Studio Code](#tab/visual-studio-code)
119+
120+
:::image type="content" source="media/how-to-create-environment-with-azure-developer/azure-developer-enable-support.png" alt-text="Screenshot of Visual Studio Code, showing the Enable support command in the command palette." lightbox="media/how-to-create-environment-with-azure-developer/azure-developer-enable-support.png":::
121+
122+
# [Azure Developer CLI](#tab/azure-developer-cli)
123+
124+
```bash
125+
azd config set platform.type devcenter
126+
```
127+
---
128+
129+
### Create a new environment
130+
131+
Now you're ready to create an environment to work in. You begin with an existing template. ADE defines the infrastructure for your application, and the AZD template provides sample application code.
132+
133+
# [Visual Studio Code](#tab/visual-studio-code)
134+
135+
1. In Visual Studio Code, open an empty folder.
136+
137+
1. Open the command palette, enter *Azure Developer CLI init*, and then from the list, select **Azure Developer CLI (azd): init**.
138+
139+
:::image type="content" source="media/how-to-create-environment-with-azure-developer/command-palette-azure-developer-initialize.png" alt-text="Screenshot of the Visual Studio Code command palette with Azure Developer CLI (azd): init highlighted." lightbox="media/how-to-create-environment-with-azure-developer/command-palette-azure-developer-initialize.png":::
140+
141+
1. In the list of templates, select **Function-App-with-Cosmos_AZD-template**.
142+
143+
:::image type="content" source="media/how-to-configure-azure-developer-cli-deployment-environments/command-palette-functionapp-template.png" alt-text="Screenshot of the Visual Studio Code command palette with a list of templates, Function App highlighted." lightbox="media/how-to-configure-azure-developer-cli-deployment-environments/command-palette-functionapp-template.png":::
144+
145+
1. In the AZD terminal, enter an environment name.
146+
147+
:::image type="content" source="media/how-to-configure-azure-developer-cli-deployment-environments/enter-environment-name.png" alt-text="Screenshot of the Azure Developer terminal, showing prompt for a new environment name." lightbox="media/how-to-configure-azure-developer-cli-deployment-environments/enter-environment-name.png":::
148+
149+
1. Select a project.
150+
151+
:::image type="content" source="media/how-to-configure-azure-developer-cli-deployment-environments/initialize-select-project.png" alt-text="Screenshot of the Azure Developer terminal, showing prompt to select a project." lightbox="media/how-to-configure-azure-developer-cli-deployment-environments/initialize-select-project.png":::
152+
153+
1. Select an environment definition.
154+
155+
:::image type="content" source="media/how-to-configure-azure-developer-cli-deployment-environments/initialize-select-environment-definition.png" alt-text="Screenshot of the Azure Developer terminal, showing prompt to select an environment definition." lightbox="media/how-to-configure-azure-developer-cli-deployment-environments/initialize-select-environment-definition.png":::
156+
157+
AZD creates the project resources, including an *azure.yaml* file in the root of your project.
158+
159+
160+
# [Azure Developer CLI](#tab/azure-developer-cli)
161+
162+
1. At the CLI, navigate to an empty folder.
163+
164+
1. To list the templates available, in the AZD terminal, run the following command:
165+
166+
```bash
167+
azd template list
168+
169+
```
170+
Multiple templates are available. You can select the template that best fits your needs, depending on the application you want to build and the language you want to use.
171+
172+
:::image type="content" source="media/how-to-configure-azure-developer-cli-deployment-environments/developer-cli-template-list.png" alt-text="Screenshot of the Azure Developer terminal, showing the templates available." lightbox="media/how-to-configure-azure-developer-cli-deployment-environments/developer-cli-template-list.png":::
173+
174+
1. Run the following command to initialize your application and supply information when prompted:
175+
176+
```bash
177+
azd init
178+
```
179+
1. In the AZD terminal, enter an environment name.
180+
181+
:::image type="content" source="media/how-to-configure-azure-developer-cli-deployment-environments/enter-environment-name.png" alt-text="Screenshot of the Azure Developer terminal, showing prompt for a new environment name." lightbox="media/how-to-configure-azure-developer-cli-deployment-environments/enter-environment-name.png":::
182+
183+
1. Select a project.
184+
185+
:::image type="content" source="media/how-to-configure-azure-developer-cli-deployment-environments/initialize-select-project.png" alt-text="Screenshot of the Azure Developer terminal, showing prompt to select a project." lightbox="media/how-to-configure-azure-developer-cli-deployment-environments/initialize-select-project.png":::
186+
187+
1. Select an environment definition.
188+
189+
:::image type="content" source="media/how-to-configure-azure-developer-cli-deployment-environments/initialize-select-environment-definition.png" alt-text="Screenshot of the Azure Developer terminal, showing prompt to select an environment definition." lightbox="media/how-to-configure-azure-developer-cli-deployment-environments/initialize-select-environment-definition.png":::
190+
191+
AZD creates the project resources, including an *azure.yaml* file in the root of your project.
192+
193+
---
194+
195+
## Configure your devcenter
196+
197+
You can define AZD settings for your dev centers so that you don't need to specify them each time you update an environment. In this example, you define the names of the catalog, dev center, and project that you're using for your environment.
198+
199+
1. In Visual Studio Code, navigate to the *azure.yaml* file in the root of your project.
200+
201+
1. In the azure.yaml file, add the following settings:
202+
203+
```yaml
204+
platform:
205+
type: devcenter
206+
config:
207+
catalog: MS-cat
208+
name: Contoso-DevCenter
209+
project: Contoso-Dev-project
210+
```
211+
212+
:::image type="content" source="media/how-to-configure-azure-developer-cli-deployment-environments/azure-yaml-dev-center-settings.png" alt-text="Screenshot of the azure.yaml file with dev center settings highlighted." lightbox="media/how-to-configure-azure-developer-cli-deployment-environments/azure-yaml-dev-center-settings.png":::
213+
214+
To learn more about the settings you can configure, see [Configure dev center settings](/azure/developer/azure-developer-cli/ade-integration#configure-dev-center-settings).
215+
216+
## Provision your environment
217+
218+
You can use AZD to provision and deploy resources to your deployment environments using commands like `azd up` or `azd provision`.
219+
220+
To learn more about provisioning your environment, see [Create an environment by using the Azure Developer CLI](how-to-create-environment-with-azure-developer.md#provision-infrastructure-to-azure-deployment-environment).
221+
222+
To how common AZD commands work with ADE, see [Work with Azure Deployment Environments](/azure/developer/azure-developer-cli/ade-integration?branch=main#work-with-azure-deployment-evironments).
223+
224+
225+
## Related content
226+
227+
- [Add and configure an environment definition](./configure-environment-definition.md)
228+
- [Create an environment by using the Azure Developer CLI](./how-to-create-environment-with-azure-developer.md)

articles/deployment-environments/how-to-create-environment-with-azure-developer.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ In this article, you install the Azure Developer CLI (AZD), create a new deploym
1919

2020
Azure Developer CLI (AZD) is an open-source tool that accelerates the time it takes for you to get your application from local development environment to Azure. AZD provides best practice, developer-friendly commands that map to key stages in your workflow, whether you’re working in the terminal, your editor or integrated development environment (IDE), or CI/CD (continuous integration/continuous deployment).
2121

22-
<!-- To learn how to set up AZD to work with Azure Deployment Environments, see [Use Azure Developer CLI with Azure Deployment Environments](/azure/deployment-environments/concept-azure-developer-cli-with-deployment-environments). -->
22+
To learn how to set up AZD to work with Azure Deployment Environments, see [Use Azure Developer CLI with Azure Deployment Environments](/azure/deployment-environments/concept-azure-developer-cli-with-deployment-environments).
2323

2424
## Prerequisites
2525

@@ -141,7 +141,7 @@ AZD uses an *azure.yaml* file to define the environment. The azure.yaml file def
141141

142142
# [Visual Studio Code](#tab/visual-studio-code)
143143

144-
1. In Visual Studio Code, and then open the folder that contains your application code.
144+
1. In Visual Studio Code, open the folder that contains your application code.
145145

146146
1. Open the command palette, and enter *Azure Developer CLI init*, then from the list, select **Azure Developer CLI (azd): init**.
147147

@@ -448,4 +448,4 @@ azd down --environment <environmentName>
448448
## Related content
449449
- [Create and configure a dev center](/azure/deployment-environments/quickstart-create-and-configure-devcenter)
450450
- [What is the Azure Developer CLI?](/azure/developer/azure-developer-cli/overview)
451-
- [Install or update the Azure Developer CLI](/azure/developer/azure-developer-cli/install-azd)
451+
- [Install or update the Azure Developer CLI](/azure/developer/azure-developer-cli/install-azd)
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)