Is there a command to view Azure App Service Log Stream entries from the command line? I would like to tail the logs on my local console.
Yes, you can stream the Web App logs using:
az webapp log tail [--ids]
[--name]
[--provider]
[--resource-group]
[--slot]
[--subscription]
Documentation
Related
I'm trying to retrieve a docker log for an application, from an Azure Devops Pipeline. In a pipeline step, I can run a bash script on the VM that's hosting the application, using the Azure CLI like this. This reads the docker log from the VM hosting the application:
az vmss run-command invoke --command-id RunShellScript --instance-id 0 -n aks-myservicename-12345678-vmss -g my-resource-group --scripts "docker logs [container_id]" > testing.txt
The problem is that the output of az vmss run-command invoke is limited to a max 4096 bytes - see https://learn.microsoft.com/en-us/azure/virtual-machines/linux/run-command#restrictions
Is there any way I can read the entire docker log?
The following reference documents an --output-blob-uri parameter that can be used with az vm run-command create. I'm wondering if that gives a way to output the docker log to a file that I can then access by using another Azure CLI step. I haven't found any documentation though on how this works https://learn.microsoft.com/en-us/cli/azure/vmss/run-command?view=azure-cli-latest
I have an Azure release pipeline that uses an Azure Web App for Containers task to deploy a docker image on an Azure App Service.
The image is specified in the form of some_image:$(Build.BuildId). The pipeline works as intended and successfully updates the App Service with the latest built of the image.
I want from an other release pipeline to execute a docker run command using that image. I've noticed that version 1 of the Docker task allows me to execute such a docker run command on a docker image (no idea why run is missing from version 2), but how can I specify the docker image? How can I get which image is the currently deployed on that App Service?
You can either use PowerShell or Shell script in the YAML pipeline. Since you already know the container registry and the image name, just use the below command to get the latest version
az acr repository show-tags -n MyRegistry --repository MyRepository --top 1 --orderby time_desc --detail
https://learn.microsoft.com/en-us/cli/azure/acr/repository?view=azure-cli-latest#az_acr_repository_show_tags
Might be too late now, but what you want to do is to get the value of LinuxFXVersion (if you're running docker on Linux) property from Azure Resource Explorer.
Using a combination of Azure PowerShell and CLI, you can have these commands to retrieve the current image running on your web app:
$webAppProperties = (az webapp config show --subscription "<subscription-id>" --resource-group "<resource-group-name>" -n "<webapp-name>") | ConvertFrom-Json
$webAppProperties.linuxFXVersion
Assuming you have the right permissions to your subscription from Azure Pipelines, you should be able to use this information for the next steps.
Is it possible to exec a command in a windows container related to a webapp based on a container? I'm not able to find the right name to use on the cli command az app exec. In fact az container list returns me an empty list. However the container exits cause the web app is running. Where can I find the right name to use with az app exec command? I also checked with the name of only one slot in the webapp without success.
The error az app exec returns is:
The Resource 'Microsoft.ContainerInstance/containerGroups/theNameIPRovide' under resource group 'thegroupNameIProvide' was not found.
Unfortunately, there is no Azure CLI command for Web app for Container to exec the command inside the container. But you can use other ways, for example, the API.
There is no CLI command like az app exec. And az container is for ACI, not for the Web App. You can get all CLI command for Web App in az webapp.
Or you can deploy your application in Azure Container Instance, it also can run windows container for you. So that you can use the CLI command az container exec to execute the command inside your application.
Could you have a look at this https://learn.microsoft.com/en-us/cli/azure/container?view=azure-cli-latest#az-container-exec, Couldnt comment, so had to post it in an answer
I'm trying to run a multicontainer web app based in two images that I stored in an azure container registry (launched with a docker compose yml custom file) but it fails because the docker-compose proccess cannot get the images due to an "unauthorized: autentication required" response. Both the container registry and the web app belongs to the same resource group.
How can we solve this problem? Thanks in advance.
#jennylwrnce from Azure Developer App Service Team tweeted this:
https://blogs.msdn.microsoft.com/appserviceteam/2018/06/27/use-acr-for-multicontainer-web-app/
So it can be solved via panel.azure.com
enter image description here
You need to configure authentication for the webapp, by default it can only pull public images.
this is the sample command to do that:
az webapp config container set --name <app_name>
--resource-group myResourceGroup
--docker-custom-image-name <azure-container-registry-name>.azurecr.io/mydockerimage
--docker-registry-server-url https://<azure-container-registry-name>.azurecr.io
--docker-registry-server-user <registry-username>
--docker-registry-server-password <password>
https://learn.microsoft.com/en-us/azure/app-service/containers/tutorial-custom-docker-image#use-a-docker-image-from-any-private-registry-optional
this article also talks about how to push to the private repo (ACR) and how to configure it
I have deployed a NodeJS application to Linux App Service that logs to stderr and stdout. The diagnostic logs functionality in Linux App Service does not appear to work, as nothing appears in table storage. The only logs in Kudu are from when the docker container is deployed. After that, it logs nothing.
The SSH component in Kudu does not work, even after following the official setup documentation.
Has anyone come up with a way to capture stdout and stderr? or can recommend a library that they have gotten to work successfully with NodeJS on the Linux App Service platform?
You could use Azure CLI 2.0 to capture stdout. Try to use the following commands.
az webapp log config -g <resource group name> -n <app name> --application-logging true --detailed-error-messages true --level verbose
az webapp log tail -g <resource group name> -n <app name>
You could get help with -h
root#shui:~# az webapp log config -h
Command
az webapp log config: Configure web app logs.
Arguments
--application-logging : Configure application logging to file system. Allowed values: false,
true.
--detailed-error-messages: Configure detailed error messages. Allowed values: false, true.
--failed-request-tracing : Configure failed request tracing. Allowed values: false, true.
--level : Logging level. Allowed values: error, information, verbose, warning.
--slot -s : The name of the slot. Default to the productions slot if not
specified.
--web-server-logging : Configure Web server logging. Allowed values: filesystem, off,
storage.
More information about Azure Cli supports linux webapp please refer to this link.