Skip to content

Commit e124bc2

Browse files
committed
Updated docs to cover ACI deployment in vnet pulling from ACR behind private endpoint
1 parent 868a941 commit e124bc2

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

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+
Managed identity can also be used to deploy an Azure Container instance or group in a virtual network and authenticate with an Azure Container Registry (ACR) instance that runs behind a 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 in a vnet 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).
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 in a vnet 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).
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,8 @@ az group delete --name $RESOURCE_GROUP
475475

476476
* [Troubleshoot Azure Private Endpoint connectivity problems](../private-link/troubleshoot-private-endpoint-connectivity.md)
477477

478+
* If you need to deploy Azure Container Instances that can pull from an ACR that runs behind 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)
479+
478480
<!-- LINKS - external -->
479481
[docker-linux]: https://docs.docker.com/engine/installation/#supported-platforms
480482
[docker-login]: https://docs.docker.com/engine/reference/commandline/login/

0 commit comments

Comments
 (0)