You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Learn how to deploy containers in Azure Container Instances using container images in an Azure container registry.
4
4
services: container-instances
5
5
ms.topic: article
6
-
ms.date: 01/04/2019
6
+
ms.date: 12/30/2019
7
7
ms.author: danlep
8
8
ms.custom: mvc
9
9
---
@@ -20,15 +20,19 @@ ms.custom: mvc
20
20
21
21
## Configure registry authentication
22
22
23
-
In any production scenario, access to an Azure container registry should be provided by using [service principals](../container-registry/container-registry-auth-service-principal.md). Service principals allow you to provide [role-based access control](../container-registry/container-registry-roles.md) to your container images. For example, you can configure a service principal with pull-only access to a registry.
23
+
In a production scenario where you provide access to "headless" services and applications, it's recommended to configure registry access by using a [service principal](../container-registry/container-registry-auth-service-principal.md). A service principal allows you to provide [role-based access control](../container-registry/container-registry-roles.md) to your container images. For example, you can configure a service principal with pull-only access to a registry.
In the following section, you create an Azure key vault and a service principal, and store the service principal's credentials in the vault.
26
28
27
29
### Create key vault
28
30
29
31
If you don't already have a vault in [Azure Key Vault](../key-vault/key-vault-overview.md), create one with the Azure CLI using the following commands.
30
32
31
-
Update the `RES_GROUP` variable with the name of an existing resource group in which to create the key vault, and `ACR_NAME` with the name of your container registry. Specify a name for your new key vault in `AKV_NAME`. The vault name must be unique within Azure and must be 3-24 alphanumeric characters in length, begin with a letter, end with a letter or digit, and cannot contain consecutive hyphens.
33
+
Update the `RES_GROUP` variable with the name of an existing resource group in which to create the key vault, and `ACR_NAME` with the name of your container registry. For brevity, commands in this article assume that your registry, key vault, and container instances are all created in the same resource group.
34
+
35
+
Specify a name for your new key vault in `AKV_NAME`. The vault name must be unique within Azure and must be 3-24 alphanumeric characters in length, begin with a letter, end with a letter or digit, and cannot contain consecutive hyphens.
### Create service principal and store credentials
42
46
43
-
You now need to create a service principal and store its credentials in your key vault.
47
+
Now create a service principal and store its credentials in your key vault.
44
48
45
49
The following command uses [az ad sp create-for-rbac][az-ad-sp-create-for-rbac] to create the service principal, and [az keyvault secret set][az-keyvault-secret-set] to store the service principal's **password** in the vault.
46
50
47
51
```azurecli
48
-
# Create service principal, store its password in AKV (the registry *password*)
52
+
# Create service principal, store its password in vault (the registry *password*)
49
53
az keyvault secret set \
50
54
--vault-name $AKV_NAME \
51
55
--name $ACR_NAME-pull-pwd \
@@ -62,14 +66,14 @@ The `--role` argument in the preceding command configures the service principal
62
66
Next, store the service principal's *appId* in the vault, which is the **username** you pass to Azure Container Registry for authentication.
63
67
64
68
```azurecli
65
-
# Store service principal ID in AKV (the registry *username*)
69
+
# Store service principal ID in vault (the registry *username*)
66
70
az keyvault secret set \
67
71
--vault-name $AKV_NAME \
68
72
--name $ACR_NAME-pull-usr \
69
73
--value $(az ad sp show --id http://$ACR_NAME-pull --query appId --output tsv)
70
74
```
71
75
72
-
You've created an Azure Key Vault and stored two secrets in it:
76
+
You've created an Azure key vault and stored two secrets in it:
73
77
74
78
*`$ACR_NAME-pull-usr`: The service principal ID, for use as the container registry **username**.
75
79
*`$ACR_NAME-pull-pwd`: The service principal password, for use as the container registry **password**.
@@ -111,18 +115,22 @@ Once the container has started successfully, you can navigate to its FQDN in you
111
115
112
116
## Deploy with Azure Resource Manager template
113
117
114
-
You can specify the properties of your Azure Container Registry in an Azure Resource Manager template by including the `imageRegistryCredentials` property in the container group definition:
118
+
You can specify the properties of your Azure container registry in an Azure Resource Manager template by including the `imageRegistryCredentials` property in the container group definition. For example, you can specify the registry credentials directly:
115
119
116
120
```JSON
121
+
[...]
117
122
"imageRegistryCredentials": [
118
123
{
119
124
"server": "imageRegistryLoginServer",
120
125
"username": "imageRegistryUsername",
121
126
"password": "imageRegistryPassword"
122
127
}
123
128
]
129
+
[...]
124
130
```
125
131
132
+
For complete container group settings, see the [Resource Manager template reference](/azure/templates/Microsoft.ContainerInstance/2018-10-01/containerGroups).
133
+
126
134
For details on referencing Azure Key Vault secrets in a Resource Manager template, see [Use Azure Key Vault to pass secure parameter value during deployment](../azure-resource-manager/resource-manager-keyvault-parameter.md).
0 commit comments