Skip to content

Commit 7208033

Browse files
authored
Merge pull request #227461 from norelina/norelina/acr-in-vnet-acr-private-endpoint
ACI deployment in vnet pulling from ACR behind private endpoint
2 parents 6d64fc3 + b8edbaa commit 7208033

File tree

3 files changed

+69
-3
lines changed

3 files changed

+69
-3
lines changed

articles/container-instances/container-instances-vnet.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,11 @@ az network vnet delete --resource-group $RES_GROUP --name aci-vnet
213213

214214
## Next steps
215215

216-
To deploy a new virtual network, subnet, network profile, and container group using a Resource Manager template, see [Create an Azure container group with VNet](https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.containerinstance/aci-vnet
216+
* To deploy a new virtual network, subnet, network profile, and container group using a Resource Manager template, see [Create an Azure container group with VNet](https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.containerinstance/aci-vnet
217217
).
218218

219+
* To deploy Azure Container Instances that can pull images from an Azure Container Registry through a private endpoint, see [Deploy to Azure Container Instances from Azure Container Registry using a managed identity](../container-instances/using-azure-container-registry-mi.md).
220+
219221
<!-- IMAGES -->
220222
[aci-vnet-01]: ./media/container-instances-vnet/aci-vnet-01.png
221223

articles/container-instances/using-azure-container-registry-mi.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ ms.custom: mvc, devx-track-azurecli
1414

1515
[Azure Container Registry][acr-overview] (ACR) is an Azure-based, managed container registry service used to store private Docker container images. This article describes how to pull container images stored in an Azure container registry when deploying to container groups with Azure Container Instances. One way to configure registry access is to create an Azure Active Directory managed identity.
1616

17+
When access to an Azure Container Registry (ACR) is [restricted using a private endpoint](../container-registry/container-registry-private-link.md), using a managed identity allows Azure Container Instances [deployed into a virtual network](container-instances-vnet.md) to access the container registry through the private endpoint.
18+
1719
## Prerequisites
1820

1921
**Azure container registry**: You need a premium SKU Azure container registry with at least one image. If you need to create a registry, see [Create a container registry using the Azure CLI][acr-get-started]. Be sure to take note of the registry's `id` and `loginServer`
@@ -162,6 +164,66 @@ To deploy a container group using managed identity to authenticate image pulls v
162164
az container create --name my-containergroup --resource-group myResourceGroup --image <loginServer>/hello-world:v1 --acr-identity $userID --assign-identity $userID --ports 80 --dns-name-label <dns-label>
163165
```
164166

167+
## Deploy in a virtual network using the Azure CLI
168+
169+
To deploy a container group to a virtual network using managed identity to authenticate image pulls from an ACR that runs behind a private endpoint via the Azure CLI, use the following command:
170+
171+
```azurecli-interactive
172+
az container create --name my-containergroup --resource-group myResourceGroup --image <loginServer>/hello-world:v1 --acr-identity $userID --assign-identity $userID --vnet "/subscriptions/$SUBSCRIPTION_ID/resourceGroups/"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourceGroups/myVNetResourceGroup/providers/ --subnet mySubnetName
173+
```
174+
175+
For more info on how to deploy to a virtual network see [Deploy container instances into an Azure virtual network](./container-instances-vnet.md).
176+
177+
## Deploy a multi-container group in a virtual network using YAML and the Azure CLI
178+
179+
To deploy a multi-container group to a virtual network using managed identity to authenticate image pulls from an ACR that runs behind a private endpoint via the Azure CLI, you can specify the container group configuration in a YAML file. Then pass the YAML file as a parameter to the command.
180+
181+
```yaml
182+
apiVersion: '2021-10-01'
183+
location: eastus
184+
type: Microsoft.ContainerInstance/containerGroups
185+
identity:
186+
type: UserAssigned
187+
userAssignedIdentities: {
188+
'/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourcegroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myACRId': {}
189+
}
190+
properties:
191+
osType: Linux
192+
imageRegistryCredentials:
193+
- server: myacr.azurecr.io
194+
identity: '/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourcegroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myACRId'
195+
subnetIds:
196+
- id: '/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourceGroups/myVNetResourceGroup/providers/Microsoft.Network/virtualNetworks/myVNetName/subnets/mySubnetName'
197+
name: mySubnetName
198+
containers:
199+
- name: myContainer-1
200+
properties:
201+
resources:
202+
requests:
203+
cpu: '.4'
204+
memoryInGb: '1'
205+
environmentVariables:
206+
- name: CONTAINER
207+
value: 1
208+
image: 'myacr.azurecr.io/myimage:latest'
209+
- name: myContainer-2
210+
properties:
211+
resources:
212+
requests:
213+
cpu: '.4'
214+
memoryInGb: '1'
215+
environmentVariables:
216+
- name: CONTAINER
217+
value: 2
218+
image: 'myacr.azurecr.io/myimage:latest'
219+
```
220+
221+
```azurecli-interactive
222+
az container create --name my-containergroup --resource-group myResourceGroup --file my-YAML-file.yaml
223+
```
224+
225+
For more info on how to deploy to a multi-container group see [Deploy a multi-container group](./container-instances-multi-container-yaml.md).
226+
165227
## Clean up resources
166228

167229
To remove all resources from your Azure subscription, delete the resource group:

articles/container-registry/container-registry-private-link.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,11 +469,13 @@ az group delete --name $RESOURCE_GROUP
469469

470470
* To learn more about Private Link, see the [Azure Private Link](../private-link/private-link-overview.md) documentation.
471471

472-
* To verify DNS settings in the virtual network that route to a private endpoint, run the [az acr check-health](/cli/azure/acr#az-acr-check-health) command with the `--vnet` parameter. For more information, see [Check the health of an Azure container registry](container-registry-check-health.md)
472+
* To verify DNS settings in the virtual network that route to a private endpoint, run the [az acr check-health](/cli/azure/acr#az-acr-check-health) command with the `--vnet` parameter. For more information, see [Check the health of an Azure container registry](container-registry-check-health.md).
473473

474474
* If you need to set up registry access rules from behind a client firewall, see [Configure rules to access an Azure container registry behind a firewall](container-registry-firewall-access-rules.md).
475475

476-
* [Troubleshoot Azure Private Endpoint connectivity problems](../private-link/troubleshoot-private-endpoint-connectivity.md)
476+
* [Troubleshoot Azure Private Endpoint connectivity problems](../private-link/troubleshoot-private-endpoint-connectivity.md).
477+
478+
* If you need to deploy Azure Container Instances that can pull images from an ACR through a private endpoint, see [Deploy to Azure Container Instances from Azure Container Registry using a managed identity](../container-instances/using-azure-container-registry-mi.md).
477479

478480
<!-- LINKS - external -->
479481
[docker-linux]: https://docs.docker.com/engine/installation/#supported-platforms

0 commit comments

Comments
 (0)