Skip to content

Commit 495a54c

Browse files
authored
Merge pull request #194207 from carlrab/azurecli-docs-container-registry
update for script updates and refresh
2 parents 5a86494 + b2fa1d5 commit 495a54c

5 files changed

+24
-23
lines changed

articles/container-registry/container-registry-auth-aci.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ The following articles contain additional details on working with service princi
5252
<!-- IMAGES -->
5353

5454
<!-- LINKS - External -->
55-
[acr-scripts-cli]: https://github.com/Azure/azure-docs-cli-python-samples/tree/master/container-registry
55+
[acr-scripts-cli]: https://github.com/Azure/azure-docs-cli-python-samples/tree/master/container-registry/create-registry/create-registry-service-principal-assign-role.sh
5656
[acr-scripts-psh]: https://github.com/Azure/azure-docs-powershell-samples/tree/master/container-registry
5757

5858
<!-- LINKS - Internal -->

articles/container-registry/container-registry-auth-kubernetes.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ This command returns a new, valid password for your service principal.
3333

3434
## Create an image pull secret
3535

36-
Kubernetes uses an *image pull secret* to store information needed to authenticate to your registry. To create the pull secret for an Azure container registry, you provide the service principal ID, password, and the registry URL.
36+
Kubernetes uses an *image pull secret* to store information needed to authenticate to your registry. To create the pull secret for an Azure container registry, you provide the service principal ID, password, and the registry URL.
3737

3838
Create an image pull secret with the following `kubectl` command:
3939

@@ -44,6 +44,7 @@ kubectl create secret docker-registry <secret-name> \
4444
--docker-username=<service-principal-ID> \
4545
--docker-password=<service-principal-password>
4646
```
47+
4748
where:
4849

4950
| Value | Description |
@@ -75,17 +76,15 @@ spec:
7576
7677
In the preceding example, `my-awesome-app:v1` is the name of the image to pull from the Azure container registry, and `acr-secret` is the name of the pull secret you created to access the registry. When you deploy the pod, Kubernetes automatically pulls the image from your registry, if it is not already present on the cluster.
7778

78-
7979
## Next steps
8080

8181
* For more about working with service principals and Azure Container Registry, see [Azure Container Registry authentication with service principals](container-registry-auth-service-principal.md)
8282
* Learn more about image pull secrets in the [Kubernetes documentation](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod)
8383

84-
8584
<!-- IMAGES -->
8685

8786
<!-- LINKS - External -->
88-
[acr-scripts-cli]: https://github.com/Azure/azure-docs-cli-python-samples/tree/master/container-registry
87+
[acr-scripts-cli]: https://github.com/Azure/azure-docs-cli-python-samples/tree/master/container-registry/create-registry/create-registry-service-principal-assign-role.sh
8988
[acr-scripts-psh]: https://github.com/Azure/azure-docs-powershell-samples/tree/master/container-registry
9089

9190
<!-- LINKS - Internal -->

articles/container-registry/container-registry-auth-service-principal.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ For example, configure your web application to use a service principal that prov
2525

2626
You should use a service principal to provide registry access in **headless scenarios**. That is, an application, service, or script that must push or pull container images in an automated or otherwise unattended manner. For example:
2727

28-
* *Pull*: Deploy containers from a registry to orchestration systems including Kubernetes, DC/OS, and Docker Swarm. You can also pull from container registries to related Azure services such as [Azure Container Instances](container-registry-auth-aci.md), [App Service](../app-service/index.yml), [Batch](../batch/index.yml), [Service Fabric](../service-fabric/index.yml), and others.
28+
* *Pull*: Deploy containers from a registry to orchestration systems including Kubernetes, DC/OS, and Docker Swarm. You can also pull from container registries to related Azure services such as [Azure Container Instances](container-registry-auth-aci.md), [App Service](../app-service/index.yml), [Batch](../batch/index.yml), [Service Fabric](../service-fabric/index.yml), and others.
2929

3030
> [!TIP]
31-
> A service principal is recommended in several [Kubernetes scenarios](authenticate-kubernetes-options.md) to pull images from an Azure container registry. With Azure Kubernetes Service (AKS), you can also use an automated mechanism to authenticate with a target registry by enabling the cluster's [managed identity](../aks/cluster-container-registry-integration.md).
31+
> A service principal is recommended in several [Kubernetes scenarios](authenticate-kubernetes-options.md) to pull images from an Azure container registry. With Azure Kubernetes Service (AKS), you can also use an automated mechanism to authenticate with a target registry by enabling the cluster's [managed identity](../aks/cluster-container-registry-integration.md).
3232
* *Push*: Build container images and push them to a registry using continuous integration and deployment solutions like Azure Pipelines or Jenkins.
3333

3434
For individual access to a registry, such as when you manually pull a container image to your development workstation, we recommend using your own [Azure AD identity](container-registry-authentication.md#individual-login-with-azure-ad) instead for registry access (for example, with [az acr login][az-acr-login]).
@@ -49,7 +49,7 @@ Once you have a service principal that you've granted access to your container r
4949
* **User name** - service principal's **application (client) ID**
5050
* **Password** - service principal's **password (client secret)**
5151

52-
Each value has the format `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`.
52+
Each value has the format `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`.
5353

5454
> [!TIP]
5555
> You can regenerate the password (client secret) of a service principal by running the [az ad sp credential reset](/cli/azure/ad/sp/credential#az-ad-sp-credential-reset) command.
@@ -74,7 +74,7 @@ Once logged in, Docker caches the credentials.
7474

7575
### Use with certificate
7676

77-
If you've added a certificate to your service principal, you can sign into the Azure CLI with certificate-based authentication, and then use the [az acr login][az-acr-login] command to access a registry. Using a certificate as a secret instead of a password provides additional security when you use the CLI.
77+
If you've added a certificate to your service principal, you can sign into the Azure CLI with certificate-based authentication, and then use the [az acr login][az-acr-login] command to access a registry. Using a certificate as a secret instead of a password provides additional security when you use the CLI.
7878

7979
A self-signed certificate can be created when you [create a service principal](/cli/azure/create-an-azure-service-principal-azure-cli). Or, add one or more certificates to an existing service principal. For example, if you use one of the scripts in this article to create or update a service principal with rights to pull or push images from a registry, add a certificate using the [az ad sp credential reset][az-ad-sp-credential-reset] command.
8080

@@ -98,7 +98,7 @@ A service principal can also be used in Azure scenarios that require pulling ima
9898

9999
To create a service principal that can authenticate with a container registry in a cross-tenant scenario:
100100

101-
* Create a [multitenant app](../active-directory/develop/single-and-multi-tenant-apps.md) (service principal) in Tenant A
101+
* Create a [multitenant app](../active-directory/develop/single-and-multi-tenant-apps.md) (service principal) in Tenant A
102102
* Provision the app in Tenant B
103103
* Grant the service principal permissions to pull from the registry in Tenant B
104104
* Update the service or app in Tenant A to authenticate using the new service principal
@@ -107,7 +107,7 @@ For example steps, see [Pull images from a container registry to an AKS cluster
107107

108108
## Service principal renewal
109109

110-
The service principal is created with one-year validity. You have options to extend the validity further than one year, or can provide expiry date of your choice using the [`az ad sp credential reset`](/cli/azure/ad/sp/credential#az-ad-sp-credential-reset) command.
110+
The service principal is created with one-year validity. You have options to extend the validity further than one year, or can provide expiry date of your choice using the [`az ad sp credential reset`](/cli/azure/ad/sp/credential#az-ad-sp-credential-reset) command.
111111

112112
## Next steps
113113

@@ -116,7 +116,7 @@ The service principal is created with one-year validity. You have options to ext
116116
* For an example of using an Azure key vault to store and retrieve service principal credentials for a container registry, see the tutorial to [build and deploy a container image using ACR Tasks](container-registry-tutorial-quick-task.md).
117117

118118
<!-- LINKS - External -->
119-
[acr-scripts-cli]: https://github.com/Azure/azure-docs-cli-python-samples/tree/master/container-registry
119+
[acr-scripts-cli]: https://github.com/Azure/azure-docs-cli-python-samples/tree/master/container-registry/create-registry/create-registry-service-principal-assign-role.sh
120120
[acr-scripts-psh]: https://github.com/Azure/azure-docs-powershell-samples/tree/master/container-registry
121121

122122
<!-- LINKS - Internal -->

articles/container-registry/container-registry-tutorial-multistep-task.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ ms.custom: "seodec18, mvc, devx-track-azurecli"
99

1010
# Tutorial: Run a multi-step container workflow in the cloud when you commit source code
1111

12-
In addition to a [quick task](container-registry-tutorial-quick-task.md), ACR Tasks supports multi-step, multi-container-based workflows that can automatically trigger when you commit source code to a Git repository.
12+
In addition to a [quick task](container-registry-tutorial-quick-task.md), ACR Tasks supports multi-step, multi-container-based workflows that can automatically trigger when you commit source code to a Git repository.
1313

1414
In this tutorial, you learn how to use example YAML files to define multi-step tasks that build, run, and push one or more container images to a registry when you commit source code. To create a task that only automates a single image build on code commit, see [Tutorial: Automate container image builds in the cloud when you commit source code](container-registry-tutorial-build-task.md). For an overview of ACR Tasks, see [Automate OS and framework patching with ACR Tasks](container-registry-tasks-overview.md),
1515

1616
In this tutorial:
1717

1818
> [!div class="checklist"]
19+
>
1920
> * Define a multi-step task using a YAML file
2021
> * Create a task
2122
> * Optionally add credentials to the task to enable access to another registry
@@ -54,7 +55,7 @@ steps:
5455
5556
This multi-step task does the following:
5657
57-
1. Runs a `build` step to build an image from the Dockerfile in the working directory. The image targets the `Run.Registry`, the registry where the task is run, and is tagged with a unique ACR Tasks run ID.
58+
1. Runs a `build` step to build an image from the Dockerfile in the working directory. The image targets the `Run.Registry`, the registry where the task is run, and is tagged with a unique ACR Tasks run ID.
5859
1. Runs a `cmd` step to run the image in a temporary container. This example starts a long-running container in the background and returns the container ID, then stops the container. In a real-world scenario, you might include steps to test the running container to ensure it runs correctly.
5960
1. In a `push` step, pushes the image that was built to the run registry.
6061

@@ -79,7 +80,7 @@ az acr task create \
7980
--git-access-token $GIT_PAT
8081
```
8182

82-
This task specifies that any time code is committed to the *main* branch in the repository specified by `--context`, ACR Tasks will run the multi-step task from the code in that branch. The YAML file specified by `--file` from the repository root defines the steps.
83+
This task specifies that any time code is committed to the *main* branch in the repository specified by `--context`, ACR Tasks will run the multi-step task from the code in that branch. The YAML file specified by `--file` from the repository root defines the steps.
8384

8485
Output from a successful [az acr task create][az-acr-task-create] command is similar to the following:
8586

@@ -294,7 +295,7 @@ steps:
294295
This multi-step task does the following:
295296

296297
1. Runs two `build` steps to build images from the Dockerfile in the working directory:
297-
* The first targets the `Run.Registry`, the registry where the task is run, and is tagged with the ACR Tasks run ID.
298+
* The first targets the `Run.Registry`, the registry where the task is run, and is tagged with the ACR Tasks run ID.
298299
* The second targets the registry identified by the value of `regDate`, which you set when you create the task (or provide through an external `values.yaml` file passed to `az acr task create`). This image is tagged with the run date.
299300
1. Runs a `cmd` step to run one of the built containers. This example starts a long-running container in the background and returns the container ID, then stops the container. In a real-world scenario, you might test a running container to ensure it runs correctly.
300301
1. In a `push` step, pushes the images that were built, the first to the run registry, the second to the registry identified by `regDate`.
@@ -317,7 +318,9 @@ az acr task create \
317318

318319
To push images to the registry identified by the value of `regDate`, use the [az acr task credential add][az-acr-task-credential-add] command to add login credentials for that registry to the task.
319320

320-
For this example, we recommend that you create a [service principal](container-registry-auth-service-principal.md) with access to the registry scoped to the *AcrPush* role, so that it has permissions to push images. To create the service principal, see this [Azure CLI script](https://github.com/Azure-Samples/azure-cli-samples/blob/master/container-registry/service-principal-create/service-principal-create.sh).
321+
For this example, we recommend that you create a [service principal](container-registry-auth-service-principal.md) with access to the registry scoped to the *AcrPush* role, so that it has permissions to push images. To create the service principal, use the following script:
322+
323+
:::code language="azurecli" source="~/azure_cli_scripts/container-registry/create-registry/create-registry-service-principal-assign-role.sh" id="Create":::
321324

322325
Pass the service principal application ID and password in the following `az acr task credential add` command. Be sure to update the login server name *mycontainerregistrydate* with the name of your second registry:
323326

@@ -445,7 +448,7 @@ In this tutorial, you learned how to create multi-step, multi-container-based ta
445448
[az-acr-task-create]: /cli/azure/acr/task#az-acr-task-create
446449
[az-acr-task-run]: /cli/azure/acr/task#az-acr-task-run
447450
[az-acr-task-list-runs]: /cli/azure/acr/task#az-acr-task-list-runs
448-
[az-acr-task-credential-add]: /cli/azure/acr/task/credential#az-acr-task-credential-add
451+
[az-acr-task-credential-add]: /cli/azure/acr/task/credential#az-acr-task-credential-add
449452
[az-login]: /cli/azure/reference-index#az-login
450453

451454
<!-- IMAGES -->

includes/container-registry-service-principal.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,17 @@ You can optionally modify the `--role` value in the [az ad sp create-for-rbac][a
2121

2222
After you run the script, take note of the service principal's **ID** and **password**. Once you have its credentials, you can configure your applications and services to authenticate to your container registry as the service principal.
2323

24-
<!-- https://github.com/Azure-Samples/azure-cli-samples/blob/master/container-registry/service-principal-create/service-principal-create.sh -->
25-
[!code-azurecli-interactive[acr-sp-create](~/cli_scripts/container-registry/service-principal-create/service-principal-create.sh)]
24+
<!-- https://github.com/Azure-Samples/azure-cli-samples/blob/master/container-registry/create-registry/create-registry-service-principal-assign-role.sh -->
25+
:::code language="azurecli" source="~/azure_cli_scripts/container-registry/create-registry/create-registry-service-principal-assign-role.sh" id="Create":::
2626

2727
### Use an existing service principal
2828

2929
To grant registry access to an existing service principal, you must assign a new role to the service principal. As with creating a new service principal, you can grant pull, push and pull, and owner access, among others.
3030

3131
The following script uses the [az role assignment create][az-role-assignment-create] command to grant *pull* permissions to a service principal you specify in the `SERVICE_PRINCIPAL_ID` variable. Adjust the `--role` value if you'd like to grant a different level of access.
3232

33-
34-
<!-- https://github.com/Azure-Samples/azure-cli-samples/blob/master/container-registry/service-principal-assign-role/service-principal-assign-role.sh -->
35-
[!code-azurecli-interactive[acr-sp-role-assign](~/cli_scripts/container-registry/service-principal-assign-role/service-principal-assign-role.sh)]
33+
<!-- https://github.com/Azure-Samples/azure-cli-samples/blob/master/container-registry/create-registry/create-registry-service-principal-assign-role.sh -->
34+
:::code language="azurecli" source="~/azure_cli_scripts/container-registry/create-registry/create-registry-service-principal-assign-role.sh" id="Assign":::
3635

3736
<!-- LINKS - Internal -->
3837
[az-ad-sp-create-for-rbac]: /cli/azure/ad/sp#az_ad_sp_create_for_rbac

0 commit comments

Comments
 (0)