I've tried the following azure command:
az webapp update --resource-group <YourResourceGroupName> --name <YourWebAppName> --set httpsOnly=true
However I got the following response:
az: error: unrecognized arguments: --set httpsOnly=true
I'm running the command in the docker image azuresdk/azure-cli-python version 2.0.23
EDIT:
My mistake: I was not running az update but az deployment (which btw should support the httpsOnly flag IMO).
We should use this command to set HttpsOnly for Azure Web app.
az webapp update --resource-group <YourResourceGroupName> --name <YourWebAppName> --set HttpsOnly=true
I run this command in Azure cloud shell, that works for me:
Also we can check it via Azure portal:
Note:
The Azure CLI version is 2.0.23, we can find the CLI 2.0 release here, we can follow this link to install Azure CLI 2.0.
Related
Have a question on Azure need to deploy an azure container app by pulling the image from azure container registry from AZ
Steps:
1- az login -successful
2- az acr login appdev - successful
3- az containerapp create --name apptest --resource-group \
testapp --image appdev.azurecr.io/dev/dev-app:latest \
--environment MyContainerappEnv \
Throwing this error:
the following field(s) are either invalid or missing. Invalid value: "appdev.azurecr.io/dev/dev-app:latest": GET https:?scope=repository%3Adev%2Fdev-app%3Apull&service=appdev.azurecr.io: UNAUTHORIZED: authentication required, visit https://aka.ms/acr/authorization for more information.: template.containers.apptest.image
I have already logged in successfully and able to pull the image using
docker pull appdev.azurecr.io/dev/dev-app:latest
Also this is successful
az acr login --name appdev
Login Succeeded
Able to push the image to ACR .
I already have contributor permission to the subscription.
Can anyone help? Thanks
this worked:
az containerapp create --name apptest \
--resource-group testapp \
--image appdev.azurecr.io/dev/dev-app:latest \
--environment MyContainerappEnv \
--registry-server appdev.azurecr.io //adding this
Go to
your container registry => Access token => set admin user to "enabled"
You should add a commend below during creating az containerapp using Azure CLI.:
--registry-server appdev.azurecr.io
Azure Container Registry:
`az acr create --resource-group $RESOURCE_GROUP --name $ACR_NAME --sku Basic '--admin-enabled true
Created Azure app services web app without using any Docker registry integration.
I want achieve below.
1] create, tag image on my Linux machine
2] deploy local Docker image to App services web app using below
az webapp config container set --name springboot-docker-helloworld-app --resource-group SpringBoot --docker-custom-image-name org/dockerspringtboot-metinv:latest
But it is not working.
Is it possible to deploy local Docker images to Azure app services web app ?
You'll need to push your container image to an Azure container registry from which your Azure web app can pull the image.
You can do this using Azure CLI with the following steps:
$ az acr create --resource-group your_rg \
--name yourAcrName --sku Basic
# login to the container registry locally
$ az acr login --name yourAcrName
# update the container registry to use admin-enabled
# https://learn.microsoft.com/en-us/azure/container-registry/container-registry-authentication?tabs=azure-cli#admin-account
$ az acr update -n yourAcrName --admin-enabled true
# tag your local image to the container registry
$ docker tag dockerspringtboot-metinv:latest yourAcrName/dockerspringtboot-metinv:latest
# push image to your container registry
$ docker push yourAcrName/dockerspringtboot-metinv:latest
Then you can create an app service plan and deploy the web app specifying to use your container registry.
$ az appservice plan create -g your-rg \
-n your-app-plan \
--sku B1 --is-linux
# deploy your container as an app in the created App Service plan
$ az webapp create -g your-rg \
-p your-app-plan \
-n dockerspringtboot \
-i yourAcrName/dockerspringtboot-metinv:latest
I'm trying to setup a script for automate the creation of a new environment for my app, and i need a docker webapp.
The problem is that i need to pull the image from docker hub.
When i create an env from the interface in juste setup it like that :
The problem is that i don't find out how i can configure the "Source de registre" on Docker Hub by the az cli.
For now the command i'm using to create a new web app ressource is this one
az webapp create -g name_of_group -p name_of_plan -n resource-test2 -i https://registry.hub.docker.com/publisher/name_of_image:version -s name_of_image -w my_password
The problem of this command is that it give me this configuration
Which doesn't work because i can't get logged in (probably because it's not configured as a Docker Hub registre).
Do you know how i can specify this configuration in my az cli command ? Thanks
To deploy the images stored in a private registry or the Docker Hub, you can set the environment variables below:
DOCKER_REGISTRY_SERVER_USERNAME - The username for the ACR server.
DOCKER_REGISTRY_SERVER_URL - The full URL to the ACR server. (For example, https://my-server.azurecr.io.)
DOCKER_REGISTRY_SERVER_PASSWORD - The password for the ACR server.
Get more details here. And you can use the CLI command az webapp config appsettings set to do it.
Recently had the same problem deploying azure cloud webapp from a container in my private docker hub repo. UI experience works fine but when I do it using azure cli with 'az webapp create ...' ended up with same problem. I was able to fix it by using 'az webapp config container set ...' command after creating the webapp. See below and in my github repo
# First create the webapp with a docker container:
~$ az webapp create -n $webAppName -g $resGroup -p $servicePlan -i $containerImg -s $dockerUsr -w $dockerPass --tags Lifecycle=Test
# Update docker container settings with your private docker hub repo credentials:
~$ az webapp config container set --name $webAppName --resource-group $resGroup --docker-custom-image-name 'DOCKER|dockeruser/myrepo:tweb1' --docker-registry-server-url 'https://index.docker.io/v1' --docker-registry-server-user 'dockeruser' --docker-registry-server-password 'xxxxxxxxxxx'
I have deployed a "Container Image" on to Web App Service with the following command.
az webapp create --name Dev-App --plan Dev-AppServicePlan \
--resource-group Dev \
--deployment-container-image-name ...devcontainerregistry.azurecr.io/app-node:latest
After the app was successfully deploment I need to change some Environment variables via the following commands.
az webapp config appsettings set --name Dev-App --resource-group Dev \
--settings MONGO_DSN='mongodb://cosmosdb...'
az webapp config appsettings set --name Dev-App --resource-group Dev \
--settings REDIS_URI='...dev.redis.cache.windows.net:6380...'
az webapp log config --name Dev-App --resource-group Dev \
--docker-container-logging filesystem
Now I have updated and restarted the Web App but it looks like the Image is not redeployed or at least the Environment variables are not there.
az webapp update --name Dev-App --resource-group Dev
az webapp restart --name Dev-App --resource-group Dev
I looked with log tail to the logs but the logs are also not changed. What I mean with "not changed" is that the log output is stucked to the Timestamp "2021-01-13T13:21:31.100Z" even when I restart the Web App.
az webapp log tail --name Dev-App --resource-group Dev
In this Articles from MS is described that a restart should be enough but then should also the log output should be changed.
2: Redeploy a container to Azure App Service after making changes
Configure a custom container for Azure App Service
Any hint how to activate the new settings in the custom image setup or trigger a redeployment?
FYI: I have also created a question in the azure community.
https://learn.microsoft.com/en-us/answers/questions/230584/how-to-activate-settings-in-the-web-app-when-deplo.html
It seems you want to updates the environment variables just like add them in the command:
docker run --name container_name image -e env_var1 -e env_var2
The Azure CLI command just sets the environment variables for the Web App service, you can see them in the Kudu, but it's not the same result as the docker run command.
I recommend you use the docker-compose to deploy your image to the Web App service. Here is the example for the docker-compose. You can update the environment variables in the environment option of the docker-compose file in the portal. Then it will restart again and refresh the logs. And the variables you added will also take effect.
Well the solution for my problem was that I change the registry from "Private Registry" to "Azure Container Registry" in the "container settings" page after running the following command
az webapp create --name Dev-App \
--plan Dev-AppServicePlan \
--resource-group chat-Dev \
--deployment-container-image-name devcontainerregistry.azurecr.io/chat-node:latest
I have put the acr data into the fields and activated the "Continous Deployment"
After this change every settings change triggers a restart and the ENV Variables was in the new instance.
going through tutorial https://learn.microsoft.com/en-us/azure/app-service/containers/tutorial-custom-docker-image
Is it possible to switch docker image on already running appservice?
using this command:
az webapp config container set --name <app-name> --resource-group myResourceGroup --docker-custom-image-name <azure-container-registry-name>.azurecr.io/mydockerimage:v1.0.0 --docker-registry-server-url https://<azure-container-registry-name>.azurecr.io --docker-registry-server-user <registry-username> --docker-registry-server-password <password>
az webapp config container
You should go on deployment center.