|
1 | 1 | ---
|
2 |
| -title: 'Quickstart: Deploy your first container app' |
3 |
| -description: Deploy your first application to Azure Container Apps. |
| 2 | +title: 'Quickstart: Deploy your first container app with containerapp up' |
| 3 | +description: Deploy your first application to Azure Container Apps using the Azure CLI containerapp up command. |
4 | 4 | services: container-apps
|
5 |
| -author: craigshoemaker |
| 5 | +author: cebundy |
6 | 6 | ms.service: container-apps
|
7 | 7 | ms.topic: quickstart
|
8 |
| -ms.date: 03/21/2022 |
9 |
| -ms.author: cshoe |
10 |
| -ms.custom: ignite-fall-2021, mode-api, devx-track-azurecli, event-tier1-build-2022, devx-track-azurepowershell |
| 8 | +ms.date: 03/29/2023 |
| 9 | +ms.author: v-bcatherine |
| 10 | +ms.custom: devx-track-azurecli, event-tier1-build-2022 |
11 | 11 | ms.devlang: azurecli
|
12 | 12 | ---
|
13 | 13 |
|
14 |
| -# Quickstart: Deploy your first container app |
| 14 | +# Quickstart: Deploy your first container app with containerapp up |
15 | 15 |
|
16 | 16 | The Azure Container Apps service enables you to run microservices and containerized applications on a serverless platform. With Container Apps, you enjoy the benefits of running containers while you leave behind the concerns of manually configuring cloud infrastructure and complex container orchestrators.
|
17 | 17 |
|
18 |
| -In this quickstart, you create a secure Container Apps environment and deploy your first container app. |
| 18 | +In this quickstart, you create and deploy your first container app using the `az containerapp up` command. |
19 | 19 |
|
20 | 20 | ## Prerequisites
|
21 | 21 |
|
22 | 22 | - An Azure account with an active subscription.
|
23 | 23 | - If you don't have one, you [can create one for free](https://azure.microsoft.com/free/).
|
24 | 24 | - Install the [Azure CLI](/cli/azure/install-azure-cli).
|
25 | 25 |
|
26 |
| -[!INCLUDE [container-apps-create-cli-steps.md](../../includes/container-apps-create-cli-steps.md)] |
| 26 | +## Setup |
27 | 27 |
|
28 |
| -# [Bash](#tab/bash) |
| 28 | +To sign in to Azure from the CLI, run the following command and follow the prompts to complete the authentication process. |
29 | 29 |
|
30 |
| -To create the environment, run the following command: |
| 30 | +# [Bash](#tab/bash) |
31 | 31 |
|
32 | 32 | ```azurecli
|
33 |
| -az containerapp env create \ |
34 |
| - --name $CONTAINERAPPS_ENVIRONMENT \ |
35 |
| - --resource-group $RESOURCE_GROUP \ |
36 |
| - --location $LOCATION |
| 33 | +az login |
37 | 34 | ```
|
38 | 35 |
|
39 | 36 | # [Azure PowerShell](#tab/azure-powershell)
|
40 | 37 |
|
41 |
| -A Log Analytics workspace is required for the Container Apps environment. The following commands create a Log Analytics workspace and save the workspace ID and primary shared key to variables. |
42 |
| - |
43 | 38 | ```azurepowershell
|
44 |
| -$WorkspaceArgs = @{ |
45 |
| - Name = 'myworkspace' |
46 |
| - ResourceGroupName = $ResourceGroupName |
47 |
| - Location = $Location |
48 |
| - PublicNetworkAccessForIngestion = 'Enabled' |
49 |
| - PublicNetworkAccessForQuery = 'Enabled' |
50 |
| -} |
51 |
| -New-AzOperationalInsightsWorkspace @WorkspaceArgs |
52 |
| -$WorkspaceId = (Get-AzOperationalInsightsWorkspace -ResourceGroupName $ResourceGroupName -Name $WorkspaceArgs.Name).CustomerId |
53 |
| -$WorkspaceSharedKey = (Get-AzOperationalInsightsWorkspaceSharedKey -ResourceGroupName $ResourceGroupName -Name $WorkspaceArgs.Name).PrimarySharedKey |
| 39 | +az login |
54 | 40 | ```
|
55 | 41 |
|
56 |
| -To create the environment, run the following command: |
| 42 | +--- |
| 43 | + |
| 44 | +Ensure you're running the latest version of the CLI via the upgrade command. |
| 45 | + |
| 46 | +# [Bash](#tab/bash) |
| 47 | + |
| 48 | +```azurecli |
| 49 | +az upgrade |
| 50 | +``` |
| 51 | + |
| 52 | +# [Azure PowerShell](#tab/azure-powershell) |
57 | 53 |
|
58 | 54 | ```azurepowershell
|
59 |
| -$EnvArgs = @{ |
60 |
| - EnvName = $ContainerAppsEnvironment |
61 |
| - ResourceGroupName = $ResourceGroupName |
62 |
| - Location = $Location |
63 |
| - AppLogConfigurationDestination = 'log-analytics' |
64 |
| - LogAnalyticConfigurationCustomerId = $WorkspaceId |
65 |
| - LogAnalyticConfigurationSharedKey = $WorkspaceSharedKey |
66 |
| -} |
67 |
| -
|
68 |
| -New-AzContainerAppManagedEnv @EnvArgs |
| 55 | +az upgrade |
69 | 56 | ```
|
70 | 57 |
|
71 | 58 | ---
|
72 | 59 |
|
73 |
| -## Create a container app |
74 |
| - |
75 |
| -Now that you have an environment created, you can deploy your first container app. With the `containerapp create` command, deploy a container image to Azure Container Apps. |
| 60 | +Next, install or update the Azure Container Apps extension for the CLI. |
76 | 61 |
|
77 | 62 | # [Bash](#tab/bash)
|
78 | 63 |
|
79 | 64 | ```azurecli
|
80 |
| -az containerapp create \ |
81 |
| - --name my-container-app \ |
82 |
| - --resource-group $RESOURCE_GROUP \ |
83 |
| - --environment $CONTAINERAPPS_ENVIRONMENT \ |
84 |
| - --image mcr.microsoft.com/azuredocs/containerapps-helloworld:latest \ |
85 |
| - --target-port 80 \ |
86 |
| - --ingress 'external' \ |
87 |
| - --query properties.configuration.ingress.fqdn |
| 65 | +az extension add --name containerapp --upgrade |
88 | 66 | ```
|
89 | 67 |
|
90 |
| -> [!NOTE] |
91 |
| -> Make sure the value for the `--image` parameter is in lower case. |
92 |
| -
|
93 |
| -By setting `--ingress` to `external`, you make the container app available to public requests. |
94 |
| - |
95 | 68 | # [Azure PowerShell](#tab/azure-powershell)
|
96 | 69 |
|
| 70 | + |
97 | 71 | ```azurepowershell
|
98 |
| -$ImageParams = @{ |
99 |
| - Name = 'my-container-app' |
100 |
| - Image = 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest' |
101 |
| -} |
102 |
| -$TemplateObj = New-AzContainerAppTemplateObject @ImageParams |
103 |
| -$EnvId = (Get-AzContainerAppManagedEnv -EnvName $ContainerAppsEnvironment -ResourceGroupName $ResourceGroupName).Id |
104 |
| -
|
105 |
| -$AppArgs = @{ |
106 |
| - Name = 'my-container-app' |
107 |
| - Location = $Location |
108 |
| - ResourceGroupName = $ResourceGroupName |
109 |
| - ManagedEnvironmentId = $EnvId |
110 |
| - IdentityType = 'SystemAssigned' |
111 |
| - TemplateContainer = $TemplateObj |
112 |
| - IngressTargetPort = 80 |
113 |
| - IngressExternal = $true |
114 |
| -
|
115 |
| -} |
116 |
| -New-AzContainerApp @AppArgs |
| 72 | +az extension add --name containerapp --upgrade |
117 | 73 | ```
|
118 | 74 |
|
119 |
| -> [!NOTE] |
120 |
| -> Make sure the value for the `Image` parameter is in lower case. |
121 |
| -
|
122 |
| -By setting `IngressExternal` to `$true`, you make the container app available to public requests. |
123 |
| - |
124 | 75 | ---
|
125 | 76 |
|
126 |
| -## Verify deployment |
| 77 | +Register the `Microsoft.App` and `Microsoft.OperationalInsights` namespaces if you haven't already registered them in your Azure subscription. |
127 | 78 |
|
128 | 79 | # [Bash](#tab/bash)
|
129 | 80 |
|
130 |
| -The `create` command returns the fully qualified domain name for the container app. Copy this location to a web browser. |
| 81 | +```azurecli |
| 82 | +az provider register --namespace Microsoft.App |
| 83 | +``` |
131 | 84 |
|
132 |
| -# [Azure PowerShell](#tab/azure-powershell) |
| 85 | +```azurecli |
| 86 | +az provider register --namespace Microsoft.OperationalInsights |
| 87 | +``` |
133 | 88 |
|
134 |
| -Get the fully qualified domain name for the container app. |
| 89 | +# [Azure PowerShell](#tab/azure-powershell) |
135 | 90 |
|
136 | 91 | ```azurepowershell
|
137 |
| -(Get-AzContainerApp -Name $AppArgs.Name -ResourceGroupName $ResourceGroupName).IngressFqdn |
| 92 | +az provider register --namespace Microsoft.App |
138 | 93 | ```
|
139 | 94 |
|
140 |
| -Copy this location to a web browser. |
| 95 | +```azurepowershell |
| 96 | +az provider register --namespace Microsoft.OperationalInsights |
| 97 | +``` |
141 | 98 |
|
142 | 99 | ---
|
143 | 100 |
|
144 |
| - The following message is displayed when the container app is deployed: |
| 101 | +Now that your Azure CLI setup is complete, you can define the environment variables that are used throughout this article. |
145 | 102 |
|
146 |
| -:::image type="content" source="media/get-started/azure-container-apps-quickstart.png" alt-text="Your first Azure Container Apps deployment."::: |
147 | 103 |
|
148 |
| -## Clean up resources |
| 104 | +## Create and deploy the container app |
149 | 105 |
|
150 |
| -If you're not going to continue to use this application, run the following command to delete the resource group along with all the resources created in this quickstart. |
| 106 | +Create and deploy your first container app with the `containerapp up` command. This command will: |
| 107 | + |
| 108 | +- Create the resource group |
| 109 | +- Create the Container Apps environment |
| 110 | +- Create the Log Analytics workspace |
| 111 | +- Create and deploy the container app using a public container image |
| 112 | + |
| 113 | +Note that if any of these resources already exist, the command will use them instead of creating new ones. |
151 | 114 |
|
152 |
| ->[!CAUTION] |
153 |
| -> The following command deletes the specified resource group and all resources contained within it. If resources outside the scope of this quickstart exist in the specified resource group, they will also be deleted. |
154 | 115 |
|
155 | 116 | # [Bash](#tab/bash)
|
156 | 117 |
|
157 | 118 | ```azurecli
|
158 |
| -az group delete --name $RESOURCE_GROUP |
| 119 | +az containerapp up \ |
| 120 | + --name my-container-app \ |
| 121 | + --resource-group my-container-apps \ |
| 122 | + --location centralus \ |
| 123 | + --environment 'my-container-apps' \ |
| 124 | + --image mcr.microsoft.com/azuredocs/containerapps-helloworld:latest \ |
| 125 | + --target-port 80 \ |
| 126 | + --ingress external \ |
| 127 | + --query properties.configuration.ingress.fqdn |
159 | 128 | ```
|
160 | 129 |
|
161 | 130 | # [Azure PowerShell](#tab/azure-powershell)
|
162 | 131 |
|
163 |
| -```azurepowershell |
164 |
| -Remove-AzResourceGroup -Name $ResourceGroupName -Force |
| 132 | +```powershell |
| 133 | +az containerapp up ` |
| 134 | + --name my-container-app ` |
| 135 | + --resource-group my-container-apps ` |
| 136 | + --location centralus ` |
| 137 | + --environment my-container-apps ` |
| 138 | + --image mcr.microsoft.com/azuredocs/containerapps-helloworld:latest ` |
| 139 | + --target-port 80 ` |
| 140 | + --ingress external ` |
| 141 | + --query properties.configuration.ingress.fqdn |
165 | 142 | ```
|
166 | 143 |
|
167 | 144 | ---
|
168 | 145 |
|
| 146 | +> [!NOTE] |
| 147 | +> Make sure the value for the `--image` parameter is in lower case. |
| 148 | +
|
| 149 | +By setting `--ingress` to `external`, you make the container app available to public requests. |
| 150 | + |
| 151 | +## Verify deployment |
| 152 | + |
| 153 | +The `up` command returns the fully qualified domain name for the container app. Copy this location to a web browser. |
| 154 | + |
| 155 | +The following message is displayed when the container app is deployed: |
| 156 | + |
| 157 | +:::image type="content" source="media/get-started/azure-container-apps-quickstart.png" alt-text="Screenshot of container app web page."::: |
| 158 | + |
| 159 | +## Clean up resources |
| 160 | + |
| 161 | +If you're not going to continue to use this application, run the following command to delete the resource group along with all the resources created in this quickstart. |
| 162 | + |
| 163 | +>[!CAUTION] |
| 164 | +> The following command deletes the specified resource group and all resources contained within it. If resources outside the scope of this quickstart exist in the specified resource group, they will also be deleted. |
| 165 | +
|
| 166 | + |
| 167 | +```azurecli |
| 168 | +az group delete --name my-container-apps |
| 169 | +``` |
| 170 | + |
169 | 171 | > [!TIP]
|
170 | 172 | > Having issues? Let us know on GitHub by opening an issue in the [Azure Container Apps repo](https://github.com/microsoft/azure-container-apps).
|
171 | 173 |
|
|
0 commit comments