Skip to content

Commit 9fcc8b9

Browse files
author
RoseHJM
committed
Pulumi section updates
1 parent 556d126 commit 9fcc8b9

File tree

1 file changed

+24
-144
lines changed

1 file changed

+24
-144
lines changed

articles/deployment-environments/how-to-configure-extensibility-model-custom-image.md

Lines changed: 24 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,20 @@ echo "{\"outputs\": ${stackout:-{\}}}" > $ADE_OUTPUTS
457457
```
458458
::: zone-end
459459

460+
## Build a custom image
461+
462+
You can build your image using the Docker CLI. Ensure the [Docker Engine is installed](https://docs.docker.com/desktop/) on your computer. Then, navigate to the directory of your Dockerfile, and run the following command:
463+
464+
```docker
465+
docker build . -t {YOUR_REGISTRY}.azurecr.io/{YOUR_REPOSITORY}:{YOUR_TAG}
466+
```
467+
468+
For example, if you want to save your image under a repository within your registry named `customImage`, and upload with the tag version of `1.0.0`, you would run:
469+
470+
```docker
471+
docker build . -t {YOUR_REGISTRY}.azurecr.io/customImage:1.0.0
472+
```
473+
460474
## Make the custom image available to ADE
461475

462476
In order to use custom images, you need to store them in a container registry. You can use a public container registry or a private container registry. Azure Container Registry (ACR) is highly recommended, due to its tight integration with ADE, the image can be published without allowing public anonymous pull access. You must build your custom container image and push it to a container registry to make it available for use in ADE.
@@ -468,27 +482,15 @@ It's also possible to store the image in a different container registry such as
468482

469483
To use a custom image stored in ACR, you need to ensure that ADE has appropriate permissions to access your image. When you create an ACR instance, it's secure by default and only allows authenticated users to gain access.
470484

471-
::: zone pivot="arm-bicep,terraform"
485+
::: zone pivot="pulumi"
486+
You can use Pulumi to create an Azure Container Registry and publish your image to it. Refer to the [Provisioning/custom-image](https://github.com/pulumi/azure-deployment-environments/tree/main/Provisioning/custom-image) example for a self-contained Pulumi project that creates all the required resources in your Azure account.
487+
::: zone-end
472488

473489
Select the appropriate tab to learn more about each approach.
474490

475491
### [Public registry](#tab/public-registry/)
476492

477-
**1. Build the image**
478-
479-
You can build your image using the Docker CLI. Ensure the [Docker Engine is installed](https://docs.docker.com/desktop/) on your computer. Then, navigate to the directory of your Dockerfile, and run the following command:
480-
481-
```docker
482-
docker build . -t {YOUR_REGISTRY}.azurecr.io/{YOUR_REPOSITORY}:{YOUR_TAG}
483-
```
484-
485-
For example, if you want to save your image under a repository within your registry named `customImage`, and upload with the tag version of `1.0.0`, you would run:
486-
487-
```docker
488-
docker build . -t {YOUR_REGISTRY}.azurecr.io/customImage:1.0.0
489-
```
490-
491-
**2. Use a public registry with anonymous pull**
493+
**Use a public registry with anonymous pull**
492494

493495
To set up your registry to have anonymous image pull enabled, run the following commands in the Azure CLI:
494496

@@ -506,27 +508,13 @@ docker push {YOUR_REGISTRY}.azurecr.io/{YOUR_IMAGE_LOCATION}:{YOUR_TAG}
506508
```
507509
### [Private registry](#tab/private-registry/)
508510

509-
**1. Build the image**
510-
511-
You can build your image using the Docker CLI. Ensure the [Docker Engine is installed](https://docs.docker.com/desktop/) on your computer. Then, navigate to the directory of your Dockerfile, and run the following command:
512-
513-
```docker
514-
docker build . -t {YOUR_REGISTRY}.azurecr.io/{YOUR_REPOSITORY}:{YOUR_TAG}
515-
```
516-
517-
For example, if you want to save your image under a repository within your registry named `customImage`, and upload with the tag version of `1.0.0`, you would run:
518-
519-
```docker
520-
docker build . -t {YOUR_REGISTRY}.azurecr.io/customImage:1.0.0
521-
```
522-
523-
**2. Use a private registry with secured access**
511+
**Use a private registry with secured access**
524512

525513
By default, access to pull or push content from an Azure Container Registry is only available to authenticated users. You can further secure access to ACR by limiting access from certain networks and assigning specific roles.
526514

527515
To create an instance of ACR, which can be done through the Azure CLI, the Azure portal, PowerShell commands, and more, follow one of the [quickstarts](/azure/container-registry/container-registry-get-started-azure-cli).
528516

529-
**2.1 Limit network access**
517+
**1. Limit network access**
530518

531519
To secure network access to your ACR, you can limit access to your own networks, or disable public network access entirely. If you limit network access, you must enable the firewall exception *Allow trusted Microsoft services to access this container registry*.
532520

@@ -543,7 +531,7 @@ To disable access from public networks:
543531

544532
:::image type="content" source="media/how-to-configure-extensibility-bicep-container-image/container-registry-network-disable-public.png" alt-text="Screenshot of the ACR network settings, with Allow trusted Microsoft services to access this container registry and Save highlighted.":::
545533

546-
**2.2 Assign the AcrPull role**
534+
**2. Assign the AcrPull role**
547535

548536
Creating environments by using container images uses the ADE infrastructure, including projects and environment types. Each project has one or more project environment types, which need read access to the container image that defines the environment to be deployed. To access the images within your ACR securely, assign the AcrPull role to each project environment type.
549537

@@ -576,122 +564,14 @@ docker push {YOUR_REGISTRY}.azurecr.io/{YOUR_IMAGE_LOCATION}:{YOUR_TAG}
576564
```
577565
---
578566

579-
## [Build a container image with a script](#tab/build-a-container-image-with-a-script/)
567+
::: zone pivot="arm-bicep,terraform"
568+
### Build a container image with a script
580569

581570
Rather than building your custom image and pushing it to a container registry yourself, you can use a script to build and push it to a specified container registry.
582571

583572
[!INCLUDE [custom-image-script](includes/custom-image-script.md)]
584-
585573
::: zone-end
586574

587-
::: zone pivot="pulumi"
588-
### Build the image
589-
590-
Before you build the image to be pushed to your registry, ensure the [Docker Engine is installed](https://docs.docker.com/desktop/) on your computer. Then, navigate to the directory of your Dockerfile, and run the following command:
591-
592-
```docker
593-
docker build . -t {YOUR_REGISTRY}.azurecr.io/{YOUR_REPOSITORY}:{YOUR_TAG}
594-
```
595-
596-
For example, if you want to save your image under a repository within your registry named `customImage`, and upload with the tag version of `1.0.0`, you would run:
597-
598-
```docker
599-
docker build . -t {YOUR_REGISTRY}.azurecr.io/customImage:1.0.0
600-
```
601-
602-
### Push the custom image to a registry
603-
604-
In order to use custom images, you need to set up a publicly accessible image registry with anonymous image pull enabled. This way, Azure Deployment Environments can access your custom image to execute in our container.
605-
606-
#### Create an Azure Container Registry and publish your image with Pulumi
607-
608-
Azure Container Registry is an Azure offering that stores container images and similar artifacts.
609-
610-
You can use Pulumi to create an Azure Container Registry and publish your image to it. Refer to the [Provisioning/custom-image](https://github.com/pulumi/azure-deployment-environments/tree/main/Provisioning/custom-image) example for a self-contained Pulumi project that creates all the required resources in your Azure account.
611-
612-
#### Create an Azure Container Registry and publish your image manually via CLI
613-
614-
In order to use custom images, you need to store them in a container registry. Azure Container Registry (ACR) is highly recommended, due to its tight integration with ADE, the image can be published without allowing public anonymous pull access.
615-
616-
It's also possible to store the image in a different container registry such as Docker Hub, but in that case it needs to be publicly accessible.
617-
618-
> [!Caution]
619-
> Storing your container image in a registry with anonymous (unauthenticated) pull access makes it publicly accessible. Don't do that if your image contains any sensitive information. Instead, store it in Azure Container Registry (ACR) with anonymous pull access disabled.
620-
621-
To use a custom image stored in the ACR, you need to ensure that ADE has appropriate permissions to access your image. When you create an ACR instance, it's secure by default and only allows authenticated users to gain access. With this configuration, you don't have to enable anonymous pull access.
622-
623-
To create an instance of the ACR, which can be done through the Azure CLI, the Azure portal, PowerShell commands, and more, follow one of the [quickstarts](/azure/container-registry/container-registry-get-started-azure-cli).
624-
625-
#### Use a public registry with anonymous pull
626-
627-
To set up your registry to have anonymous image pull enabled, run the following commands in the Azure CLI:
628-
629-
```azurecli
630-
az login
631-
az acr login -n {YOUR_REGISTRY}
632-
az acr update -n {YOUR_REGISTRY} --public-network-enabled true
633-
az acr update -n {YOUR_REGISTRY} --anonymous-pull-enabled true
634-
```
635-
636-
When you're ready to push your image to your registry, run the following command:
637-
638-
```docker
639-
docker push {YOUR_REGISTRY}.azurecr.io/{YOUR_IMAGE_LOCATION}:{YOUR_TAG}
640-
```
641-
642-
#### Use ACR with secured access
643-
644-
By default, access to pull or push content from an Azure Container Registry is only available to authenticated users. You can further secure access to ACR by limiting access from certain networks and assigning specific roles.
645-
646-
##### Limit network access
647-
648-
To secure network access to your ACR, you can limit access to your own networks, or disable public network access entirely. If you limit network access, you must enable the firewall exception *Allow trusted Microsoft services to access this container registry*.
649-
650-
To disable access from public networks:
651-
652-
1. [Create an ACR instance](/azure/container-registry/container-registry-get-started-azure-cli) or use an existing one.
653-
1. In the Azure portal, go to the ACR that you want to configure.
654-
1. On the left menu, under **Settings**, select **Networking**.
655-
1. On the Networking page, on the **Public access** tab, under **Public network access**, select **Disabled**.
656-
657-
:::image type="content" source="media/how-to-configure-extensibility-pulumi-container-image/container-registry-network-settings.png" alt-text="Screenshot of the Azure portal, showing the ACR network settings, with Public access and Disabled highlighted.":::
658-
659-
1. Under **Firewall exception**, check that **Allow trusted Microsoft services to access this container registry** is selected, and then select **Save**.
660-
661-
:::image type="content" source="media/how-to-configure-extensibility-pulumi-container-image/container-registry-network-disable-public.png" alt-text="Screenshot of the ACR network settings, with Allow trusted Microsoft services to access this container registry and Save highlighted.":::
662-
663-
##### Assign the AcrPull role
664-
665-
Creating environments by using container images uses the ADE infrastructure, including projects and environment types. Each project has one or more project environment types, which need read access to the container image that defines the environment to be deployed. To access the images within your ACR securely, assign the AcrPull role to each project environment type.
666-
667-
To assign the AcrPull role to the Project Environment Type:
668-
669-
1. In the Azure portal, go to the ACR that you want to configure.
670-
1. On the left menu, select **Access Control (IAM)**.
671-
1. Select **Add** > **Add role assignment**.
672-
1. Assign the following role. For detailed steps, see [Assign Azure roles using the Azure portal](../role-based-access-control/role-assignments-portal.yml).
673-
674-
| Setting | Value |
675-
| --- | --- |
676-
| **Role** | Select **AcrPull**. |
677-
| **Assign access to** | Select **User, group, or service principal**. |
678-
| **Members** | Enter the name of the project environment type that needs to access the image in the container. |
679-
680-
The project environment type displays like the following example:
681-
682-
:::image type="content" source="media/how-to-configure-extensibility-pulumi-container-image/container-registry-access-control.png" alt-text="Screenshot of the Select members pane, showing a list of project environment types with part of the name highlighted.":::
683-
684-
In this configuration, ADE uses the Managed Identity for the PET, whether system assigned or user assigned.
685-
686-
> [!Tip]
687-
> This role assignment has to be made for every project environment type. It can be automated through the Azure CLI.
688-
689-
When you're ready to push your image to your registry, run the following command:
690-
691-
```docker
692-
docker push {YOUR_REGISTRY}.azurecr.io/{YOUR_IMAGE_LOCATION}:{YOUR_TAG}
693-
```
694-
::: zone-end
695575
## Connect the image to your environment definition
696576

697577
When authoring environment definitions to use your custom image in their deployment, edit the `runner` property on the manifest file (environment.yaml or manifest.yaml).
@@ -708,4 +588,4 @@ To learn more about how to create environment definitions that use the ADE conta
708588
- [ADE CLI variables reference](reference-deployment-environment-variables.md)
709589
::: zone pivot="pulumi"
710590
- [Pulumi's azure-deployment-environments repository](https://github.com/pulumi/azure-deployment-environments)
711-
::: zone-end
591+
::: zone-end

0 commit comments

Comments
 (0)