Skip to content

Commit 262eed6

Browse files
committed
Verified PS cmdlets.
1 parent a6a1c47 commit 262eed6

File tree

2 files changed

+78
-79
lines changed

2 files changed

+78
-79
lines changed

articles/container-apps/managed-identity-image-pull.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ New-AzUserAssignedIdentity -Name $IdentityName -ResourceGroupName $ResourceGroup
381381

382382
# [Bash](#tab/bash)
383383

384-
Get identity's resource ID.
384+
Get the identity's resource ID.
385385

386386
```azurecli
387387
IDENTITY_ID=$(az identity show \
@@ -457,8 +457,7 @@ $AppArgs = @{
457457
ResourceGroupName = $ResourceGroupName
458458
ManagedEnvironmentId = $EnvId
459459
ConfigurationRegistry = $CredentialObject
460-
IdentityType = 'UserAssigned'
461-
IdentityUserAssignedIdentity = @{ $IdentityId = @{ } }
460+
UserAssignedIdentity = @($IdentityId)
462461
TemplateContainer = $TemplateObj
463462
IngressTargetPort = 80
464463
IngressExternal = $true

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

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.custom:
99
- devx-track-azurepowershell
1010
- ignite-2023
1111
ms.topic: tutorial
12-
ms.date: 12/10/2024
12+
ms.date: 12/12/2024
1313
ms.author: cshoe
1414
zone_pivot_groups: container-apps-image-build-type
1515
---
@@ -24,7 +24,7 @@ This is the first tutorial in the series of articles that walk you through how t
2424
> [!NOTE]
2525
> You can also build and deploy this app using the [az containerapp up](/cli/azure/containerapp#az_containerapp_up) by following the instructions in the [Quickstart: Build and deploy an app to Azure Container Apps from a repository](quickstart-code-to-cloud.md) article. The `az containerapp up` command is a fast and convenient way to build and deploy your app to Azure Container Apps using a single command. However, it doesn't provide the same level of customization for your container app.
2626
27-
The next tutorial in the series will build and deploy the front end web application to Azure Container Apps.
27+
The next tutorial in the series will build and deploy the front end web application to Azure Container Apps.
2828

2929
The following screenshot shows the output from the album API deployed in this tutorial.
3030

@@ -152,6 +152,7 @@ cd code-to-cloud/src
152152
```azurecli
153153
az acr create \
154154
--resource-group $RESOURCE_GROUP \
155+
--location $LOCATION \
155156
--name $ACR_NAME \
156157
--sku Basic
157158
```
@@ -161,6 +162,7 @@ cd code-to-cloud/src
161162
```azurepowershell
162163
$acr = New-AzContainerRegistry `
163164
-ResourceGroupName $ResourceGroup `
165+
-Location $Location `
164166
-Name $ACRName `
165167
-Sku Basic
166168
```
@@ -177,15 +179,6 @@ cd code-to-cloud/src
177179
az acr config authentication-as-arm show --registry "$ACR_NAME"
178180
```
179181
180-
TODO1 Verify
181-
# [Azure PowerShell](#tab/azure-powershell)
182-
183-
```powershell
184-
$acr.Config.AuthenticationAsArm
185-
```
186-
187-
---
188-
189182
If ARM tokens are allowed, the command outputs the following.
190183
191184
```
@@ -196,18 +189,23 @@ TODO1 Verify
196189
197190
If the `status` is `disabled`, allow ARM tokens with the following command.
198191
199-
# [Bash](#tab/bash)
200-
201192
```azurecli
202193
az acr config authentication-as-arm update --registry "$ACR_NAME" --status enabled
203194
```
204195
205-
TODO1 Verify
206196
# [Azure PowerShell](#tab/azure-powershell)
207197
208198
```powershell
209-
$acr.Config.AuthenticationAsArm.Enabled = $true
210-
Set-AzContainerRegistry -ResourceGroupName $acr.ResourceGroupName -Name $acr.Name -Registry $acr
199+
Write-Output $acr.AzureAdAuthenticationAsArmPolicyStatus
200+
```
201+
202+
If the command returns `disabled`, allow ARM tokens with the following command.
203+
204+
```powershell
205+
Update-AzContainerRegistry `
206+
-ResourceGroupName $acr.ResourceGroupName `
207+
-Name $acr.Name `
208+
-AzureAdAuthenticationAsArmPolicyStatus enabled
211209
```
212210
213211
---
@@ -216,50 +214,61 @@ TODO1 Verify
216214
217215
To avoid using administrative credentials, pull images from private repositories in Microsoft Azure Container Registry using managed identities for authentication. When possible, use a user-assigned managed identity to pull images.
218216
219-
1. Create a user-assigned managed identity. Before you run the following commands, choose a name for your managed identity and replace the `\<PLACEHOLDER\>` with the name.
217+
# [Bash](#tab/bash)
220218
221-
# [Bash](#tab/bash)
219+
1. Create a user-assigned managed identity. Before you run the following commands, choose a name for your managed identity and replace the `\<PLACEHOLDER\>` with the name.
222220
223-
```bash
224-
IDENTITY="<YOUR_IDENTITY_NAME>"
225-
```
221+
```bash
222+
IDENTITY="<YOUR_IDENTITY_NAME>"
223+
```
226224

227-
```azurecli
228-
az identity create \
229-
--name $IDENTITY \
230-
--resource-group $RESOURCE_GROUP
231-
```
225+
```azurecli
226+
az identity create \
227+
--name $IDENTITY \
228+
--resource-group $RESOURCE_GROUP
229+
```
232230

233-
# [Azure PowerShell](#tab/azure-powershell)
231+
1. Get the identity's resource ID.
234232

235-
TODO1 Verify
236-
```powershell
237-
$IdentityName="<YOUR_IDENTITY_NAME>"
238-
$Identity = New-AzUserAssignedIdentity -ResourceGroupName $ResourceGroup -Name $IdentityName
239-
```
233+
# [Bash](#tab/bash)
240234

241-
---
235+
```azurecli
236+
IDENTITY_ID=$(az identity show \
237+
--name $IDENTITY \
238+
--resource-group $RESOURCE_GROUP \
239+
--query id \
240+
--output tsv)
241+
```
242242

243-
1. Get the identity's resource ID.
243+
# [Azure PowerShell](#tab/azure-powershell)
244244

245-
# [Bash](#tab/bash)
245+
1. Create a user-assigned managed identity. Before you run the following commands, choose a name for your managed identity and replace the `\<PLACEHOLDER\>` with the name.
246246

247-
```azurecli
248-
IDENTITY_ID=$(az identity show \
249-
--name $IDENTITY \
250-
--resource-group $RESOURCE_GROUP \
251-
--query id \
252-
--output tsv)
253-
```
247+
```powershell
248+
$IdentityName="<YOUR_IDENTITY_NAME>"
249+
$Identity = New-AzUserAssignedIdentity -ResourceGroupName $ResourceGroup -Name $IdentityName
250+
```
254251

255-
# [Azure PowerShell](#tab/azure-powershell)
252+
1. Get the identity's resource and principal ID.
256253

257-
TODO1 Verify
258-
```powershell
259-
$IdentityId = $identity.Id
260-
```
254+
```azurepowershell
255+
$IdentityId = $Identity.Id
256+
$PrincipalId = (Get-AzUserAssignedIdentity -Name $IdentityName -ResourceGroupName $ResourceGroup).PrincipalId
257+
```
261258

262-
---
259+
Get the registry's resource ID. Before you run the following command, replace the *\<placeholders\>* with the resource group name for your registry.
260+
261+
```azurepowershell
262+
$RegistryId = (Get-AzContainerRegistry -ResourceGroupName $ResourceGroup -Name $ACRName).Id
263+
```
264+
265+
1. Create the `acrpull` role assignment for the identity.
266+
267+
```azurepowershell
268+
New-AzRoleAssignment -ObjectId $PrincipalId -Scope $RegistryId -RoleDefinitionName acrpull
269+
```
270+
271+
---
263272

264273
::: zone pivot="acr-remote"
265274

@@ -279,10 +288,10 @@ az acr build --registry $ACR_NAME --image $API_NAME .
279288

280289
# [Azure PowerShell](#tab/azure-powershell)
281290

282-
TODO1 Verify
283-
```azurepowershell
284-
New-AzAcrBuildTask -RegistryName $ACRName -ImageName $APIName -ContextPath "."
291+
The `az acr build` command does not have a PowerShell equivalent, but can be run in PowerShell.
285292

293+
```azurepowershell
294+
az acr build --registry $AcrName --image $APIName .
286295
```
287296

288297
---
@@ -295,7 +304,7 @@ Output from the `az acr build` command shows the upload progress of the source c
295304

296305
## Build your application
297306

298-
The following steps, demonstrate how to build your container image locally using Docker and push the image to the new container registry.
307+
The following steps show how to build your container image locally using Docker and push the image to the new container registry.
299308

300309
### Build the container with Docker
301310

@@ -327,20 +336,12 @@ az acr login --name $ACR_NAME
327336

328337
# [Azure PowerShell](#tab/azure-powershell)
329338

330-
TODO1 Verify
331339
```powershell
332340
Connect-AzContainerRegistry -Name $ACRName
333341
```
334342

335343
---
336344

337-
TODO1 Shouldn't az acr build take care of this? Try skipping this. What az acr build command did we use in the other tutorial?
338-
az acr build \
339-
--registry "$CONTAINER_REGISTRY_NAME" \
340-
--image "$CONTAINER_IMAGE_NAME" \
341-
"https://github.com/Azure-Samples/container-apps-event-driven-jobs-tutorial.git"
342-
Okay, but in our case, we specify . instead of a URL. Which should push the dockerfile in . to the registry.
343-
344345
Now, push the image to your registry.
345346

346347
# [Bash](#tab/bash)
@@ -436,6 +437,8 @@ az containerapp create \
436437

437438
* Without a `query` property, the call to `az containerapp create` returns a JSON response that includes a rich set of details about the application. Adding a query parameter filters the output to just the app's fully qualified domain name (FQDN).
438439

440+
* This command adds the `acrPull` role to your user-assigned managed identity, so it can pull images from your container registry.
441+
439442
# [Azure PowerShell](#tab/azure-powershell)
440443

441444
To create the container app, create template objects that you pass in as arguments to the `New-AzContainerApp` command.
@@ -450,14 +453,7 @@ $ImageParams = @{
450453
$TemplateObj = New-AzContainerAppTemplateObject @ImageParams
451454
```
452455

453-
TODO1 Remove?
454-
Run the following command to get your registry credentials.
455-
456-
```azurepowershell
457-
$RegistryCredentials = Get-AzContainerRegistryCredential -Name $ACRName -ResourceGroupName $ResourceGroup
458-
```
459-
460-
Create a registry credential object to define your registry information, and a secret object to define your registry password. The `PasswordSecretRef` refers to the `Name` in the secret object.
456+
Create a registry credential object to define your registry information.
461457

462458
```azurepowershell
463459
$RegistryArgs = @{
@@ -466,8 +462,6 @@ $RegistryArgs = @{
466462
}
467463
$RegistryObj = New-AzContainerAppRegistryCredentialObject @RegistryArgs
468464
469-
TODO1 Remove.
470-
$SecretObj = New-AzContainerAppSecretObject -Name 'registrysecret' -Value $RegistryCredentials.Password
471465
```
472466

473467
Get your environment ID.
@@ -479,23 +473,29 @@ $EnvId = (Get-AzContainerAppManagedEnv -EnvName $Environment -ResourceGroup $Res
479473
Create the container app.
480474

481475
```azurepowershell
476+
$AppConfig = @{
477+
IngressTargetPort = 8080
478+
IngressExternal = $true
479+
Registry = $RegistryObj
480+
}
481+
$AppConfigObj = New-AzContainerAppConfigurationObject @AppConfig
482+
482483
$AppArgs = @{
483484
Name = $APIName
484485
Location = $Location
485486
ResourceGroupName = $ResourceGroup
486487
ManagedEnvironmentId = $EnvId
487488
TemplateContainer = $TemplateObj
488-
ConfigurationRegistry = $RegistryObj
489-
IngressTargetPort = 8080
490-
IngressExternal = $true
489+
Configuration = $AppConfigObj
490+
UserAssignedIdentity = @($IdentityId)
491491
}
492492
$MyApp = New-AzContainerApp @AppArgs
493493
494-
# show the app's fully qualified domain name (FQDN).
495-
$MyApp.IngressFqdn
494+
# Show the app's fully qualified domain name (FQDN).
495+
$MyApp.LatestRevisionFqdn
496496
```
497497

498-
* By setting `IngressExternal` to `external`, your container app is accessible from the public internet.
498+
* By setting `IngressExternal` to `$true`, your container app is accessible from the public internet.
499499
* The `IngressTargetPort` parameter is set to `8080` to match the port that the container is listening to for requests.
500500

501501
---

0 commit comments

Comments
 (0)