Skip to content

Commit b8a63e2

Browse files
authored
Merge pull request #265374 from nathaniel-msft/azd-quickstart
AKS & AZD Quickstart
2 parents ea62e96 + 9646660 commit b8a63e2

File tree

2 files changed

+201
-0
lines changed

2 files changed

+201
-0
lines changed

articles/aks/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
items:
3434
- name: Use the Azure CLI
3535
href: learn/quick-kubernetes-deploy-cli.md
36+
- name: Use the Azure Developer CLI
37+
href: learn/quick-kubernetes-deploy-azd.md
3638
- name: Use Azure PowerShell
3739
href: learn/quick-kubernetes-deploy-powershell.md
3840
- name: Use the Azure portal
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
---
2+
title: 'Quickstart: Deploy an Azure Kubernetes Service (AKS) cluster using Azure Developer CLI (AZD)'
3+
description: Learn how to quickly deploy a Kubernetes cluster and deploy an application in Azure Kubernetes Service (AKS) using the AZD CLI.
4+
ms.topic: quickstart
5+
ms.date: 02/06/2024
6+
ms.custom: H1Hack27Feb2017, mvc, devcenter, seo-javascript-september2019, seo-javascript-october2019, seo-python-october2019, devx-track-azurecli, contperf-fy21q1, mode-api, linux-related-content
7+
#Customer intent: As a developer or cluster operator, I want to deploy an AKS cluster and deploy an application so I can see how to run applications using the managed Kubernetes service in Azure.
8+
---
9+
10+
# Quickstart: Deploy an Azure Kubernetes Service (AKS) cluster using Azure Developer CLI (AZD)
11+
12+
Azure Kubernetes Service (AKS) is a managed Kubernetes service that lets you quickly deploy and manage clusters. In this quickstart, you learn to:
13+
14+
- Deploy an AKS cluster using the Azure CLI.
15+
- Run a sample multi-container application with a group of microservices simulating a retail app.
16+
17+
> [!NOTE]
18+
> To get started with quickly provisioning an AKS cluster, this article includes steps to deploy a cluster with default settings for evaluation purposes only. Before deploying a production-ready cluster, we recommend that you familiarize yourself with our [baseline reference architecture][baseline-reference-architecture] to consider how it aligns with your business requirements.
19+
20+
## Before you begin
21+
22+
There are two methods for the quickstart. Choosing Azure Developer CLI is a more automated process that uses scripts to run the Azure CLI commands and resource provisioning.
23+
24+
> [!NOTE]
25+
> For Windows users, follow the guide for the Azure CLI instead. The AZD Template repository doesn't support PowerShell commands yet.
26+
27+
## Azure Developer CLI
28+
29+
- An Azure account with an active subscription. Create an account for free
30+
- The Azure Developer CLI
31+
- The latest .NET 7.0 SDK
32+
- A Linux OS
33+
34+
This quickstart assumes a basic understanding of Kubernetes concepts. For more information, see [Kubernetes core concepts for Azure Kubernetes Service (AKS)][kubernetes-concepts].
35+
36+
- [!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
37+
38+
[!INCLUDE [azure-cli-prepare-your-environment-no-header.md](~/articles/reusable-content/azure-cli/azure-cli-prepare-your-environment-no-header.md)]
39+
40+
- This article requires version 2.0.64 or later of the Azure CLI. If you're using Azure Cloud Shell, the latest version is already installed there.
41+
- Check the identity you're using to create your cluster has the appropriate minimum permissions. For more information on access and identity for AKS, see [Access and identity options for Azure Kubernetes Service (AKS)](../concepts-identity.md).
42+
43+
## Sample Code
44+
45+
All code used in the quickstart is available at [Azure-Samples/aks-store-demo](https://github.com/Azure-Samples/aks-store-demo).
46+
47+
The quickstart application includes the following Kubernetes deployments and services:
48+
49+
:::image type="content" source="media/quick-kubernetes-deploy-portal/aks-store-architecture.png" alt-text="Screenshot of Azure Store sample architecture." lightbox="media/quick-kubernetes-deploy-portal/aks-store-architecture.png":::
50+
51+
- **Store front**: Web application for customers to view products and place orders.
52+
- **Product service**: Shows product information.
53+
- **Order service**: Places orders.
54+
- **Rabbit MQ**: Message queue for an order queue.
55+
56+
> [!NOTE]
57+
> We don't recommend running stateful containers, such as Rabbit MQ, without persistent storage for production use. These are used here for simplicity, but we recommend using managed services instead, such as Azure CosmosDB or Azure Service Bus.
58+
59+
### Template Command
60+
61+
You can quickly clone the application with `azd init` with the name of the repo using the template argument.
62+
63+
For instance, our code sample is at: `azd init --template aks-store-demo`.
64+
65+
### Git
66+
67+
Alternatively, you can clone the application directly through GitHub, then run `azd init` from inside the directory to create configurations for the AZD CLI.
68+
69+
When prompted for an environment name you can choose anything, but our quickstart uses `aksqs`.
70+
71+
## Sign in to your Azure Cloud account
72+
73+
The Azure Development Template contains all the code needed to create the services, but you need to sign in to host them on Azure Kubernetes Service.
74+
75+
Run `azd auth login`
76+
77+
1. Copy the device code that appears.
78+
2. Hit enter to open in a new tab the auth portal.
79+
3. Enter in your Microsoft Credentials in the new page.
80+
4. Confirm that it's you trying to connect to Azure CLI. If you encounter any issues, skip to the Troubleshooting section.
81+
5. Verify the message "Device code authentication completed. Logged in to Azure." appears in your original terminal.
82+
83+
### Troubleshooting: Can't Connect to Localhost
84+
85+
Certain Azure security policies cause conflicts when trying to sign in. As a workaround, you can perform a curl request to the localhost url you were redirected to after you logged in.
86+
87+
The workaround requires the Azure CLI for authentication. If you don't have it or aren't using GitHub Codespaces, install the [Azure CLI][install-azure-cli].
88+
89+
1. Inside a terminal, run `az login --scope https://graph.microsoft.com/.default`
90+
2. Copy the "localhost" URL from the failed redirect
91+
3. In a new terminal window, type `curl` and paste your url
92+
4. If it works, code for a webpage saying "You have logged into Microsoft Azure!" appears
93+
5. Close the terminal and go back to the old terminal
94+
6. Copy and note down which subscription_id you want to use
95+
7. Paste in the subscription_ID to the command `az account set -n {sub}`
96+
97+
- If you have multiple Azure subscriptions, select the appropriate subscription for billing using the [az account set](/cli/azure/account#az-account-set) command.
98+
99+
## Create resources for your cluster
100+
101+
The step can take longer depending on your internet speed.
102+
103+
1. Create all your resources with the `azd up` command.
104+
2. Select which Azure subscription and region for your AKS Cluster.
105+
3. Wait as azd automatically runs the commands for pre-provision and post-provision steps.
106+
4. At the end, your output shows the newly created deployments and services.
107+
108+
```output
109+
deployment.apps/rabbitmq created
110+
service/rabbitmq created
111+
deployment.apps/order-service created
112+
service/order-service created
113+
deployment.apps/product-service created
114+
service/product-service created
115+
deployment.apps/store-front created
116+
service/store-front created
117+
```
118+
119+
## Test the application
120+
121+
When your application is created, a Kubernetes service exposes the application's front end service to the internet. This process can take a few minutes to complete. Once completed, follow these steps verify and test the application by opening up the store-front page.
122+
123+
1. View the status of the deployed pods with the [kubectl get pods][kubectl-get] command.
124+
125+
Check that all pods are in the `Running` state before proceeding:
126+
127+
```console
128+
kubectl get pods
129+
```
130+
131+
1. Search for a public IP address for the front end store-front application.
132+
133+
Monitor progress using the [kubectl get service][kubectl-get] command with the `--watch` argument:
134+
135+
```azurecli
136+
kubectl get service store-front --watch
137+
```
138+
139+
The **EXTERNAL-IP** output for the `store-front` service initially shows as *pending*:
140+
141+
```output
142+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
143+
store-front LoadBalancer 10.0.100.10 <pending> 80:30025/TCP 4h4m
144+
```
145+
146+
1. When the **EXTERNAL-IP** address changes from *pending* to a public IP address, use `CTRL-C` to stop the `kubectl` watch process.
147+
148+
The following sample output shows a valid public IP address assigned to the service:
149+
150+
```output
151+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
152+
store-front LoadBalancer 10.0.100.10 20.62.159.19 80:30025/TCP 4h5m
153+
```
154+
155+
1. Open a web browser using the external IP address of your service to view the Azure Store app in action.
156+
157+
:::image type="content" source="media/quick-kubernetes-deploy-cli/aks-store-application.png" alt-text="Screenshot of AKS Store sample application." lightbox="media/quick-kubernetes-deploy-cli/aks-store-application.png":::
158+
159+
### Visit the store-front
160+
161+
Once on the store page, you can add new items to your cart and check them out. To verify, visit the Azure Service in your portal to view the records of the transactions for your store app.
162+
163+
<!-- Image of Storefront Checkout -->
164+
165+
## Delete the cluster
166+
167+
Once you're finished with the quickstart, remember to clean up all your resources to avoid Azure charges.
168+
169+
Run `azd down` to delete all your resources used in the quickstart, which includes your resource group, cluster, and related Azure Services.
170+
171+
> [!NOTE]
172+
> This sample application is for demo purposes and doesn't represent all the best practices for Kubernetes applications.
173+
> For guidance on creating full solutions with AKS for production, see [AKS solution guidance][aks-solution-guidance].
174+
175+
## Next steps
176+
177+
In this quickstart, you deployed a Kubernetes cluster and then deployed a simple multi-container application to it. You hosted a store app, but there's more to learn in the [AKS tutorial][aks-tutorial].
178+
179+
> [!div class="nextstepaction"]
180+
> [AKS tutorial][aks-tutorial]
181+
182+
<!-- LINKS - external -->
183+
[kubectl]: https://kubernetes.io/docs/reference/kubectl/
184+
[kubectl-apply]: https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#apply
185+
[kubectl-get]: https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#get
186+
187+
<!-- LINKS - internal -->
188+
[kubernetes-concepts]: ../concepts-clusters-workloads.md
189+
[aks-tutorial]: ../tutorial-kubernetes-prepare-app.md
190+
[azure-resource-group]: ../../azure-resource-manager/management/overview.md
191+
[az-aks-create]: /cli/azure/aks#az-aks-create
192+
[az-aks-get-credentials]: /cli/azure/aks#az-aks-get-credentials
193+
[install-azure-cli]: /cli/azure/install-azure-cli
194+
[az-aks-install-cli]: /cli/azure/aks#az-aks-install-cli
195+
[az-group-create]: /cli/azure/group#az-group-create
196+
[az-group-delete]: /cli/azure/group#az-group-delete
197+
[kubernetes-deployment]: ../concepts-clusters-workloads.md#deployments-and-yaml-manifests
198+
[aks-solution-guidance]: /azure/architecture/reference-architectures/containers/aks-start-here?toc=/azure/aks/toc.json&bc=/azure/aks/breadcrumb/toc.json
199+
[baseline-reference-architecture]: /azure/architecture/reference-architectures/containers/aks/baseline-aks?toc=/azure/aks/toc.json&bc=/azure/aks/breadcrumb/toc.json

0 commit comments

Comments
 (0)