When using docker compose to deploy a container group to Azure Container Instances, the --location argument specified when creating the docker context for aci, docker context create aci..., appears to have no effect.
I'm following these azure instructions for using docker compose with azure container instances
and this docker documentation showing the additional arguments for the docker context create command
Steps to re-produce
Pre-requisites:
Azure CLI
λ az version
{
"azure-cli": "2.22.1",
"azure-cli-core": "2.22.1",
"azure-cli-telemetry": "1.0.6",
"extensions": {}
}
Docker
λ docker-compose --version
docker-compose version 1.29.0, build 07737305
Docker Compose
λ docker --version
Docker version 20.10.5, build 55c4c88
Steps:
Log into azure via the cli az login
Authenticate docker with azure docker login azure
Create an azure resource group in a specific location az group create -l uksouth -n test-aci-ctx-group
Create a docker context specifying a location different to the resource group location docker context create aci aci-context-eastus --resource-group test-aci-ctx-group --location eastus
Display the information about the new context. docker context inspect aci-context-eastus
Expected result: a context bound to the location specified as --location for the docker context create command, i.e., eastus
Actual result: a context bound to the same location as the azure resource group, i.e., uksouth
λ docker context inspect aci-context-eastus
[
{
"Name": "aci-context-eastus",
"Metadata": {
"Description": "test-aci-ctx-group#uksouth",
"Type": "aci"
},
"Endpoints": {
"aci": {
"Location": "uksouth",
"ResourceGroup": "test-aci-ctx-group",
"SubscriptionID": "xxxxxxxxxxxxxxxxxxx"
},
"docker": {
"SkipTLSVerify": false
}
},
"TLSMaterial": {},
"Storage": {
"MetadataPath": "xxxx",
"TLSPath": "xxxx"
}
}
]
The ultimate manifestation of this issue is that I am unable to create a container group in azure because I'm working in the context of a resource group which I cannot change, but the resource group is in a location that does not support Azure Container Instances.
When I try and issue the docker-compose up command in the aci context that I thought I created in a location that supports azure container instances, I get a location not supported error, listing the location of the resource group and not the location I specified for the docker aci context.
Am I misunderstanding the purpose of the --location parameter?
I know you can mix and match locations between a container instance and a resource group because I am able to create a container instance via azure cli with a location different to that of the resource group that it is linked to.
You misunderstand the steps. The parameter needs to be used like this:
docker context create aci --location "eastus"
So you don't need to create the resource group first. When you do it, then the group is already created with a certain location and you can't change it with the docker-compose command.
You have two choices. One is that create the resource group with the location you want, for example, location "eastus". Or create the resource group with the parameter --location "eastus" without a name.
Related
I have wrongly deleted the Log Analytics Workspace and moved the Container App Environment to a new group. After that I found out my Container App Environment had the wrong customerId.
"appLogsConfiguration": {
"destination": "log-analytics",
"logAnalyticsConfiguration": {
"customerId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
},
I tried to change that using the workspace-id using the create command below, but it didn't change. I suppose that workspaceid and customerId are the same, since I checked both.
az containerapp env create \
--name samenameasbefore \
--resource-group newgroup\
--logs-workspace-id newid \
--logs-workspace-key newsecret \
--location westeurope
Is there any documented or undocumented way to change the customerId/workspaceid of a Container App Environment?
Thank you
Short answer, the CAE workspace ID can't be changed. In order to use a specific workspace with a container app you'll need to redeploy it in a CAE that was created with the specific workspace you want to use. Currently there's no CLI command or workaround that would allow for a workspace switch on CAE.
I've created a command using the Azure CLI like this, that I want to use to pull docker logs from a container running in an Azure Virtual Machine ScaleSet (VMSS):
az vmss run-command create --resource-group "my-resource-group" --instance-id "0" --location "[azure_location_here]" --async-execution false --run-as-user "su" --script "docker logs ab5" --timeout-in-seconds 3600 --run-command-name "myCommandName" --vmss-name "aks-myservice-1234567-vmss" --output-blob-uri "https://myfileshare.blob.core.windows.net/my-azure-storage-container/log.txt"
I can see the command listed when I use:
az vmss run-command list --subscription "[my_subscription_id]" -g my-resource-group --vmss-name "aks-myservice-1234567-vmss" --instance-id 0
This gives me the following:
[
{
"asyncExecution": false,
"errorBlobUri": null,
"id": "/subscriptions/[my_subscription_id]/resourceGroups/my_resource_group/providers/Microsoft.Compute/virtualMachineScaleSets/aks-myservice-1234567-vmss/virtualMachines/0/runCommands/myCommandName",
"instanceView": null,
"location": "[azure_location_here]",
"name": "myCommandName",
"outputBlobUri": "https://myfileshare.blob.core.windows.net/my-azure-storage-container/log.txt",
"parameters": null,
"protectedParameters": null,
"provisioningState": "Succeeded",
"resourceGroup": "my_resource_group",
"runAsPassword": null,
"runAsUser": "su",
"source": {
"commandId": null,
"script": "docker logs ab5",
"scriptUri": null
},
"tags": null,
"timeoutInSeconds": 3600,
"type": "Microsoft.Compute/virtualMachineScaleSets/virtualMachines/runCommands"
}
]
I'm trying to invoke the command using the following:
az vmss run-command invoke -g my-resource-group -n aks-myservice-1234567-vmss --instance-id 0 --command-id myCommandName
This gives me the error:
(NotFound) The entity was not found in this Azure location.
How can I invoke (run) the command that I created in the first step, so that the script docker logs ab5 is run on the VMSS instance? I know how to directly run this script using az vmss run-command invoke, but the output is limited to the first 4096 bytes of the docker log. I'm trying to use az vmss run-command create to set up the script, as that allows me to use the parameter --output-blob-uri, which I'm hoping will allow me to capture the entire Docker log in a file within Azure storage once I invoke the script.
The documentation for az vmss run-command invoke isn't really clear on how a command can be invoked that was created using az vmss run-command create.
Let's assume that an azure resource, ex "storage account" is being updated!
at the same time if I run a command like
az storage account update --default-action Allow --name MyStorageAccount --resource-group MyResourceGroup
It will throw an error
The request failed due to conflict with a concurrent request or something similar
So before running such command, how can I check if the resource is being used like being updated using Azure CLI
You could use az resource show to show everything about an Azure resource.
So in your case you would do:
az resource show -n "RESOURCE_NAME" -g "RESOURCE_GROUP" --resource-type "RESOURCE_TYPE"
I found the what I'm looking for inspired by the above answer at this link az resource wait
So it will be something like
az resource wait -n "RESOURCE_NAME" -g "RESOURCE_GROUP" --resource-type "RESOURCE_TYPE" --updated
I have a File Share setup in a Storage Account. When I try to mount it in my Web App I get the following response:
"nexport-shared": {
"accessKey": "hidden==",
"accountName": "hidden",
"mountPath": "\\\\nexportshared",
"shareName": "nexportcampusbetashare",
"state": "InvalidCredentials",
"type": "AzureFiles"
}
I am using the az CLI command below :
az webapp config storage-account add --resource-group "GROUPNAME" --name "WEBAPPNAME" --custom-id nexport-shared --storage-typeAzureFiles --share-name nexportcampusbetashare --account-name STORAGEACCOUNT --access-key "hidden==" --mount-path "\\nexportshared" --verbose --debug
When I run 'az webapp config list' it shows up in the list but still with InvalidCredentials
A possible reason is that you have input an invalid key or storage account to mount the Azure files. Correcting these parameters fixes this issue for me.
Fixed as below
You may need to turn off or modify the firewall on the storage account for the Azure-Cli and the App Service to be able to see it.
I'm getting same response and file share is working as expected.
Also I just found an issue created about this, seems to be an error in the response message from the API:
https://github.com/Azure/azure-cli/issues/21571
So I'm following this guide in order tosuse Azure 2.0 CLI to create an app service to deploy.
https://learn.microsoft.com/en-us/azure/app-service-web/app-service-web-get-started
I have set up the resource group, the app service plan and the app but instead of setting up the deployment with a Git repository like this
az appservice web source-control config-local-git --name <app_name> --resource-group my-first-app-group
I would like to put all my files into a folder in DropBox.
This step can be done by using the Azure web site but I would like to know if it is possible to using the Azure 2.0 CLI? If so, what is the command?
I would like to put all my files into a folder in DropBox.
This step can be done by using the Azure web site but I would like to
know if it is possible to using the Azure 2.0 CLI?
We can use CLI 2.0 command like this:
C:\Users>az appservice web source-control config --repo-url https://www.dropbox.com/sh/ar7n31ozqgchnb2/AABxdZN4v4pklk3USCnFBWdVa?dl=0 --repository-type mercurial --name jasonapp2 --resource ubuntu
Here is my result:
C:\Users>az appservice web source-control config --repo-url https://www.dropbox.com/sh/ar7n31ozqgchnb2/AABxdZN4v4pklk3USCnFBWdVa?dl=0 --repository-type mercurial --name jasonapp2 --resource ubuntu
{
"branch": null,
"deploymentRollbackEnabled": false,
"id": "/subscriptions/5384xxxx-xxxx-xxxx-xxxx-0361e29a7b15/resourceGroups/ubuntu/providers/Microsoft.Web/sites/jasonapp2/sourcecontrols/web",
"isManualIntegration": false,
"isMercurial": false,
"kind": null,
"location": "Central US",
"name": "jasonapp2",
"repoUrl": "https://www.dropbox.com/sh/ar7n31ozqgchnb2/AABxdZN4v4pklk3USCnFBWdVa?dl=0",
"resourceGroup": "ubuntu",
"tags": {
"hidden-related:/subscriptions/5384xxxx-xxxx-xxxx-xxxx-0361e29a7b15/resourcegroups/AppResource/providers/Microsoft.Web/serverfarms/palian160919": "empty"
},
"type": "Microsoft.Web/sites/sourcecontrols"
}