How to get logs from azure container app? - azure

I have an Azure Container App with simple nodeJs api service. I need to read logs of this application, just to see my console.log('Hi there!').
Container App has Monitoring Logs with huge list of different queries. Which one I need to use to see my console? Or can some one provide a simple query to fetch my logs?
p.s. I want to see same logs which I can see with command:
az container logs show -n <containerName> -g <resource group>

I have tried to reproduce the issue by deploying a sample app and app service container in Azure.
To view our application console logs go to Revision Management-->click on your app-->select console logs(view details) as shown in below image:
After running the query above you can see the console logs which were generated by your application.

Related

How to Deploy FastAPI on Azure App Service

I want to deploy a simple FastAPI onto an Azure app service, but I keep getting this error message.
This is my api.
from fastapi import FastAPI
app = FastAPI()
#app.get('/')
async def welcome():
return {'message':'Wecome to My website!'}
The api works just fine on my local machine. The command I use on my VS code terminal is "uvicorn main: app".
In order to deploy my app, I have startup.sh where there is only one command line:
gunicorn -w 2 -k uvicorn.workers.UvicornWorker main:app
I've set up the configuration of the app service:
The pricing tier is :
I don't see any probem in the pipeline:
Alernatively, I've tried with each of following lines of code in startup.sh:
python -m uvicorn main:app
gunicorn --bind=0.0.0.0 --timeout:600 main:app
But all failed. Help is much appreciated!
Great to know that upgrading the App service plan resolves the issue.
In general, the first step in troubleshooting is to use App Service Diagnostics:
In the Azure portal for your web app, select Diagnose and solve
problems from the left menu.
Select Availability and Performance.
Examine the information in the Application Logs, Container Crash, and Container
Issues options, where the most common issues will appear.
Next, examine both the deployment logs and the app logs for any error messages. These logs often identify specific issues that can prevent app deployment or app startup.

How to deploy pgadmin4 docker image on azure web app?

I am unable to run docker image dpage/pgadmin4 on azure web app (Linux) which is available on docker hub.
I have installed Docker in my Linux machine and was able to run that docker image locally. Then I created Web app in Azure with options as given below:
OS: Linux
Publish: Docker Image
App service plan: Linux app service
After creating web app, I added two env variables in App Settings section:
PGADMIN_DEFAULT_EMAIL : user#domain.com
PGADMIN_DEFAULT_PASSWORD : SuperSecret
Finally login screen is visible but when I enter above credentials, it doesn't work and keeps redirecting to login page.
Update: If login is working properly, screen appears as shown below.
!(pgadmin initial screen)
After several retries i once got an message (CSRF token invalid) displayed in the right-top corner of the login screen.
For CSRF to properly work there must be some serverside state? So I activated the "ARR affinity" in the "General Settings" on the azure "Configuration".
I also noticed in the explamples on documentation the two environment-variables PGADMIN_CONFIG_CONSOLE_LOG_LEVEL (which is in the example set to '10') and PGADMIN_CONFIG_ENHANCED_COOKIE_PROTECTION (which is in the example set to 'True').
After enabling "ARR" and setting PGADMIN_CONFIG_ENHANCED_COOKIE_PROTECTION to False the login started to work. I have no idea what PGADMIN_CONFIG_ENHANCED_COOKIE_PROTECTION is actually doing, so please take that with caution.
If thats not working for you, maybe setting PGADMIN_CONFIG_CONSOLE_LOG_LEVEL to 10 and enabling console debug logging can give you a clue whats happening.
For your issue, I do the test and find that it's really a strange thing. When I deploy the docker image dpage/pgadmin4 in Azure service Web App for Container through Azure CLI and set the app settings, there is no problem to log in with the user and password. But when I deploy it through the Azure portal, then I meet the same thing with you.
Not sure what is the reason, but the solution is that set the environment variables PGADMIN_DEFAULT_EMAIL and PGADMIN_DEFAULT_PASSWORD through the Azure CLI like below:
az webapp config appsettings set --resource-group <resource-group-name> --name <app-name> --settings PGADMIN_DEFAULT_EMAIL="user#domain.com" PGADMIN_DEFAULT_PASSWORD="SuperSecret"
If you really want to know the reason, then you can make feedback to Microsoft. Maybe it's a bug or some special settings.
Update
The screenshot of the test on my side here:

"No route registered for '/ZipDeployUI' in Azure

Am following node application deployment guide in Azure app service .After creating the web app in azure it asks to redirect to below url
https://<app_name>.scm.azurewebsites.net/ZipDeployUI
But after redirecting it says.
"No route registered for '/ZipDeployUI'
Any clue to fix this issue.
https://<app_name>.scm.azurewebsites.net/ZipDeployUI does not work for Linux App Services at this time. Consider using FTP or the ZIP deploy API instead.
Uploading the zip file through the cli.It worked fine for me
az webapp deployment source config-zip --resource-group myResourceGroup --name <app_name> --src clouddrive/<filename>.zip
You have few options. Don't worry about not having the zipDeploy endpoint. You can ssh file, you can upload from a CLI, and a few others options are also there. Please refer to the below documentation:
https://learn.microsoft.com/en-us/azure/app-service/deploy-zip
I got this error on a Linux App Services instance. According to the documentation for the ZipDeployUI endpoint:
The above endpoint does not work for Linux App Services at this time.
Consider using FTP or the ZIP deploy API instead.
Switching to a Windows App Services instance fixed the issue for me.

Azure web app container and docker commands

I'm using the Azure resource "Web app for containers" with a Linux docker image. I would like to use docker commands such as "docker inspect" but I'm not sure how this is possible. Via the Kudo interface this doesn't seem possible. I cannot even get the SHA256 hash of the image currently deployed. All I have is the initial docker run command executed by the app service itself.
Does anyone know how such operations can be executed with app containers in Azure ?
The Azure Web app for container is different from the container. It is a web app service when you create it. The difference is that it comes out from a container.
So you cannot execute a docker command to a web app. You can execute the command of the web app.
For example, if you want to check the container image, the command is az webapp config container show --resource-group groupName --name webName and the result like this:
For more details about Web app command, see Web App commands.

Azure NodeJS console log

I have a Visual Studio Enterprise MSDN subscription so I decided to move from Heroku to Microsoft Azure because I used to pay: now I don't. My Service Plan is the D1.
I wish I can trail the console.log strings of my Node JS application deployed on my Azure platform. My service plan is the shared one named
I deployed the app code on BitBucket and linked my repo to the application with a correct destribution. Correct means I see the green check flag. I deployed, on the main folder of the app, a file named IISNode.yml, here is the content:
nodeProcessCommandLine: "D:\Program Files (x86)\nodejs\0.12.6\node.exe"
loggingEnabled: true
debuggingEnabled: false
devErrorsEnabled: false
node_env: production
The firse line I copied from the iisnode.yml created by Azure itselves. The other lines I am not quite sure about the exact meanings of all of them, but I figured they were enough. If I visit the url: http://MY_APP_NAME.scm.azurewebsites.net/DebugConsole I can click on Tools->Log Stream menu but the page remains on loading.
I can reach the Azure Portal, enter my node app, Tools -> Application Log and Web Server log. The application log shows this (I think quite interesting) message:
System.ApplicationException: The trace listener AzureBlobTraceListener is disabled. ---> System.InvalidOperationException: The SAS URL for the cloud storage account is not specified. Use the environment variable 'DIAGNOSTICS_AZUREBLOBCONTAINERSASURL' to define it.
at Microsoft.WindowsAzure.WebSites.Diagnostics.AzureBlobTraceListener.RefreshConfig()
I have not reached informations about this "environment variable", and I can0t guess what the BLOB container has to do with my log application. And: what is the correct value for this variable? And if there is any, why is that one correct?
The Web Servier log is are empty. I can see http activities from the monitor of the app on the same portal, but still no log.
Am I missing something ? I decided to install Visual Studio, maybe this will help? I hope this has tools to be integrated with Azure for good. Meanwhile, where is the console log of my (Extremely Simple) node application?
You can view your logs in real time if you use the azure SCM interface. This can usually be accessed on the following url
https://{{ name of webapp }}.scm.azurewebsites.net/api/logstream
All your console output from your application is redirected here.
You can also use curl:
curl -u {{ deploymentCredentialsUsername:deploymentCredentialsPassword }} https://webapp-name.acm.azurewebsites.net/api/logstream
Otherwise you could use the nodejs azure cli. Install it with
npm install -g azure-cli
Switch to asm mode:
azure config mode asm
Then you can proceed to look at the logs from your terminal:
azure site log tail {{ webapp name }}
You can add an item in iisnode.yml named logDirectory, set the value as iisnode for example, then the application will create a folder in this name in your root directory and store files with stdout and stderr captures in it. You can refer to https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/iisnode.yml#L94 for the details for this configuration.
You can store logs in files whatever you need via console.log(), then the application will create a html file index.html in the log folder to provide logs. You can visit the logs via the URL: http://<you_app_name>.azurewebsites.net/<log_file_name>/index.html
Additionally, you can leverage Node.js console class to customize logger, refer to https://nodejs.org/api/console.html#console_new_console_stdout_stderr for the sample
If you are using the Azure Portal web interface, you can find the console.log output under the Log Stream section under Monitoring.
Refer to the screenshot below:

Resources