How to harvest Azure Web App For Containers webhook - azure

I wish to bind the web app update & warm start to the Azure container registry image using the web app's container webhook URL. I can find the Azure CLI command for creating the webhook push in the ACR, but haven't yet found how to query the web app.
Thanks.

az webapp deployment container config -n sname -g rgname -e true
from https://learn.microsoft.com/en-us/azure/app-service/containers/app-service-linux-cli

Related

Error when trying to create a webapp using CLI

I have no experience in coding, just started now.
I am trying to create a webapp using the Azure Cloud Shell, so I used the following command:
az webapp create --name WebAppOne --resource-group learn-64c4ca17-0293-40f6-ba23-e4581751cca0 --plan ServicePlanTest
Then I get the message:
Webapp 'WebAppOne' already exists. The command will use the existing app's settings.
Unable to retrieve details of the existing app 'WebAppOne'. Please check that the app is a part of the current subscription
I only have one subscription in Azure as I am still using a free account for learning purposes.
So, I decided to get a list showing the webapps that exist by using the command:
az webapp list --output table
However, the only outcome is a blank line, showing no web apps already existing. What should I try next?
To create a web app in Azure App service, you must have a resource group and App service plan in your subscription.
To check the existing App services in your subscription
az webapp list --resource-group MyRGName
Output :
As you can see, currently I don't have any webapps created in the given Resource group
Run the below command to create an Azure Web App
az webapp create --name MyWebApp --resource-group MyRGName --plan MyAppServicePlan
Though I don't have any Webapps with the given name, I got the same error.
In Azure Portal => Azure Active Directory => App registrations => All applications
In search box, searched with the web app name. I can see the web app with same name is already created.
Reason for the error
You might have created a web app with same name long ago, but the resource got deleted from the resource group. But still, it is available in the Azure Active Directory App registrations.
If it is created by you and you don't want to use anymore, you can delete it. If not create web app with another name.
Tried to create web app with another name.
Create Azure App Service:
Now I can see the created Web App List.
List of Azure Web Apps

How can I deploy image to Azure App Service from an ACR which is located in different subscription?

I want to deploy an image to Azure App Service. The image is in the ACR which is in different subscription and App Service is in other subscription. Is there any way to deploy the image.
I will be using terraform to setup the App Service and Azure DevOps Pipeline to deploy new version of images
In case when your ACR is in a different subscription you need to treat this ACR as private docker hub and provide following app settings:
DOCKER_REGISTRY_SERVER_URL
DOCKER_REGISTRY_SERVER_USERNAME
DOCKER_REGISTRY_SERVER_PASSWORD
Of course you need to provide also linux_fx_version

Map Custom domain to Azure web app deployment slot

I want to automate mapping a custom domain for my web app's deployment slots(not the production slot). I have achieved this through the Azure Portal with this guide, but I can't get it to work through the AZ CLI. It appears that in the cli, only through for the production slot is possible to achieve mapping a custom domain. This is the command to do it for the production slot but I can not see an option for other slots on the same web app. Also whatever I try on the webapp-name parameter to try and reference the slot(as supposingly is a separate web app) doesn't work(it keeps giving me app not found errors):
az webapp config hostname add --webapp-name <app_slot_name> --resource-group <rg> --hostname <cname_that_already_exists>
You can use --slot.
Offical doc.
az webapp config hostname add
az webapp config hostname add [--hostname]
[--ids]
[--resource-group]
[--slot]
[--subscription]
[--webapp-name]

Connecting an Azure Web app (container) to an Azure container registry using the CLI

I'm trying to Connect a Azure Webb app (containers) to an Azure Container Registry Using the Azure CLI. I have an Azure Container Registry located in the same Ressouce Group as the Webb App.
My command looks like this:
az webapp config container set --name "containerbugdemo" --resource-group "Containerbug" --docker-custom-image-name "application/helloworld:latest" --docker-registry-server-url "https://"$arcName.azurecr.io" --docker-registry-server-password "****" --docker-registry-server-user "***"
After running the command the container settings blade shows the following error:
Failed to get a list of tags.
And the Container fails to get pulled by the WebApp.
If I try the same procedure only using the graphical interface through the Azure portal, everything works as expected.
It seems you set the wrong image name. If you use the image in the ACR, you need to set the image name as acrname.azurecr.io/repository:tag, both when you create the web app and container setting, not just repository:tag. And the server URL is also a mistake that one more double quote in the question.

Can I switch azure app service Publish Profile

In azure web app we have two option to publish our code:
Via Code
Via Docker image
is there any way i can switch between this two.
Actually if you select Publish Profile as Connection Type you cannot deploy docker image. Please check this:
for Azure Resource Manager you can select container deployment:
but for Publish Profile you don't have this choice:
The same apply for YAML version.
I'm afraid that you can not change from code to container , but you can have two instances of your code, one using code and one using container within the same service app. You can re-created your webapp with the same name but with a different deployment method in the portal.
For details , please refer to this ticket with similar issue.
To switch the publish method from docker to code you can set the linuxFxVersion via Azure CLI. For example:
az webapp config set --name myWebApp --resource-group rgname --linux-fx-version 'DOTNETCORE|3.1'
To switch from code to docker you can just deploy a docker container and the web app will automatically switch to the docker publish method. For example:
Set-AzureRmWebApp -ResourceGroupName rgName -Name myWebApp -ContainerImageName imageName:tag -ContainerRegistryUser userName -ContainerRegistryPassword $passwordSecure -ContainerRegistryUrl url
I have not tested it for windows apps but I supect it will behave similarly.

Resources