Skip to content

Commit d2a2457

Browse files
author
Jill Grant
authored
Merge pull request #290041 from anthonychu/20241106-update-quickstart
[Container Apps] Remove no Dockerfile instructions from quickstart
2 parents 9c7f9ae + 866cf06 commit d2a2457

File tree

1 file changed

+110
-128
lines changed

1 file changed

+110
-128
lines changed

articles/container-apps/quickstart-code-to-cloud.md

Lines changed: 110 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,14 @@ ms.custom:
88
- devx-track-azurecli
99
- ignite-2023
1010
ms.topic: quickstart
11-
ms.date: 09/09/2024
11+
ms.date: 11/07/2024
1212
ms.author: cshoe
13-
zone_pivot_groups: container-apps-code-to-cloud-segmemts
1413
---
1514

16-
1715
# Quickstart: Build and deploy from local source code to Azure Container Apps
1816

1917
This article demonstrates how to build and deploy a microservice to Azure Container Apps from local source code using the programming language of your choice. In this quickstart, you create a backend web API service that returns a static collection of music albums.
2018

21-
> [!NOTE]
22-
> This sample application is available in two versions. One version where the source contains a Dockerfile. The other version has no Dockerfile. Select the version that best reflects your source code. If you are new to containers, select the **No Dockerfile** option at the top.
23-
2419
The following screenshot shows the output from the album API service you deploy.
2520

2621
:::image type="content" source="media/quickstart-code-to-cloud/azure-container-apps-album-api.png" alt-text="Screenshot of response from albums API endpoint.":::
@@ -32,220 +27,207 @@ To complete this project, you need the following items:
3227
| Requirement | Instructions |
3328
|--|--|
3429
| Azure account | If you don't have one, [create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F). You need the *Contributor* or *Owner* permission on the Azure subscription to proceed. <br><br>Refer to [Assign Azure roles using the Azure portal](../role-based-access-control/role-assignments-portal.yml?tabs=current) for details. |
30+
| Git | Install [Git](https://git-scm.com/downloads). |
3531
| Azure CLI | Install the [Azure CLI](/cli/azure/install-azure-cli).|
3632

37-
[!INCLUDE [container-apps-create-cli-steps.md](../../includes/container-apps-create-cli-steps.md)]
33+
## Setup
3834

39-
## Create environment variables
40-
41-
Now that your Azure CLI setup is complete, you can define the environment variables that are used throughout this article.
35+
To sign in to Azure from the CLI, run the following command and follow the prompts to complete the authentication process.
4236

4337
# [Bash](#tab/bash)
4438

45-
Define the following variables in your bash shell.
46-
47-
```azurecli
48-
export RESOURCE_GROUP="album-containerapps"
49-
export LOCATION="canadacentral"
50-
export ENVIRONMENT="env-album-containerapps"
51-
export API_NAME="album-api"
39+
```bash
40+
az login
5241
```
5342

54-
# [Azure PowerShell](#tab/azure-powershell)
55-
56-
Define the following variables in your PowerShell console.
43+
# [PowerShell](#tab/powershell)
5744

5845
```powershell
59-
$RESOURCE_GROUP="album-containerapps"
60-
$LOCATION="canadacentral"
61-
$ENVIRONMENT="env-album-containerapps"
62-
$API_NAME="album-api"
46+
az login
6347
```
6448

6549
---
6650

67-
## Get the sample code
51+
To ensure you're running the latest version of the CLI, run the upgrade command.
6852

69-
Download and extract the API sample application in the language of your choice.
53+
# [Bash](#tab/bash)
7054

71-
::: zone pivot="with-dockerfile"
55+
```bash
56+
az upgrade
57+
```
7258

73-
# [C#](#tab/csharp)
59+
# [PowerShell](#tab/powershell)
7460

75-
[Download the source code](https://codeload.github.com/azure-samples/containerapps-albumapi-csharp/zip/refs/heads/main) to your machine.
61+
```powershell
62+
az upgrade
63+
```
7664

77-
Extract the download and change into the *containerapps-albumapi-csharp-main/src* folder.
65+
---
7866

67+
Next, install or update the Azure Container Apps extension for the CLI.
7968

80-
# [Java](#tab/java)
8169

82-
[Download the source code](https://codeload.github.com/azure-samples/containerapps-albumapi-java/zip/refs/heads/main) to your machine.
70+
# [Bash](#tab/bash)
8371

84-
Extract the download and change into the *containerapps-albumapi-java-main* folder.
72+
```bash
73+
az extension add --name containerapp --upgrade --allow-preview true
74+
```
8575

76+
# [PowerShell](#tab/powershell)
8677

87-
# [JavaScript](#tab/javascript)
78+
```powershell
79+
az extension add --name containerapp --upgrade --allow-preview true
80+
```
8881

89-
[Download the source code](https://codeload.github.com/azure-samples/containerapps-albumapi-javascript/zip/refs/heads/main) to your machine.
82+
---
9083

91-
Extract the download and change into the *containerapps-albumapi-javascript-main/src* folder.
84+
Now that the current extension is installed, register the `Microsoft.App` and `Microsoft.OperationalInsights` namespaces.
9285

86+
# [Bash](#tab/bash)
9387

94-
# [Python](#tab/python)
88+
```bash
89+
az provider register --namespace Microsoft.App
90+
az provider register --namespace Microsoft.OperationalInsights
91+
```
9592

96-
[Download the source code](https://codeload.github.com/azure-samples/containerapps-albumapi-python/zip/refs/heads/main) to your machine.
93+
# [PowerShell](#tab/powershell)
9794

98-
Extract the download and change into the *containerapps-albumapi-python-main/src* folder.
95+
```powershell
96+
az provider register --namespace Microsoft.App
97+
az provider register --namespace Microsoft.OperationalInsights
98+
```
9999

100+
---
100101

101-
# [Go](#tab/go)
102+
## Create environment variables
102103

103-
[Download the source code](https://codeload.github.com/azure-samples/containerapps-albumapi-go/zip/refs/heads/main) to your machine.
104+
Now that your CLI setup is complete, you can define the environment variables that are used throughout this article.
105+
Now that your CLI setup is complete, you can define the environment variables that are used throughout this article.
106+
# [Bash](#tab/bash)
104107

105-
Extract the download and navigate into the *containerapps-albumapi-go-main/src* folder.
108+
Define the following variables in your bash shell.
106109

110+
```bash
111+
export RESOURCE_GROUP="album-containerapps"
112+
export LOCATION="canadacentral"
113+
export ENVIRONMENT="env-album-containerapps"
114+
export API_NAME="album-api"
115+
```
107116

108-
::: zone-end
109-
::: zone pivot="without-dockerfile"
117+
# [PowerShell](#tab/powershell)
110118

119+
Define the following variables in your PowerShell console.
111120

112-
# [C#](#tab/csharp)
121+
```powershell
122+
$RESOURCE_GROUP="album-containerapps"
123+
$LOCATION="canadacentral"
124+
$ENVIRONMENT="env-album-containerapps"
125+
$API_NAME="album-api"
126+
```
113127

114-
[Download the source code](https://codeload.github.com/azure-samples/containerapps-albumapi-csharp/zip/refs/heads/buildpack) to your machine.
128+
---
115129

116-
Extract the download and change into the *containerapps-albumapi-csharp-buildpack/src* folder.
130+
## Get the sample code
117131

132+
Run the following command to clone the sample application in the language of your choice and change into the project source folder.
118133

119-
# [Java](#tab/java)
134+
# [C#](#tab/csharp)
120135

121-
[Download the source code](https://codeload.github.com/azure-samples/containerapps-albumapi-java/zip/refs/heads/buildpack) to your machine.
136+
```bash
137+
git clone https://github.com/azure-samples/containerapps-albumapi-csharp.git
138+
cd containerapps-albumapi-csharp/src
139+
```
122140

123-
Extract the download and change into the *containerapps-albumapi-java-buildpack* folder.
141+
# [Java](#tab/java)
124142

125-
> [!NOTE]
126-
> The Java Buildpack uses [Maven](https://maven.apache.org/what-is-maven.html) with default settings to build your application. Alternatively, you can the [use `--build-env-vars` parameter to configure the image build from source code](java-build-environment-variables.md).
143+
```bash
144+
git clone https://github.com/azure-samples/containerapps-albumapi-java.git
145+
cd containerapps-albumapi-java
146+
```
127147

128148
# [JavaScript](#tab/javascript)
129149

130-
[Download the source code](https://codeload.github.com/azure-samples/containerapps-albumapi-javascript/zip/refs/heads/buildpack) to your machine.
131-
132-
Extract the download and change into the *containerapps-albumapi-javascript-buildpack/src* folder.
150+
```bash
151+
git clone https://github.com/azure-samples/containerapps-albumapi-javascript.git
152+
cd containerapps-albumapi-javascript/src
153+
```
133154

134155
# [Python](#tab/python)
135156

136-
[Download the source code](https://codeload.github.com/azure-samples/containerapps-albumapi-python/zip/refs/heads/buildpack) to your machine.
137-
138-
Extract the download and change into the *containerapps-albumapi-python-buildpack/src* folder.
157+
```bash
158+
git clone https://github.com/azure-samples/containerapps-albumapi-python.git
159+
cd containerapps-albumapi-python/src
160+
```
139161

140162
# [Go](#tab/go)
141163

142-
Azure Container Apps cloud build doesn't currently support Buildpacks for Go.
143-
144-
::: zone-end
164+
```bash
165+
git clone https://github.com/azure-samples/containerapps-albumapi-go.git
166+
cd containerapps-albumapi-go/src
167+
```
145168

146169
---
147170

148171
## Build and deploy the container app
149172

150-
Build and deploy your first container app with the `containerapp up` command. This command will:
173+
First, run the following command to create the resource group that will contain the resources you create in this quickstart.
151174

152-
::: zone pivot="with-dockerfile"
153-
- Create the resource group
154-
- Create an Azure Container Registry
155-
- Build the container image and push it to the registry
156-
- Create the Container Apps environment with a Log Analytics workspace
157-
- Create and deploy the container app using the built container image
158-
::: zone-end
175+
# [Bash](#tab/bash)
159176

160-
::: zone pivot="without-dockerfile"
161-
- Create the resource group
162-
- Create a default registry as part of your environment
163-
- Detect the language and runtime of your application and build the image using the appropriate Buildpack
164-
- Push the image into the Azure Container Apps default registry
165-
- Create the Container Apps environment with a Log Analytics workspace
166-
- Create and deploy the container app using the built container image
167-
::: zone-end
177+
```bash
178+
az group create --name $RESOURCE_GROUP --location $LOCATION
179+
```
168180

169-
::: zone pivot="with-dockerfile"
181+
# [PowerShell](#tab/powershell)
170182

171-
The `up` command uses the Dockerfile in the root of the repository to build the container image. The `EXPOSE` instruction in the Dockerfile defined the target port, which is the port used to send ingress traffic to the container.
183+
```powershell
184+
az group create --name $RESOURCE_GROUP --location $LOCATION
185+
```
172186

173-
::: zone-end
174-
::: zone pivot="without-dockerfile"
187+
---
175188

176-
If the `up` command doesn't find a Dockerfile, it automatically uses Buildpacks to turn your application source into a runnable container. Since the Buildpack is trying to run the build on your behalf, you need to tell the `up` command which port to send ingress traffic to.
189+
Build and deploy your first container app with the `containerapp up` command. This command will:
177190

178-
::: zone-end
191+
- Create the resource group
192+
- Create an Azure Container Registry
193+
- Build the container image and push it to the registry
194+
- Create the Container Apps environment with a Log Analytics workspace
195+
- Create and deploy the container app using the built container image
179196

197+
The `up` command uses the Dockerfile in project folder to build the container image. The `EXPOSE` instruction in the Dockerfile defines the target port, which is the port used to send ingress traffic to the container.
180198

181-
In the following code example, the `.` (dot) tells `containerapp up` to run in the current directory of the extracted sample API application.
199+
In the following code example, the `.` (dot) tells `containerapp up` to run in the current directory of the project that also contains the Dockerfile.
182200

183201
# [Bash](#tab/bash)
184202

185-
::: zone pivot="with-dockerfile"
186-
187-
```azurecli
188-
az containerapp up \
189-
--name $API_NAME \
190-
--location $LOCATION \
191-
--environment $ENVIRONMENT \
192-
--source .
193-
```
194-
195-
::: zone-end
196-
::: zone pivot="without-dockerfile"
197-
198-
```azurecli
203+
```bash
199204
az containerapp up \
200205
--name $API_NAME \
206+
--resource-group $RESOURCE_GROUP \
201207
--location $LOCATION \
202208
--environment $ENVIRONMENT \
203-
--ingress external \
204-
--target-port 8080 \
205209
--source .
206210
```
207-
> [!IMPORTANT]
208-
> In order to deploy your container app to an existing resource group, include `--resource-group yourResourceGroup` to the `containerapp up` command.
209-
210-
::: zone-end
211-
212-
213-
# [Azure PowerShell](#tab/azure-powershell)
214-
215-
::: zone pivot="with-dockerfile"
216-
217-
```powershell
218-
az containerapp up `
219-
--name $API_NAME `
220-
--resource-group $RESOURCE_GROUP `
221-
--location $LOCATION `
222-
--environment $ENVIRONMENT `
223-
--source .
224-
```
225211

226-
::: zone-end
227-
::: zone pivot="without-dockerfile"
212+
# [PowerShell](#tab/powershell)
228213

229214
```powershell
230215
az containerapp up `
231216
--name $API_NAME `
232217
--resource-group $RESOURCE_GROUP `
233218
--location $LOCATION `
234219
--environment $ENVIRONMENT `
235-
--ingress external `
236-
--target-port 8080 `
237220
--source .
238221
```
239222

240-
::: zone-end
241-
242-
243223
---
244224

225+
> [!NOTE]
226+
> If the command returns an error with the message "AADSTS50158: External security challenge not satisfied", run `az login --scope https://graph.microsoft.com//.default` to log in with the required permissions and then run the `az containerapp up` command again.
245227
246228
## Verify deployment
247229

248-
Copy the FQDN to a web browser. From your web browser, go to the `/albums` endpoint of the FQDN.
230+
Locate the container app's URL in the output of the `az containerapp up` command. Navigate to the URL in your browser. Add `/albums` to the end of the URL to see the response from the API.
249231

250232
:::image type="content" source="media/quickstart-code-to-cloud/azure-container-apps-album-api.png" alt-text="Screenshot of response from albums API endpoint.":::
251233

@@ -262,11 +244,11 @@ If you're not going to continue on to the [Deploy a frontend](communicate-betwee
262244
263245
# [Bash](#tab/bash)
264246

265-
```azurecli
247+
```bash
266248
az group delete --name $RESOURCE_GROUP
267249
```
268250

269-
# [Azure PowerShell](#tab/azure-powershell)
251+
# [PowerShell](#tab/powershell)
270252

271253
```powershell
272254
az group delete --name $RESOURCE_GROUP

0 commit comments

Comments
 (0)