Skip to content

Commit e4c3997

Browse files
authored
Merge pull request #266341 from nathaniel-msft/azd-akstutorial-1
Update AKS Tutorial with AZD steps
2 parents f636545 + 63a0da5 commit e4c3997

File tree

6 files changed

+343
-93
lines changed

6 files changed

+343
-93
lines changed

articles/aks/TOC.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
href: tutorial-kubernetes-prepare-acr.md
7878
- name: 3 - Create Kubernetes cluster
7979
href: tutorial-kubernetes-deploy-cluster.md
80-
- name: 4 - Run application
80+
- name: 4 - Deploy containerized application
8181
href: tutorial-kubernetes-deploy-application.md
8282
- name: 5 - Use PaaS services
8383
href: tutorial-kubernetes-paas-services.md
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
ms.service: azure-kubernetes-service
3+
ms.topic: include
4+
ms.date: 02/21/2024
5+
---
6+
7+
> [!IMPORTANT]
8+
> Certain Azure security policies cause conflicts when used to sign in with `azd auth login`. As a workaround, you can perform a curl request to the localhost url you were redirected to after you logged in.
9+
10+
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].
11+
12+
1. Inside a terminal, login with Azure CLI
13+
```azurecli-interactive
14+
az login --scope https://graph.microsoft.com/.default
15+
```
16+
1. Copy the "localhost" URL from the failed redirect
17+
1. In a new terminal window, type `curl` and paste your url
18+
1. If it works, code for a webpage saying "You have logged into Microsoft Azure!" appears
19+
20+
```html
21+
<!DOCTYPE html>
22+
<html>
23+
<head>
24+
<meta charset="utf-8" />
25+
<meta http-equiv="refresh" content="60;url=https://docs.microsoft.com/cli/azure/">
26+
<title>Login successfully</title>
27+
<style>
28+
body {
29+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
30+
}
31+
32+
code {
33+
font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
34+
display: inline-block;
35+
background-color: rgb(242, 242, 242);
36+
padding: 12px 16px;
37+
margin: 8px 0px;
38+
}
39+
</style>
40+
</head>
41+
<body>
42+
<h3>You have logged into Microsoft Azure!</h3>
43+
<p>You can close this window, or we will redirect you to the <a href="https://docs.microsoft.com/cli/azure/">Azure CLI documentation</a> in 1 minute.</p>
44+
<h3>Announcements</h3>
45+
<p>[Windows only] Azure CLI is collecting feedback on using the <a href="https://learn.microsoft.com/windows/uwp/security/web-account-manager">Web Account Manager</a> (WAM) broker for the login experience.</p>
46+
<p>You may opt-in to use WAM by running the following commands:</p>
47+
<code>
48+
az config set core.allow_broker=true<br>
49+
az account clear<br>
50+
az login
51+
</code>
52+
</body>
53+
</html>
54+
```
55+
56+
5. Close the new terminal and open the old terminal
57+
6. Copy and note down which subscription_id you want to use
58+
7. Paste in the subscription_ID to the command `az account set -n {sub}`
59+
60+
[install-azure-cli]: /cli/azure/install-azure-cli

articles/aks/learn/quick-kubernetes-deploy-azd.md

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -76,24 +76,12 @@ The Azure Development Template contains all the code needed to create the servic
7676
Run `azd auth login`
7777

7878
1. Copy the device code that appears.
79-
2. Hit enter to open in a new tab the auth portal.
80-
3. Enter in your Microsoft Credentials in the new page.
81-
4. Confirm that it's you trying to connect to Azure CLI. If you encounter any issues, skip to the Troubleshooting section.
82-
5. Verify the message "Device code authentication completed. Logged in to Azure." appears in your original terminal.
79+
1. Hit enter to open in a new tab the auth portal.
80+
1. Enter in your Microsoft Credentials in the new page.
81+
1. Confirm that it's you trying to connect to Azure CLI. If you encounter any issues, skip to the Troubleshooting section.
82+
1. Verify the message "Device code authentication completed. Logged in to Azure." appears in your original terminal.
8383

84-
### Troubleshooting: Can't Connect to Localhost
85-
86-
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.
87-
88-
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].
89-
90-
1. Inside a terminal, run `az login --scope https://graph.microsoft.com/.default`
91-
2. Copy the "localhost" URL from the failed redirect
92-
3. In a new terminal window, type `curl` and paste your url
93-
4. If it works, code for a webpage saying "You have logged into Microsoft Azure!" appears
94-
5. Close the terminal and go back to the old terminal
95-
6. Copy and note down which subscription_id you want to use
96-
7. Paste in the subscription_ID to the command `az account set -n {sub}`
84+
[!INCLUDE [azd-login-ts](../includes/azd/azd-login-ts.md)]
9785

9886
- If you have multiple Azure subscriptions, select the appropriate subscription for billing using the [az account set](/cli/azure/account#az-account-set) command.
9987

@@ -102,9 +90,9 @@ The workaround requires the Azure CLI for authentication. If you don't have it o
10290
The step can take longer depending on your internet speed.
10391

10492
1. Create all your resources with the `azd up` command.
105-
2. Select which Azure subscription and region for your AKS Cluster.
106-
3. Wait as azd automatically runs the commands for pre-provision and post-provision steps.
107-
4. At the end, your output shows the newly created deployments and services.
93+
1. Select which Azure subscription and region for your AKS Cluster.
94+
1. Wait as azd automatically runs the commands for pre-provision and post-provision steps.
95+
1. At the end, your output shows the newly created deployments and services.
10896

10997
```output
11098
deployment.apps/rabbitmq created
@@ -121,6 +109,12 @@ The step can take longer depending on your internet speed.
121109
122110
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.
123111
112+
1. Set your namespace as the demo namespace `pets` with the `kubectl set-context` command.
113+
114+
```console
115+
kubectl config set-context --current --namespace=pets
116+
```
117+
124118
1. View the status of the deployed pods with the [kubectl get pods][kubectl-get] command.
125119
126120
Check that all pods are in the `Running` state before proceeding:
@@ -161,8 +155,6 @@ When your application is created, a Kubernetes service exposes the application's
161155
162156
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.
163157
164-
<!-- Image of Storefront Checkout -->
165-
166158
## Delete the cluster
167159
168160
Once you're finished with the quickstart, remember to clean up all your resources to avoid Azure charges.

articles/aks/tutorial-kubernetes-deploy-application.md

Lines changed: 82 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Kubernetes on Azure tutorial - Deploy an application to Azure Kubernetes Service (AKS)
33
description: In this Azure Kubernetes Service (AKS) tutorial, you deploy a multi-container application to your cluster using images stored in Azure Container Registry.
44
ms.topic: tutorial
5-
ms.date: 11/02/2023
5+
ms.date: 02/20/2023
66
ms.custom: mvc
77
#Customer intent: As a developer, I want to learn how to deploy apps to an Azure Kubernetes Service (AKS) cluster so that I can deploy and run my own applications.
88
---
@@ -29,15 +29,19 @@ In this tutorial, part four of seven, you deploy a sample application into a Kub
2929
3030
## Before you begin
3131

32-
In previous tutorials, you packaged an application into a container image, uploaded the image to Azure Container Registry, and created a Kubernetes cluster. To complete this tutorial, you need the pre-created `aks-store-quickstart.yaml` Kubernetes manifest file. This file download was included with the application source code in a previous tutorial. Make sure you cloned the repo and changed directories into the cloned repo. If you haven't completed these steps and want to follow along, start with [Tutorial 1 - Prepare application for AKS][aks-tutorial-prepare-app].
32+
In previous tutorials, you packaged an application into a container image, uploaded the image to Azure Container Registry, and created a Kubernetes cluster. To complete this tutorial, you need the precreated `aks-store-quickstart.yaml` Kubernetes manifest file. This file was downloaded in the application source code from [Tutorial 1 - Prepare application for AKS][aks-tutorial-prepare-app].
3333

3434
### [Azure CLI](#tab/azure-cli)
3535

36-
This tutorial requires Azure CLI version 2.34.1 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI][azure-cli-install].
36+
This tutorial requires Azure CLI version 2.0.53 or later. Check your version with `az --version`. To install or upgrade, see [Install Azure CLI][azure-cli-install].
3737

3838
### [Azure PowerShell](#tab/azure-powershell)
3939

40-
This tutorial requires Azure PowerShell version 5.9.0 or later. Run `Get-InstalledModule -Name Az` to find the version. If you need to install or upgrade, see [Install Azure PowerShell][azure-powershell-install].
40+
This tutorial requires Azure PowerShell version 5.9.0 or later. Check your version with `Get-InstalledModule -Name Az`. To install or upgrade, see [Install Azure PowerShell][azure-powershell-install].
41+
42+
### [Azure Developer CLI](#tab/azure-azd)
43+
44+
This tutorial requires Azure Developer CLI (AZD) version 1.5.1 or later. Check your version with `azd version`. To install or upgrade, see [Install Azure Developer CLI][azure-azd-install].
4145

4246
---
4347

@@ -53,7 +57,7 @@ In these tutorials, your Azure Container Registry (ACR) instance stores the cont
5357
az acr list --resource-group myResourceGroup --query "[].{acrLoginServer:loginServer}" --output table
5458
```
5559
56-
2. Make sure you're in the cloned *aks-store-demo* directory, and then open the manifest file with a text editor, such as `vi`:
60+
2. Make sure you're in the cloned *aks-store-demo* directory, and then open the manifest file with a text editor, such as `vi`.
5761
5862
```azurecli-interactive
5963
vi aks-store-quickstart.yaml
@@ -85,7 +89,7 @@ In these tutorials, your Azure Container Registry (ACR) instance stores the cont
8589
(Get-AzContainerRegistry -ResourceGroupName myResourceGroup -Name <acrName>).LoginServer
8690
```
8791
88-
2. Make sure you're in the cloned *aks-store-demo* directory, and then open the manifest file with a text editor, such as `vi`:
92+
2. Make sure you're in the cloned *aks-store-demo* directory, and then open the manifest file with a text editor, such as `vi`.
8993
9094
```azurepowershell-interactive
9195
vi aks-store-quickstart.yaml
@@ -109,11 +113,45 @@ In these tutorials, your Azure Container Registry (ACR) instance stores the cont
109113
110114
4. Save and close the file. In `vi`, use `:wq`.
111115
116+
117+
### [Azure Developer CLI](#tab/azure-azd)
118+
119+
AZD doesn't require a container registry step since it's in the template.
120+
112121
---
113122
114-
## Deploy the application
123+
## Run the application
124+
125+
### [Azure CLI](#tab/azure-cli)
126+
127+
1. Deploy the application using the [`kubectl apply`][kubectl-apply] command, which parses the manifest file and creates the defined Kubernetes objects.
128+
129+
```console
130+
kubectl apply -f aks-store-quickstart.yaml
131+
```
132+
133+
The following example output shows the resources successfully created in the AKS cluster:
134+
135+
```output
136+
deployment.apps/rabbitmq created
137+
service/rabbitmq created
138+
deployment.apps/order-service created
139+
service/order-service created
140+
deployment.apps/product-service created
141+
service/product-service created
142+
deployment.apps/store-front created
143+
service/store-front created
144+
```
145+
146+
2. Check the deployment is successful by viewing the pods with `kubectl`
147+
148+
```console
149+
kubectl get pods
150+
```
151+
152+
### [Azure PowerShell](#tab/azure-powershell)
115153
116-
* Deploy the application using the [`kubectl apply`][kubectl-apply] command, which parses the manifest file and creates the defined Kubernetes objects.
154+
1. Deploy the application using the [`kubectl apply`][kubectl-apply] command, which parses the manifest file and creates the defined Kubernetes objects.
117155
118156
```console
119157
kubectl apply -f aks-store-quickstart.yaml
@@ -132,17 +170,35 @@ In these tutorials, your Azure Container Registry (ACR) instance stores the cont
132170
service/store-front created
133171
```
134172
173+
2. Check the deployment is successful by viewing the pods with `kubectl`
174+
175+
```console
176+
kubectl get pods
177+
```
178+
179+
### [Azure Developer CLI](#tab/azure-azd)
180+
181+
Deployment in AZD in broken down into multiple stages represented by hooks. Run `azd up` as an all-in-one command.
182+
183+
When you first run azd up, you're prompted to select which Subscription and Region to host your Azure resources.
184+
185+
You can update these variables for `AZURE_LOCATION` and `AZURE_SUBSCRIPTION_ID` from inside the `.azure/<your-env-name>/.env` file.
186+
187+
---
188+
135189
## Test the application
136190
137191
When the application runs, a Kubernetes service exposes the application front end to the internet. This process can take a few minutes to complete.
138192
193+
### Command Line
194+
139195
1. Monitor progress using the [`kubectl get service`][kubectl-get] command with the `--watch` argument.
140196
141197
```console
142198
kubectl get service store-front --watch
143199
```
144200
145-
Initially, the `EXTERNAL-IP` for the *store-front* service shows as *pending*.
201+
Initially, the `EXTERNAL-IP` for the *store-front* service shows as *pending*:
146202
147203
```output
148204
store-front LoadBalancer 10.0.34.242 <pending> 80:30676/TCP 5s
@@ -158,14 +214,28 @@ When the application runs, a Kubernetes service exposes the application front en
158214
159215
3. View the application in action by opening a web browser to the external IP address of your service.
160216
217+
:::image type="content" source="./learn/media/quick-kubernetes-deploy-cli/aks-store-application.png" alt-text="Screenshot of AKS Store sample application." lightbox="./learn/media/quick-kubernetes-deploy-cli/aks-store-application.png":::
218+
161219
If the application doesn't load, it might be an authorization problem with your image registry. To view the status of your containers, use the `kubectl get pods` command. If you can't pull the container images, see [Authenticate with Azure Container Registry from Azure Kubernetes Service](cluster-container-registry-integration.md).
162220
221+
### Azure portal
222+
223+
Navigate to your Azure portal to find your deployment information.
224+
225+
1. Open your [Resource Group][azure-rg] on the Azure portal
226+
1. Navigate to the Kubernetes service for your cluster
227+
1. Select `Services and Ingress` under `Kubernetes Resources`
228+
1. Copy the External IP shown in the column for store-front
229+
1. Paste the IP into your browser and visit your store page
230+
231+
:::image type="content" source="./learn/media/quick-kubernetes-deploy-cli/aks-store-application.png" alt-text="Screenshot of AKS Store sample application." lightbox="./learn/media/quick-kubernetes-deploy-cli/aks-store-application.png":::
232+
163233
## Next steps
164234
165235
In this tutorial, you deployed a sample Azure application to a Kubernetes cluster in AKS. You learned how to:
166236
167237
> [!div class="checklist"]
168-
>
238+
>
169239
> * Update a Kubernetes manifest file.
170240
> * Run an application in Kubernetes.
171241
> * Test the application.
@@ -176,12 +246,14 @@ In the next tutorial, you learn how to use PaaS services for stateful workloads
176246
> [Use PaaS services for stateful workloads in AKS][aks-tutorial-paas]
177247
178248
<!-- LINKS - external -->
249+
[azure-rg]:https://ms.portal.azure.com/#browse/resourcegroups
179250
[kubectl-apply]: https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#apply
180251
[kubectl-get]: https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#get
181252
182253
<!-- LINKS - internal -->
183254
[aks-tutorial-prepare-app]: ./tutorial-kubernetes-prepare-app.md
184255
[az-acr-list]: /cli/azure/acr
256+
[azure-azd-install]: /azure/developer/azure-developer-cli/install-azd
185257
[azure-cli-install]: /cli/azure/install-azure-cli
186258
[azure-powershell-install]: /powershell/azure/install-az-ps
187259
[get-azcontainerregistry]: /powershell/module/az.containerregistry/get-azcontainerregistry

0 commit comments

Comments
 (0)