Can I deploy code from DevOps to Azure Web running on Linux Container? - azure

I have a Web app running on Linux which is deployed from Docker Container.
Container comes from Azure container registry and was defined when I created the web app.
When I try to set my release pipeline to deploy to this web app, it doesnt offer me this choice.
When I set my subscription and Web app on Linux, I only see web apps that are deployed from code. My web app from docker container is not in the list in the App Name select:
I tried to do this manually using Azure PowerShell. I have set up local connection and trying to test the deploy but it doesnt work.
I have downloaded the repository locally as a zip file and I am trying to deploy it from this local zip file to the Web app on Azure. I try to deploy it from Powershell:
$webapp = Get-AzWebApp -ResourceGroupName "MyResourceGroup" -Name "my-container-app"
$path = 'C:\temp\repository.zip'
Publish-AzWebApp -WebApp $webapp -ArchivePath $path -Force
I am using Publish-AzWebApp command.
This command goes without an error, I also tried without -Force parameter, and with -AsJob parameter.
Everytime the command is executed successfully, but when I check my web app there is nothing deployed there. If I try this exact procedure with web app that is not from container, but from code than it works. By code/container I mean this setting that you choose when creating web app:
Currently I am using docker image that is also used by Azure as default so it should be the same Debian. I need to use it because I want to set some things differently in my web app, so I want to have my own system on web app, but deploy code from Devops to it.
However it seems that this type of web app is not supperted for deploy - nether from Devops gui, nor from Azure CLI. Can I somehow deploy my code on a web app that is running on my custom docker image?
PS: One option is to use the agent in Devops pipeline, compile a docker image from it and publish it with my code to the Azure container repository, from which it can be used form my web app. Problem is that you can only choose from 2 Ubuntu versions as an agent for build pipeline and I dont want that.
Any help is appreciated, thanks

For your requirements, first of all, you need to know the Web App on Linux and Web App for Container are two different resources, so it does not list your app deployed from the docker image. And second, when you use the docker image, it means you need to create a new image when your code change. So it does not support that create the Web App from the docker image and then publish the code from the DevOps.
The option that you think is right. Don't worry about the OS, you can use the Azure CLI command to create the docker image and push it to the Azure Container Registry directly:
az acr build -t image_name:tag -r acr_name source_code_path
And then deploy the image from the ACR to the Web App. In this way, the DevOps agent just use to run the task, not for the creation of the docker image.

Related

Azure App service Keeps pulling docker image from docker hub

I have a azure app service to host a docker image from out Azure Container Registry.
The full process is as follow:
Run Pipeline
Run Release pipeline
Azure app pulls the latest release from azure container registry
But what happen is that after Each realise, for some reason, the app service tries to pull the image from Docker Hubinstead of pulling from azure Container Registry.
Can somebody help to understand where is the issue here?
For your issue, I can guess the problem you made, you must set the image with the tag as, for example, nginx:latest. But if you push the image in the ACR and need to pull it from the ACR, you must set the image with the tag as myacr.azurecr.io/nginx:latest. In addition, you also need to configure the credential for your ACR.

How to automatically deploy a web job to Azure portal using Power shell

I have been checking for ways to deploy a web job to azure automatically using PowerShell. I saw some blogs that depict the steps and the following summarizes what I have tried
I build my application (ASP.NET Console Application) in release mode and Zipped the contents of bin/Release to a folder.
In PowerShell, I logged in with az login
Then I tried the following commmand
Invoke-WebRequest -Uri https://$applicationName.scm.azurewebsites.net/site/wwwroot/app_data/jobs/triggered/$webJobName ` -InFile $ZipFile -ContentType "application/zip" -Method Put
$ZipFile has the path to the folder I created on step 1.
The output I get is the following
Invoke-WebRequest : The page was not displayed because the request entity is too large
Please let me know if you know what the issue is or If you have any reference that would help.
Thanks in advance!
Thanks for pitching in everyone! Your input was helpful, however I would like to update the answer with the solution I found that was so easy and saved me so much time. I will like to update you on how I could successfully deploy the app service and web job in a single go. Its very easy and since it deploys web app and corresponding web jobs in a single go, this was the perfect solution for my scenario. Thanks to my colleague who helped me with this solution.
The following depicts the steps I had to go through.
Lets suppose that my app service in Azure is "appService1" and I want to create a triggered web job under appService1 that goes by the name "webJob1".
I followed zip-deployment with azure cli.
Publish your web application (For the app service) solution in release mode to get the files you will have to deploy. Let this folder be WebAppBuild.
Build your application (a console application in my case) that would serve as the web job for the app service in release mode.
Inside the published folder for the web application (for app service ie WebAppBuild in our example), add a folder with the following path
app_data\jobs\triggered\webJob1
(If you need more than one web jobs deployed, you can create more than one folders like webJob2, webJob3 etc)
Add the files you have in step 2 to this folder. This is basically the files needed for your web job
Zip the contents in a single folder that acts as your deployment folder for web app and web job
Go to powershell and run az login (works if you have installed azure cli, otherwise you will have to install it as well)
Log into your respective account with the prompt window
Run the following commands that sets run from package property to true for your web app and the second command is the actual deployment command
az webapp config appsettings set --resource-group <<resourceGroupName>> --name <<appServiceName>> --settings WEBSITE_RUN_FROM_PACKAGE="1" ;
az webapp deployment source config-zip --resource-group <<resourceGroupName>> --name <<appServiceName>> --src <<zipFilePath>>
Now login to your azure portal and navigate to your web app. Check under web jobs option and you will see that the web job has been created with the files you deployed.
For more help on starting, stopping, deleting the web job with azure cli, go through the following document.
Check here

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.

Resources