Reset Node app on Azure to the default container image - node.js

I've created a Node 14 Web app on Azure. For Publish, I chose Code (not Container). Then I've changed the default container image with az webapp config container set. Question, how can I revert that to the default image (which was NODE|14-lts)?
Running az webapp config container set --docker-custom-image-name 14-lts resets it to DOCKER|14-lts, which is not the same.
Running az webapp config container set --docker-custom-image-name "NODE|14-lts" produces an error.

We have tested in our local environment(created a webapp with Linux as runtime ) below findings are based on the analysis.
If you are using docker container as publish mode then LinuxFxVersion value will be "DOCKER|node:14-lts" you cannot change the value of LinuxFxVersion to "NODE|14-LTS".
If you want "NODE|14-LTS" value in LinuxFxVersion in the site properties
you need change the publish mode from docker container to code mode by using the below cmdlet.
az webapp config set --name <webappName> --resource-group <resourceGroupName> --linux-fx-version 'Node|14-LTS'

Related

azure container app does not update when updating it using cli

I have an azure container app running an aspdotnet core 6 webapi. I try to update it using azure cli and get a successful response but the update actual does not happen. I even try to redeploy the container again using the cli but does not work. What could really be the issue.
To update a container app, we use the az containerapp update cmdlet...
A new revision will be generated if your container app update contains revision-scope changes.
These and other configuration variables and parameters can also be defined in a YAML file.
See az containerapp revision copy for complete information.
This below sample code updates the container image.
az containerapp update \
--name <APPLICATION_NAME> \
--resource-group <RESOURCE_GROUP_NAME> \
--image <IMAGE_NAME>
The Revision copy command can also be used to update your container app.
Please refer this Microsoft Document about Revisions in Azure Container Apps.

How to change plan when deploing the app?

I had created my own subscription for Azure App Service. Then I had deployed my app (used CLI)
After that I remove the app, the resource group as well as subscription itself.
Now I got corporate subscription, create App Service via Azure UI and now trying to deploy my app to there.
When I use command
az webapp up --name MyAppName
i get message: The webapp 'MyAppName' exists in ResourceGroup 'MyCorporateGroup' and does not match the value entered 'MyPrivategroup '. Please re-run command with the correct parameters.
When I use command:
az webapp up --name MyAppName --resource-group MyCorporateGroup --subscription MyCorporateSubscription
I get: The plan name entered 'MyCorporateGroup_0' does not match the plan name that the webapp is hosted in 'MyCorporatePlanForAppService'.Please check if you have configured defaults for plan name and re-run command.
And when I use command:
az webapp up --name MyAppName --resource-group MyCorporateGroup --subscription MyCorporateSubscription -p MyCorporatePlanForAppService
i get message: Creating AppServicePlan MyCorporatePlanForAppService ...
(InvalidResourceLocation) The resource 'MyCorporatePlanForAppService' already exists in location 'germanywestcentral' in resource group 'MyCorporateGroup'. A resource with the same name cannot be created in location 'centralus'. Please select a new resource name.
Does anyone know how can i deploy my app to the corporate app service?
Thanks
The problem has been resolved when I remove .AZURE folder from my local machine. And then rebuild the app.
It seems to me you're not changing from one context to another. Try executing the following command before trying to update the web app in your corporate subscription:
az account set -s <corporate-subscription-name-or-id>

How can I query which docker image is currently deployed to an app service from an azure release pipeline?

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.

Azure app service private container registry login problem

I am using gitlab container registry and azure app service. in the app service I pull container from gitlab and serve it as a service. My problem is I push the new image from gitlab-ci.yaml to app's container settings but the problem is it clears up the login and password info under container settings, each time I push a new container version. So, I have to type my gitlab deploy token in the container settings page. How can I prevent this? Thanks. See the image
Here agree with CSharpRocks, according to the official document, we need to use the az webapp config container set command to specify the container registry and the image to deploy for the web app:
az webapp config container set --name <app-name> --resource-group AppSvc-DockerTutorial-rg --docker-custom-image-name <registry-name>.azurecr.io/appsvc-tutorial-custom-image:latest --docker-registry-server-url https://<registry-name>.azurecr.io
For details:
Replace <app_name> with the name of your web app and replace <registry-name> in two places with the name of your registry.
When using a registry other than Docker Hub (as this example shows),
--docker-registry-server-url must be formatted as https:// followed by the fully qualified domain name of the registry.
The message, "No credential was provided to access Azure Container
Registry. Trying to look up..." tells you that Azure is using the
app's managed identity to authenticate with the container registry
rather than asking for a username and password.
If you encounter the error, "AttributeError: 'NoneType' object has no attribute 'reserved'", make sure your <app-name> is correct.
Instead of using this to update your Web App
az webapp create
Try using
az webapp config container set --docker-custom-image-name MyDockerCustomImage --docker-registry-server-password StrongPassword --docker-registry-server-url [] --docker-registry-server-user DockerUserId --name MyWebApp --resource-group MyResourceGroup
Documentation

Deploy azure container registry images into an azure web app with docker-compose

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

Resources