Skip to content

Commit 57e58cb

Browse files
committed
Edits.
1 parent c5fa8be commit 57e58cb

File tree

1 file changed

+123
-125
lines changed

1 file changed

+123
-125
lines changed

articles/container-apps/get-started-existing-container-image.md

Lines changed: 123 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -41,185 +41,183 @@ Now that you have an environment created, you can deploy your first container ap
4141

4242
::: zone pivot="container-apps-private-registry"
4343

44-
TODO1 Replace these H3s with a numbered list?
44+
1. Set environment variables
4545

46-
### Set environment variables
46+
Replace the \<PLACEHOLDERS\> with your values. Your user principal name will typically be in the format of an email address (for example, `[email protected]`).
4747

48-
Replace the \<PLACEHOLDERS\> with your values. Your user principal name will typically be in the format of an email address (for example, `[email protected]`).
48+
# [Bash](#tab/bash)
4949

50-
# [Bash](#tab/bash)
50+
```bash
51+
KEY_VAULT_NAME=<KEY_VAULT_NAME>
52+
USER_PRINCIPAL_NAME=<USER_PRINCIPAL_NAME>
53+
SECRET_NAME=<SECRET_NAME>
54+
CONTAINER_IMAGE_NAME=<CONTAINER_IMAGE_NAME>
55+
REGISTRY_SERVER=<REGISTRY_SERVER>
56+
REGISTRY_USERNAME=<REGISTRY_USERNAME>
57+
```
5158

52-
```bash
53-
KEY_VAULT_NAME=<KEY_VAULT_NAME>
54-
USER_PRINCIPAL_NAME=<USER_PRINCIPAL_NAME>
55-
SECRET_NAME=<SECRET_NAME>
56-
CONTAINER_IMAGE_NAME=<CONTAINER_IMAGE_NAME>
57-
REGISTRY_SERVER=<REGISTRY_SERVER>
58-
REGISTRY_USERNAME=<REGISTRY_USERNAME>
59-
```
59+
# [Azure PowerShell](#tab/azure-powershell)
6060

61-
# [Azure PowerShell](#tab/azure-powershell)
61+
```azurepowershell-interactive
62+
$KeyVaultName = "<KEY_VAULT_NAME>"
63+
$UserPrincipalName = "<USER_PRINCIPAL_NAME>"
64+
$SecretName = "<SECRET_NAME>"
65+
$ContainerImageName = "<CONTAINER_IMAGE_NAME>"
66+
$RegistryServer = "<REGISTRY_SERVER>"
67+
$RegistryUsername = "<REGISTRY_USERNAME>"
68+
```
6269

63-
```azurepowershell-interactive
64-
$KeyVaultName = "<KEY_VAULT_NAME>"
65-
$UserPrincipalName = "<USER_PRINCIPAL_NAME>"
66-
$SecretName = "<SECRET_NAME>"
67-
$ContainerImageName = "<CONTAINER_IMAGE_NAME>"
68-
$RegistryServer = "<REGISTRY_SERVER>"
69-
$RegistryUsername = "<REGISTRY_USERNAME>"
70-
```
70+
---
7171

72-
---
72+
1. Create key vault
7373

74-
### Create key vault
74+
It is recommended to store your container registry password using a service such as [Azure Key Vault](https://learn.microsoft.com/en-us/azure/key-vault/general/basic-concepts). The steps in this section explain how to create a key vault, store your container registry password as a secret in the key vault, and then retrieve the password for use in your code.
7575

76-
TODO1 Explain why you should use a key vault to store your registry password. We could just link to one of the quickstarts below on creating a key vault and storing a secret in it, and only include the command for retrieving the secret here.
76+
# [Bash](#tab/bash)
7777

78-
# [Bash](#tab/bash)
78+
```bash
79+
az keyvault create --name $KEY_VAULT_NAME --resource-group $RESOURCE_GROUP
80+
```
7981

80-
```bash
81-
az keyvault create --name $KEY_VAULT_NAME --resource-group $RESOURCE_GROUP
82-
```
83-
84-
# [Azure PowerShell](#tab/azure-powershell)
82+
# [Azure PowerShell](#tab/azure-powershell)
8583

86-
First make sure you have installed the [KeyVault](https://www.powershellgallery.com/packages/Az.KeyVault) module.
84+
First make sure you have installed the [KeyVault](https://www.powershellgallery.com/packages/Az.KeyVault) module.
8785

88-
```azurepowershell-interactive
89-
Install-Module Az.KeyVault -Repository PSGallery -Force
90-
```
86+
```azurepowershell-interactive
87+
Install-Module Az.KeyVault -Repository PSGallery -Force
88+
```
9189

92-
```azurepowershell-interactive
93-
New-AzKeyVault -Name "$KeyVaultName" -ResourceGroupName "$ResourceGroupName" -Location "$Location"
94-
```
90+
```azurepowershell-interactive
91+
New-AzKeyVault -Name "$KeyVaultName" -ResourceGroupName "$ResourceGroupName" -Location "$Location"
92+
```
9593

96-
---
94+
---
9795

98-
### Give your user account permissions to manage secrets in the key vault
96+
1. Give your user account permissions to manage secrets in the key vault
9997

100-
# [Bash](#tab/bash)
98+
# [Bash](#tab/bash)
10199

102-
```bash
103-
KEY_VAULT_ID=$(az keyvault show --name $KEY_VAULT_NAME --query id --output tsv)
104-
az role assignment create --role "Key Vault Secrets Officer" --assignee "$USER_PRINCIPAL_NAME" --scope "$KEY_VAULT_ID"
105-
```
100+
```bash
101+
KEY_VAULT_ID=$(az keyvault show --name $KEY_VAULT_NAME --query id --output tsv)
102+
az role assignment create --role "Key Vault Secrets Officer" --assignee "$USER_PRINCIPAL_NAME" --scope "$KEY_VAULT_ID"
103+
```
106104

107-
# [Azure PowerShell](#tab/azure-powershell)
105+
# [Azure PowerShell](#tab/azure-powershell)
108106

109-
```azurepowershell-interactive
110-
$KeyVault=Get-AzKeyVault -VaultName $KeyVaultName
111-
New-AzRoleAssignment -SignInName "$UserPrincipalName" -RoleDefinitionName "Key Vault Secrets Officer" -Scope $KeyVault.ResourceID
112-
```
107+
```azurepowershell-interactive
108+
$KeyVault=Get-AzKeyVault -VaultName $KeyVaultName
109+
New-AzRoleAssignment -SignInName "$UserPrincipalName" -RoleDefinitionName "Key Vault Secrets Officer" -Scope $KeyVault.ResourceID
110+
```
113111

114-
---
112+
---
115113

116-
### Store container registry password
114+
1. Store container registry password
117115

118-
Replace the \<PLACEHOLDERS\> with your values.
116+
Replace the \<PLACEHOLDERS\> with your values.
119117

120-
TODO1 We are deliberately not using an env var to store the registry password here.
118+
TODO1 I'm deliberately not using an env var to store the registry password here. You can delete this line with a suggestion.
121119

122-
# [Bash](#tab/bash)
120+
# [Bash](#tab/bash)
123121

124-
TODO1 There does not seem to be an Azure CLI equivalent for "convert to secure string."
122+
TODO1 Per Copilot there does not seem to be an Azure CLI equivalent for ConvertTo-SecureString (except using Key Vault itself). You can delete this line with a suggestion.
125123

126-
```bash
127-
az keyvault secret set --vault-name $KEY_VAULT_NAME --name $SECRET_NAME --value "<REGISTRY_PASSWORD>"
128-
```
124+
```bash
125+
az keyvault secret set --vault-name $KEY_VAULT_NAME --name $SECRET_NAME --value "<REGISTRY_PASSWORD>"
126+
```
129127

130-
# [Azure PowerShell](#tab/azure-powershell)
128+
# [Azure PowerShell](#tab/azure-powershell)
131129

132-
```azurepowershell-interactive
133-
$Secret = ConvertTo-SecureString -String "<REGISTRY_PASSWORD>" -AsPlainText -Force
134-
Set-AzKeyVaultSecret -VaultName "$KeyVaultName" -Name "$SecretName" -SecretValue "$Secret"
135-
```
130+
```azurepowershell-interactive
131+
$Secret = ConvertTo-SecureString -String "<REGISTRY_PASSWORD>" -AsPlainText -Force
132+
Set-AzKeyVaultSecret -VaultName "$KeyVaultName" -Name "$SecretName" -SecretValue "$Secret"
133+
```
136134

137-
---
135+
---
138136

139-
### Retrieve container registry password
137+
1. Retrieve container registry password
140138

141-
# [Bash](#tab/bash)
139+
# [Bash](#tab/bash)
142140

143-
```bash
144-
REGISTRY_PASSWORD=$(az keyvault secret show --name $SECRET_NAME --vault-name $KEY_VAULT_NAME --query value --output tsv)
145-
```
141+
```bash
142+
REGISTRY_PASSWORD=$(az keyvault secret show --name $SECRET_NAME --vault-name $KEY_VAULT_NAME --query value --output tsv)
143+
```
146144

147-
For more information, see
148-
- [Quickstart: Set and retrieve a secret from Azure Key Vault using Azure CLI](../key-vault/secrets/quick-create-cli)
149-
- [Manage Key Vault using the Azure CLI](../key-vault/general/manage-with-cli2.md)
145+
For more information, see
146+
- [Quickstart: Set and retrieve a secret from Azure Key Vault using Azure CLI](../key-vault/secrets/quick-create-cli)
147+
- [Manage Key Vault using the Azure CLI](../key-vault/general/manage-with-cli2.md)
150148

151-
# [Azure PowerShell](#tab/azure-powershell)
149+
# [Azure PowerShell](#tab/azure-powershell)
152150

153-
```azurepowershell-interactive
154-
$RegistryPassword = Get-AzKeyVaultSecret -VaultName "$KeyVaultName" -Name "$SecretName" -AsPlainText
155-
```
151+
```azurepowershell-interactive
152+
$RegistryPassword = Get-AzKeyVaultSecret -VaultName "$KeyVaultName" -Name "$SecretName" -AsPlainText
153+
```
156154

157-
For more information, see
158-
- [Quickstart: Set and retrieve a secret from Azure Key Vault using PowerShell](../key-vault/secrets/quick-create-powershell)
159-
- [Use Azure Key Vault in automation](../../powershell/utility-modules/secretmanagement/how-to/using-azure-keyvault?view=ps-modules)
155+
For more information, see
156+
- [Quickstart: Set and retrieve a secret from Azure Key Vault using PowerShell](../key-vault/secrets/quick-create-powershell)
157+
- [Use Azure Key Vault in automation](../../powershell/utility-modules/secretmanagement/how-to/using-azure-keyvault?view=ps-modules)
160158

161-
---
159+
---
162160

163-
### Create container app
161+
1. Create container app
164162

165-
With the `containerapp create` command, deploy a container image to Azure Container Apps.
163+
With the `containerapp create` command, deploy a container image to Azure Container Apps.
166164

167-
The example shown in this article demonstrates how to use a custom container image with common commands. Your container image might need more parameters for the following items:
165+
The example shown in this article demonstrates how to use a custom container image with common commands. Your container image might need more parameters for the following items:
168166

169-
- Set the revision mode
170-
- Define secrets
171-
- Define environment variables
172-
- Set container CPU or memory requirements
173-
- Enable and configure Dapr
174-
- Enable external or internal ingress
175-
- Provide minimum and maximum replica values or scale rules
167+
- Set the revision mode
168+
- Define secrets
169+
- Define environment variables
170+
- Set container CPU or memory requirements
171+
- Enable and configure Dapr
172+
- Enable external or internal ingress
173+
- Provide minimum and maximum replica values or scale rules
176174

177-
# [Bash](#tab/bash)
175+
# [Bash](#tab/bash)
178176

179-
For details on how to provide values for any of these parameters to the `create` command, run `az containerapp create --help` or [visit the online reference](/cli/azure/containerapp#az-containerapp-create). To generate credentials for an Azure Container Registry, use [az acr credential show](/cli/azure/acr/credential#az-acr-credential-show).
177+
For details on how to provide values for any of these parameters to the `create` command, run `az containerapp create --help` or [visit the online reference](/cli/azure/containerapp#az-containerapp-create). To generate credentials for an Azure Container Registry, use [az acr credential show](/cli/azure/acr/credential#az-acr-credential-show).
180178

181-
```azurecli-interactive
182-
az containerapp create \
183-
--name my-container-app \
184-
--resource-group $RESOURCE_GROUP \
185-
--image $CONTAINER_IMAGE_NAME \
186-
--environment $CONTAINERAPPS_ENVIRONMENT \
187-
--registry-server $REGISTRY_SERVER \
188-
--registry-username $REGISTRY_USERNAME \
189-
--registry-password $REGISTRY_PASSWORD
190-
```
179+
```azurecli-interactive
180+
az containerapp create \
181+
--name my-container-app \
182+
--resource-group $RESOURCE_GROUP \
183+
--image $CONTAINER_IMAGE_NAME \
184+
--environment $CONTAINERAPPS_ENVIRONMENT \
185+
--registry-server $REGISTRY_SERVER \
186+
--registry-username $REGISTRY_USERNAME \
187+
--registry-password $REGISTRY_PASSWORD
188+
```
191189

192-
# [Azure PowerShell](#tab/azure-powershell)
190+
# [Azure PowerShell](#tab/azure-powershell)
193191

194-
```azurepowershell-interactive
195-
$EnvId = (Get-AzContainerAppManagedEnv -ResourceGroupName $ResourceGroupName -EnvName $ContainerAppsEnvironment).Id
192+
```azurepowershell-interactive
193+
$EnvId = (Get-AzContainerAppManagedEnv -ResourceGroupName $ResourceGroupName -EnvName $ContainerAppsEnvironment).Id
196194

197-
$TemplateObj = New-AzContainerAppTemplateObject -Name my-container-app -Image $ContainerImageName
195+
$TemplateObj = New-AzContainerAppTemplateObject -Name my-container-app -Image $ContainerImageName
198196

199-
$RegistrySecretObj = New-AzContainerAppSecretObject -Name registry-secret -Value $RegistryPassword
197+
$RegistrySecretObj = New-AzContainerAppSecretObject -Name registry-secret -Value $RegistryPassword
200198

201-
$RegistryArgs = @{
202-
PasswordSecretRef = 'registry-secret'
203-
Server = $RegistryServer
204-
Username = $RegistryUsername
205-
}
199+
$RegistryArgs = @{
200+
PasswordSecretRef = 'registry-secret'
201+
Server = $RegistryServer
202+
Username = $RegistryUsername
203+
}
206204

207-
$RegistryObj = New-AzContainerAppRegistryCredentialObject @RegistryArgs
205+
$RegistryObj = New-AzContainerAppRegistryCredentialObject @RegistryArgs
208206

209-
$ContainerAppArgs = @{
210-
Name = 'my-container-app'
211-
Location = $Location
212-
ResourceGroupName = $ResourceGroupName
213-
ManagedEnvironmentId = $EnvId
214-
TemplateContainer = $TemplateObj
215-
ConfigurationRegistry = $RegistryObj
216-
ConfigurationSecret = $RegistrySecretObj
217-
}
207+
$ContainerAppArgs = @{
208+
Name = 'my-container-app'
209+
Location = $Location
210+
ResourceGroupName = $ResourceGroupName
211+
ManagedEnvironmentId = $EnvId
212+
TemplateContainer = $TemplateObj
213+
ConfigurationRegistry = $RegistryObj
214+
ConfigurationSecret = $RegistrySecretObj
215+
}
218216

219-
New-AzContainerApp @ContainerAppArgs
220-
```
217+
New-AzContainerApp @ContainerAppArgs
218+
```
221219

222-
---
220+
---
223221

224222
::: zone-end
225223

0 commit comments

Comments
 (0)