|
| 1 | +--- |
| 2 | +title: Quickstart - Create a service connection in Container Apps using the Azure CLI |
| 3 | +description: Quickstart showing how to create a service connection in Azure Container Apps using the Azure CLI |
| 4 | +author: maud-lv |
| 5 | +ms.author: malev |
| 6 | +ms.service: service-connector |
| 7 | +ms.topic: quickstart |
| 8 | +ms.date: 05/24/2022 |
| 9 | +ms.devlang: azurecli |
| 10 | +--- |
| 11 | + |
| 12 | +# Quickstart: Create a service connection in Container Apps with the Azure CLI |
| 13 | + |
| 14 | +This quickstart shows you how to create a service connection in Container Apps with the Azure CLI. The [Azure CLI](/cli/azure) is a set of commands used to create and manage Azure resources. The Azure CLI is available across Azure services and is designed to get you working quickly with Azure, with an emphasis on automation. |
| 15 | + |
| 16 | +[!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)] |
| 17 | + |
| 18 | +[!INCLUDE [azure-cli-prepare-your-environment.md](../../includes/azure-cli-prepare-your-environment.md)] |
| 19 | + |
| 20 | +- Version 2.37.0 or higher of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed. |
| 21 | + |
| 22 | +- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/dotnet). |
| 23 | + |
| 24 | +- An application deployed to Container Apps in a [region supported by Service Connector](./concept-region-support.md). If you don't have one yet, [create and deploy a container to Container Apps](../container-apps/quickstart-portal.md). |
| 25 | + |
| 26 | +> [!IMPORTANT] |
| 27 | +> Service Connector in Container Apps is currently in preview. |
| 28 | +> See the [Supplemental Terms of Use for Microsoft Azure Previews](https://azure.microsoft.com/support/legal/preview-supplemental-terms/) for legal terms that apply to Azure features that are in beta, preview, or otherwise not yet released into general availability. |
| 29 | +
|
| 30 | +## View supported target services |
| 31 | + |
| 32 | +Use the following Azure CLI command to create and manage service connections from Container Apps. |
| 33 | + |
| 34 | +```azurecli-interactive |
| 35 | +az provider register -n Microsoft.ServiceLinker |
| 36 | +az containerapp connection list-support-types --output table |
| 37 | +``` |
| 38 | + |
| 39 | +## Create a service connection |
| 40 | + |
| 41 | +### [Using an access key](#tab/using-access-key) |
| 42 | + |
| 43 | +1. Use the following Azure CLI command to create a service connection from Container Apps to a Blob Storage with an access key. |
| 44 | + |
| 45 | + ```azurecli-interactive |
| 46 | + az containerapp connection create storage-blob --secret |
| 47 | + ``` |
| 48 | +
|
| 49 | +1. Provide the following information at the Azure CLI's request: |
| 50 | +
|
| 51 | + - **The resource group which contains the container app**: the name of the resource group with the container app. |
| 52 | + - **Name of the container app**: the name of your container app. |
| 53 | + - **The container where the connection information will be saved:** the name of the container, in your container app, that connects to the target service |
| 54 | + - **The resource group which contains the storage account:** the name of the resource group name with the storage account. In this guide, we're using a Blob Storage. |
| 55 | + - **Name of the storage account:** the name of the storage account that contains your blob. |
| 56 | +
|
| 57 | +> [!NOTE] |
| 58 | +> If you don't have a Blob Storage, you can run `az containerapp connection create storage-blob --new --secret` to provision a new Blob Storage and directly get connected to your app service. |
| 59 | +
|
| 60 | +### [Using a managed identity](#tab/using-managed-identity) |
| 61 | +
|
| 62 | +> [!IMPORTANT] |
| 63 | +> Using a managed identity requires you have the permission to [Azure AD role assignment](../active-directory/managed-identities-azure-resources/howto-assign-access-portal.md). Without this permission, your connection creation will fail. Ask your subscription owner to grant you this permission, or use an access key instead to create the connection. |
| 64 | +
|
| 65 | +1. Use the following Azure CLI command to create a service connection from Container Apps to a Blob Storage with a system-assigned managed identity. |
| 66 | +
|
| 67 | + ```azurecli-interactive |
| 68 | + az containerapp connection create storage-blob --system-identity |
| 69 | + ``` |
| 70 | +
|
| 71 | +1. Provide the following information at the Azure CLI's request: |
| 72 | +
|
| 73 | + - **The resource group which contains the container app**: the name of the resource group with the container app. |
| 74 | + - **Name of the container app**: the name of your container app. |
| 75 | + - **The container where the connection information will be saved:** the name of the container, in your container app, that connects to the target service |
| 76 | + - **The resource group which contains the storage account:** the name of the resource group name with the storage account. In this guide, we're using a Blob Storage. |
| 77 | + - **Name of the storage account:** the name of the storage account that contains your blob. |
| 78 | +
|
| 79 | +> [!NOTE] |
| 80 | +> If you don't have a Blob Storage, you can run `az containerapp connection create storage-blob --new --system-identity` to provision a new Blob Storage and directly get connected to your app service. |
| 81 | +
|
| 82 | +--- |
| 83 | +
|
| 84 | +## View connections |
| 85 | +
|
| 86 | + Use the Azure CLI command `az containerapp connection list` to list all your container app's provisioned connections. Provide the following information: |
| 87 | +
|
| 88 | +- **Source compute service resource group name:** the resource group name of the container app. |
| 89 | +- **Container app name:** the name of your container app. |
| 90 | +
|
| 91 | +```azurecli-interactive |
| 92 | +az containerapp connection list -g "<your-container-app-resource-group>" --name "<your-container-app-name>" --output table |
| 93 | +``` |
| 94 | + |
| 95 | +The output also displays the provisioning state of your connections: failed or succeeded. |
| 96 | + |
| 97 | +## Next steps |
| 98 | + |
| 99 | +> [!div class="nextstepaction"] |
| 100 | +> [Service Connector internals](./concept-service-connector-internals.md) |
0 commit comments