Skip to content

Commit

Permalink
CLI changes for Microsoft.App (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonychu authored Mar 22, 2022
1 parent 4bfeff5 commit 514791e
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 171 deletions.
8 changes: 4 additions & 4 deletions articles/container-apps/background-processing.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ Individual container apps are deployed to an Azure Container Apps environment. T
az containerapp env create \
--name $CONTAINERAPPS_ENVIRONMENT \
--resource-group $RESOURCE_GROUP \
--logs-workspace-id $LOG_ANALYTICS_WORKSPACE_CLIENT_ID \
--logs-workspace-key $LOG_ANALYTICS_WORKSPACE_CLIENT_SECRET \
--location "$LOCATION"
```

Expand All @@ -46,8 +44,6 @@ az containerapp env create \
az containerapp env create `
--name $CONTAINERAPPS_ENVIRONMENT `
--resource-group $RESOURCE_GROUP `
--logs-workspace-id $LOG_ANALYTICS_WORKSPACE_CLIENT_ID `
--logs-workspace-key $LOG_ANALYTICS_WORKSPACE_CLIENT_SECRET `
--location $LOCATION
```

Expand Down Expand Up @@ -280,6 +276,8 @@ Run the following command to see logged messages. This command requires the Log
# [Bash](#tab/bash)

```azurecli
LOG_ANALYTICS_WORKSPACE_CLIENT_Id=`az containerapp env show --name $CONTAINERAPPS_ENVIRONMENT --resource-group $RESOURCE_GROUP --query properties.appLogsConfiguration.logAnalyticsConfiguration.customerId --out tsv`
az monitor log-analytics query \
--workspace $LOG_ANALYTICS_WORKSPACE_CLIENT_ID \
--analytics-query "ContainerAppConsoleLogs_CL | where ContainerAppName_s == 'queuereader' and Log_s contains 'Message ID'" \
Expand All @@ -289,6 +287,8 @@ az monitor log-analytics query \
# [PowerShell](#tab/powershell)

```powershell
$LOG_ANALYTICS_WORKSPACE_CLIENT_ID=(az containerapp env show --name $CONTAINERAPPS_ENVIRONMENT --resource-group $RESOURCE_GROUP --query properties.appLogsConfiguration.logAnalyticsConfiguration.customerId --out tsv)
$queryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId $LOG_ANALYTICS_WORKSPACE_CLIENT_ID -Query "ContainerAppConsoleLogs_CL | where ContainerAppName_s == 'queuereader' and Log_s contains 'Message ID'"
$queryResults.Results
```
Expand Down
24 changes: 12 additions & 12 deletions articles/container-apps/get-started-existing-container-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services: container-apps
author: craigshoemaker
ms.service: container-apps
ms.topic: quickstart
ms.date: 12/16/2021
ms.date: 03/21/2022
ms.author: cshoe
zone_pivot_groups: container-apps-registry-types
---
Expand Down Expand Up @@ -35,8 +35,6 @@ To create the environment, run the following command:
az containerapp env create \
--name $CONTAINERAPPS_ENVIRONMENT \
--resource-group $RESOURCE_GROUP \
--logs-workspace-id $LOG_ANALYTICS_WORKSPACE_CLIENT_ID \
--logs-workspace-key $LOG_ANALYTICS_WORKSPACE_CLIENT_SECRET \
--location $LOCATION
```

Expand All @@ -46,8 +44,6 @@ az containerapp env create \
az containerapp env create `
--name $CONTAINERAPPS_ENVIRONMENT `
--resource-group $RESOURCE_GROUP `
--logs-workspace-id $LOG_ANALYTICS_WORKSPACE_CLIENT_ID `
--logs-workspace-key $LOG_ANALYTICS_WORKSPACE_CLIENT_SECRET `
--location $LOCATION
```

Expand Down Expand Up @@ -75,7 +71,7 @@ For details on how to provide values for any of these parameters to the `create`

```bash
CONTAINER_IMAGE_NAME=<CONTAINER_IMAGE_NAME>
REGISTRY_LOGIN_SERVER=<REGISTRY_LOGIN_URL>
REGISTRY_SERVER=<REGISTRY_SERVER>
REGISTRY_USERNAME=<REGISTRY_USERNAME>
REGISTRY_PASSWORD=<REGISTRY_PASSWORD>
```
Expand All @@ -88,7 +84,7 @@ az containerapp create \
--resource-group $RESOURCE_GROUP \
--image $CONTAINER_IMAGE_NAME \
--environment $CONTAINERAPPS_ENVIRONMENT \
--registry-login-server $REGISTRY_LOGIN_SERVER \
--registry-server $REGISTRY_SERVER \
--registry-username $REGISTRY_USERNAME \
--registry-password $REGISTRY_PASSWORD
```
Expand All @@ -97,7 +93,7 @@ az containerapp create \

```powershell
$CONTAINER_IMAGE_NAME=<CONTAINER_IMAGE_NAME>
$REGISTRY_LOGIN_SERVER=<REGISTRY_LOGIN_URL>
$REGISTRY_SERVER=<REGISTRY_SERVER>
$REGISTRY_USERNAME=<REGISTRY_USERNAME>
$REGISTRY_PASSWORD=<REGISTRY_PASSWORD>
```
Expand All @@ -110,7 +106,7 @@ az containerapp create `
--resource-group $RESOURCE_GROUP `
--image $CONTAINER_IMAGE_NAME `
--environment $CONTAINERAPPS_ENVIRONMENT `
--registry-login-server $REGISTRY_LOGIN_SERVER `
--registry-server $REGISTRY_SERVER `
--registry-username $REGISTRY_USERNAME `
--registry-password $REGISTRY_PASSWORD
```
Expand All @@ -125,7 +121,7 @@ az containerapp create `

```azurecli
az containerapp create \
--image <REGISTRY_CONTAINER_URL> \
--image <REGISTRY_CONTAINER_NAME> \
--name my-container-app \
--resource-group $RESOURCE_GROUP \
--environment $CONTAINERAPPS_ENVIRONMENT
Expand All @@ -135,15 +131,15 @@ az containerapp create \

```azurecli
az containerapp create `
--image <REGISTRY_CONTAINER_URL> `
--image <REGISTRY_CONTAINER_NAME> `
--name my-container-app `
--resource-group $RESOURCE_GROUP `
--environment $CONTAINERAPPS_ENVIRONMENT
```

---

Before you run this command, replace `<REGISTRY_CONTAINER_URL>` with the URL to the public container registry location including tag.
Before you run this command, replace `<REGISTRY_CONTAINER_NAME>` with the full name the public container registry location, including the registry path and tag. For example, a valid container name is `mcr.microsoft.com/azuredocs/containerapps-helloworld:latest`.

::: zone-end

Expand All @@ -158,6 +154,8 @@ After about 5-10 minutes has passed, use the following steps to view logged mess
# [Bash](#tab/bash)

```azurecli
LOG_ANALYTICS_WORKSPACE_CLIENT_Id=`az containerapp env show --name $CONTAINERAPPS_ENVIRONMENT --resource-group $RESOURCE_GROUP --query properties.appLogsConfiguration.logAnalyticsConfiguration.customerId --out tsv`
az monitor log-analytics query \
--workspace $LOG_ANALYTICS_WORKSPACE_CLIENT_ID \
--analytics-query "ContainerAppConsoleLogs_CL | where ContainerAppName_s == 'my-container-app' | project ContainerAppName_s, Log_s, TimeGenerated" \
Expand All @@ -167,6 +165,8 @@ az monitor log-analytics query \
# [PowerShell](#tab/powershell)

```powershell
$LOG_ANALYTICS_WORKSPACE_CLIENT_ID=(az containerapp env show --name $CONTAINERAPPS_ENVIRONMENT --resource-group $RESOURCE_GROUP --query properties.appLogsConfiguration.logAnalyticsConfiguration.customerId --out tsv)
$queryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId $LOG_ANALYTICS_WORKSPACE_CLIENT_ID -Query "ContainerAppConsoleLogs_CL | where ContainerAppName_s == 'nodeapp' and (Log_s contains 'persisted' or Log_s contains 'order') | project ContainerAppName_s, Log_s, TimeGenerated | take 5"
$queryResults.Results
--out table
Expand Down
6 changes: 1 addition & 5 deletions articles/container-apps/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services: container-apps
author: craigshoemaker
ms.service: container-apps
ms.topic: quickstart
ms.date: 11/02/2021
ms.date: 03/21/2022
ms.author: cshoe
ms.custom: ignite-fall-2021, mode-api, devx-track-azurecli
ms.devlang: azurecli
Expand Down Expand Up @@ -33,8 +33,6 @@ To create the environment, run the following command:
az containerapp env create \
--name $CONTAINERAPPS_ENVIRONMENT \
--resource-group $RESOURCE_GROUP \
--logs-workspace-id $LOG_ANALYTICS_WORKSPACE_CLIENT_ID \
--logs-workspace-key $LOG_ANALYTICS_WORKSPACE_CLIENT_SECRET \
--location $LOCATION
```

Expand All @@ -44,8 +42,6 @@ az containerapp env create \
az containerapp env create `
--name $CONTAINERAPPS_ENVIRONMENT `
--resource-group $RESOURCE_GROUP `
--logs-workspace-id $LOG_ANALYTICS_WORKSPACE_CLIENT_ID `
--logs-workspace-key $LOG_ANALYTICS_WORKSPACE_CLIENT_SECRET `
--location $LOCATION
```

Expand Down
4 changes: 2 additions & 2 deletions articles/container-apps/manage-secrets.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ az containerapp create \
--environment "my-environment-name" \
--image demos/myQueueApp:v1 \
--secrets "queue-connection-string=$CONNECTIONSTRING" \
--environment-variables "QueueName=myqueue,ConnectionString=secretref:queue-connection-string"
--env-vars "QueueName=myqueue" "ConnectionString=secretref:queue-connection-string"
```

Here, the environment variable named `connection-string` gets its value from the application-level `queue-connection-string` secret by using `secretref`.
Expand All @@ -136,7 +136,7 @@ az containerapp create `
--environment "my-environment-name" `
--image demos/myQueueApp:v1 `
--secrets "queue-connection-string=$CONNECTIONSTRING" `
--environment-variables "QueueName=myqueue,ConnectionString=secretref:queue-connection-string"
--env-vars "QueueName=myqueue" "ConnectionString=secretref:queue-connection-string"
```

Here, the environment variable named `connection-string` gets its value from the application-level `queue-connection-string` secret by using `secretref`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,13 @@ Next, install the Azure Container Apps extension for the Azure CLI.
# [Bash](#tab/bash)

```azurecli
az extension add \
--source https://workerappscliextension.blob.core.windows.net/azure-cli-extension/containerapp-0.2.4-py2.py3-none-any.whl
az extension add --name containerapp
```

# [PowerShell](#tab/powershell)

```azurecli
az extension add `
--source https://workerappscliextension.blob.core.windows.net/azure-cli-extension/containerapp-0.2.4-py2.py3-none-any.whl
az extension add --name containerapp
```

---
Expand All @@ -149,9 +147,6 @@ Now that the extension is installed, register the `Microsoft.App` namespace.
> [!NOTE]
> Azure Container Apps resources are in the process of migrating from the `Microsoft.Web` namespace to the `Microsoft.App` namespace. Refer to [Namespace migration from Microsoft.Web to Microsoft.App in March 2022](https://github.com/microsoft/azure-container-apps/issues/109) for more details.
> [!NOTE]
> Azure Container Apps resources are in the process of migrating from the `Microsoft.Web` namespace to the `Microsoft.App` namespace. Refer to [Namespace migration from Microsoft.Web to Microsoft.App in March 2022](https://github.com/microsoft/azure-container-apps/issues/109) for more details.
# [Bash](#tab/bash)

```azurecli
Expand Down Expand Up @@ -190,61 +185,6 @@ With the CLI upgraded and a new resource group available, you can create a Conta

The Azure Container Apps environment acts as a secure boundary around a group of container apps. Container Apps deployed to the same environment share a virtual network and write logs to the same Log Analytics workspace.

Your container apps are monitored with Azure Log Analytics, which is required when you create a Container Apps environment.

Create a Log Analytics workspace with the following command:

# [Bash](#tab/bash)

```azurecli
az monitor log-analytics workspace create \
--resource-group $RESOURCE_GROUP \
--workspace-name $LOG_ANALYTICS_WORKSPACE
```

# [PowerShell](#tab/powershell)

```powershell
New-AzOperationalInsightsWorkspace `
-Location $LOCATION `
-Name $LOG_ANALYTICS_WORKSPACE `
-ResourceGroupName $RESOURCE_GROUP
```

---

Next, retrieve the Log Analytics Client ID and client secret.

# [Bash](#tab/bash)

Make sure to run each query separately to give enough time for the request to complete.

```azurecli
LOG_ANALYTICS_WORKSPACE_CLIENT_ID=`az monitor log-analytics workspace show --query customerId -g $RESOURCE_GROUP -n $LOG_ANALYTICS_WORKSPACE -o tsv | tr -d '[:space:]'`
```

```azurecli
LOG_ANALYTICS_WORKSPACE_CLIENT_SECRET=`az monitor log-analytics workspace get-shared-keys --query primarySharedKey -g $RESOURCE_GROUP -n $LOG_ANALYTICS_WORKSPACE -o tsv | tr -d '[:space:]'`
```

# [PowerShell](#tab/powershell)

Make sure to run each query separately to give enough time for the request to complete.

```powershell
$LOG_ANALYTICS_WORKSPACE_CLIENT_ID=(Get-AzOperationalInsightsWorkspace -ResourceGroupName $RESOURCE_GROUP -Name $LOG_ANALYTICS_WORKSPACE).CustomerId
```

<!--- This was taken out because of a breaking changes warning. We should put it back after it's fixed. Until then we'll go with the az command
$LOG_ANALYTICS_WORKSPACE_CLIENT_SECRET=(Get-AzOperationalInsightsWorkspaceSharedKey -ResourceGroupName $RESOURCE_GROUP -Name $LOG_ANALYTICS_WORKSPACE).PrimarySharedKey
--->

```azurecli
$LOG_ANALYTICS_WORKSPACE_CLIENT_SECRET=(az monitor log-analytics workspace get-shared-keys --query primarySharedKey -g $RESOURCE_GROUP -n $LOG_ANALYTICS_WORKSPACE --out tsv)
```

---

Individual container apps are deployed to an Azure Container Apps environment. To create the environment, run the following command:

# [Bash](#tab/bash)
Expand All @@ -253,8 +193,6 @@ Individual container apps are deployed to an Azure Container Apps environment. T
az containerapp env create \
--name $CONTAINERAPPS_ENVIRONMENT \
--resource-group $RESOURCE_GROUP \
--logs-workspace-id $LOG_ANALYTICS_WORKSPACE_CLIENT_ID \
--logs-workspace-key $LOG_ANALYTICS_WORKSPACE_CLIENT_SECRET \
--location "$LOCATION"
```

Expand All @@ -264,8 +202,6 @@ az containerapp env create \
az containerapp env create `
--name $CONTAINERAPPS_ENVIRONMENT `
--resource-group $RESOURCE_GROUP `
--logs-workspace-id $LOG_ANALYTICS_WORKSPACE_CLIENT_ID `
--logs-workspace-key $LOG_ANALYTICS_WORKSPACE_CLIENT_SECRET `
--location "$LOCATION"
```

Expand Down Expand Up @@ -448,7 +384,7 @@ param storage_account_name string
param storage_account_key string
param storage_container_name string
resource nodeapp 'Microsoft.App/containerapps@2021-03-01' = {
resource nodeapp 'Microsoft.App/containerapps@2022-01-01-preview' = {
name: 'nodeapp'
kind: 'containerapp'
location: location
Expand Down Expand Up @@ -584,7 +520,7 @@ Save the following file as *clientapp.bicep*:
param location string = 'canadacentral'
param environment_name string
resource pythonapp 'Microsoft.App/containerApps@2021-03-01' = {
resource pythonapp 'Microsoft.App/containerApps@2022-01-01-preview' = {
name: 'pythonapp'
kind: 'containerapp'
location: location
Expand Down Expand Up @@ -806,6 +742,8 @@ Use the following command to view logs in bash or PowerShell.
# [Bash](#tab/bash)

```azurecli
LOG_ANALYTICS_WORKSPACE_CLIENT_Id=`az containerapp env show --name $CONTAINERAPPS_ENVIRONMENT --resource-group $RESOURCE_GROUP --query properties.appLogsConfiguration.logAnalyticsConfiguration.customerId --out tsv`
az monitor log-analytics query \
--workspace $LOG_ANALYTICS_WORKSPACE_CLIENT_ID \
--analytics-query "ContainerAppConsoleLogs_CL | where ContainerAppName_s == 'nodeapp' and (Log_s contains 'persisted' or Log_s contains 'order') | project ContainerAppName_s, Log_s, TimeGenerated | take 5" \
Expand All @@ -815,6 +753,8 @@ az monitor log-analytics query \
# [PowerShell](#tab/powershell)

```powershell
$LOG_ANALYTICS_WORKSPACE_CLIENT_ID=(az containerapp env show --name $CONTAINERAPPS_ENVIRONMENT --resource-group $RESOURCE_GROUP --query properties.appLogsConfiguration.logAnalyticsConfiguration.customerId --out tsv)
$queryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId $LOG_ANALYTICS_WORKSPACE_CLIENT_ID -Query "ContainerAppConsoleLogs_CL | where ContainerAppName_s == 'nodeapp' and (Log_s contains 'persisted' or Log_s contains 'order') | project ContainerAppName_s, Log_s, TimeGenerated | take 5"
$queryResults.Results
```
Expand Down
8 changes: 4 additions & 4 deletions articles/container-apps/microservices-dapr.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ Individual container apps are deployed to an Azure Container Apps environment. T
az containerapp env create \
--name $CONTAINERAPPS_ENVIRONMENT \
--resource-group $RESOURCE_GROUP \
--logs-workspace-id $LOG_ANALYTICS_WORKSPACE_CLIENT_ID \
--logs-workspace-key $LOG_ANALYTICS_WORKSPACE_CLIENT_SECRET \
--location "$LOCATION"
```

Expand All @@ -60,8 +58,6 @@ az containerapp env create \
az containerapp env create `
--name $CONTAINERAPPS_ENVIRONMENT `
--resource-group $RESOURCE_GROUP `
--logs-workspace-id $LOG_ANALYTICS_WORKSPACE_CLIENT_ID `
--logs-workspace-key $LOG_ANALYTICS_WORKSPACE_CLIENT_SECRET `
--location "$LOCATION"
```

Expand Down Expand Up @@ -296,6 +292,8 @@ Use the following CLI command to view logs on the command line.
# [Bash](#tab/bash)

```azurecli
LOG_ANALYTICS_WORKSPACE_CLIENT_Id=`az containerapp env show --name $CONTAINERAPPS_ENVIRONMENT --resource-group $RESOURCE_GROUP --query properties.appLogsConfiguration.logAnalyticsConfiguration.customerId --out tsv`
az monitor log-analytics query \
--workspace $LOG_ANALYTICS_WORKSPACE_CLIENT_ID \
--analytics-query "ContainerAppConsoleLogs_CL | where ContainerAppName_s == 'nodeapp' and (Log_s contains 'persisted' or Log_s contains 'order') | project ContainerAppName_s, Log_s, TimeGenerated | take 5" \
Expand All @@ -305,6 +303,8 @@ az monitor log-analytics query \
# [PowerShell](#tab/powershell)

```powershell
$LOG_ANALYTICS_WORKSPACE_CLIENT_ID=(az containerapp env show --name $CONTAINERAPPS_ENVIRONMENT --resource-group $RESOURCE_GROUP --query properties.appLogsConfiguration.logAnalyticsConfiguration.customerId --out tsv)
$queryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId $LOG_ANALYTICS_WORKSPACE_CLIENT_ID -Query "ContainerAppConsoleLogs_CL | where ContainerAppName_s == 'nodeapp' and (Log_s contains 'persisted' or Log_s contains 'order') | project ContainerAppName_s, Log_s, TimeGenerated | take 5"
$queryResults.Results
```
Expand Down
Loading

0 comments on commit 514791e

Please sign in to comment.