Can I switch azure app service Publish Profile - azure

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.

Related

Azure container app cannot pull image from azure container registry which are present in different subscriptions

my scenario is like I have shared container registry in one subscription say subscription A, I need to pull image from ACR to ACA through DevOps pipelines. The ACAs are present for each environment like dev, test, UAT & etc which is in another subscription say subscription B. I am using 'az containerapp up' command in azure devops pipelines to pull image of the shared ACR. Getting error 'The resource is not found in the subscription B'. What might be the alternative possible solution because we need to reduce cost of using container registry for each environment.
I am using service connections to pull image and the service connections are separate for separate subscriptions.
I know that they are in different subscriptions but I searched on websites to connect two different subscriptions.
Is there a possibility that I can connect two different service connections in azure devops & use one service connection to pull that image.
Before integrating the Azure CLI command az containerapp up with Azure pipelines, please first confirm you are able to pull the ACR image from Sub B to deploy the container app in Sub A via CloudShell or LocalPowerShell.
I tested to create ARM service connection with Tenant Root Management Group whose referenced service principle had access to both subscriptions; the issue still existed.
In local PowerShell, I az login with my user account and still could reproduce the issue.
az containerapp up `
--name XXcontainerapp `
--image XXacrsubB.azurecr.io/azurecontainerappdemo:XX `
--resource-group rg-containerapp `
--environment TestEnv `
--registry-username XXacrsubB `
--registry-password XXXXXX
It seemed to be a limitation with this command az containerapp up. You may consider reporting the issue with Azure CLI.

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]

Azure Container Instances - from where to execute "docker login" before we execute "az container create" command

we need to deploy ACI - Azure Container Instance in private virtual network.
We followed the example and prepared YAML file from this link.
https://learn.microsoft.com/en-us/azure/container-instances/container-instances-vnet
So now we need to execute before that our command:
az container create --resource-group myResourceGroup --file vnet-deploy-aci.yaml
in that yaml we are referencing our image, similarly like from the above example (just we are using our private repo )
image: mcr.microsoft.com/azuredocs/aci-helloworld
I do not have permission to execute this because of Azure permissions, so I sent this yaml file to one of Azure admins but he does not have experience with containers, so he is , as well as I am confused from where he should trigger and execute docker login repo command and enter credentials, before he execute the az container create.
Can you please provide me some guidance since I did not see that on that Azure docs link as well but I suppose that "docker login" command is required before we trigger "az create" command which deploys our yaml?
THANK YOU!
Actually, you don't need to execute the command docker login when you use the YAML to create ACI. You just need to use the imageRegistryCredentials option to configure the credential for the private registry.
And if you use the image mcr.microsoft.com/azuredocs/aci-helloworld, then you do not need any credential, as I know, it's a public image. So you only need to follow the steps in the doc you provide.

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.

How to harvest Azure Web App For Containers webhook

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

Resources