azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

[BUG] Cannot create windows container based WebApp

Open tsgenge opened this issue 6 years ago • 15 comments

Describe the bug When creating a web app on a hyper-v (windows container) service plan pulling from ACR, the command returns with an access denied attempting to authenticate with the ACR.

To Reproduce

  1. Create a new service plan using --sku PC2 and --hyper-v.
  2. Create a new web app using a container image hosted on ACR and the new service plan.

This returns with an access denied.

For linux images this works fine (it does some discovery and manually enters the ACR credentials).

Attempting to create a web app on this service plan with no image specified also does not work (actually crashes out).

The command failed with an unexpected error. Here is the traceback:

'NoneType' object has no attribute 'strip' Traceback (most recent call last): File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-0u_uiwkq\knack\knack\cli.py", line 206, in invoke File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-0u_uiwkq\azure-cli-core\azure\cli\core\commands_init_.py", line 608, in execute File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-0u_uiwkq\azure-cli-core\azure\cli\core\commands_init_.py", line 666, in run_jobs_serially File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-0u_uiwkq\azure-cli-core\azure\cli\core\commands_init.py", line 657, in run_job File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-0u_uiwkq\azure-cli\azure\cli\command_modules\appservice\commands.py", line 55, in polish_bad_errors File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-0u_uiwkq\azure-cli-core\azure\cli\core\commands_init.py", line 636, in run_job File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-0u_uiwkq\azure-cli-core\azure\cli\core\commands_init.py", line 306, in call File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-0u_uiwkq\azure-cli-core\azure\cli\core_init.py", line 493, in default_command_handler File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-0u_uiwkq\azure-cli\azure\cli\command_modules\appservice\custom.py", line 131, in create_webapp File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-0u_uiwkq\azure-cli\azure\cli\command_modules\appservice\custom.py", line 789, in _format_fx_version AttributeError: 'NoneType' object has no attribute 'strip'

Code Snippet az webapp create -n [name] -g [rg] -p [sp] -i [namespace].azurecr.io/[image]:latest

Also fails; az webapp create -n [name] -g [rg] -p [sp]

Expected behavior The web app should create with container configuration.

tsgenge avatar Jan 24 '20 15:01 tsgenge

@tsgenge

It seems to me that this is Azure CLI issue, not Azure Java SDK.

If it is actually a Java SDK issue, would you include related Java code sample?

If you are OK with it, I can transfer it to CLI's repo https://github.com/Azure/azure-cli

weidongxu-microsoft avatar Jan 25 '20 05:01 weidongxu-microsoft

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AzureAppServiceCLI @antcp

ghost avatar Feb 03 '20 02:02 ghost

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AzureAppServiceCLI @antcp

ghost avatar Feb 03 '20 02:02 ghost

@vinisoto can you help here?

panchagnula avatar Aug 04 '20 06:08 panchagnula

Thanks for the progress guys, we generally love the Azure CLI; our whole infrastructure being deployed and configured from script during each deployment (idempotent); just awesome.

tsgenge avatar Aug 04 '20 07:08 tsgenge

Looks like this might have been fixed with #13813. Please note that if your container is in ACR you need to specify the ACR credentials --docker-registry-server-user <<some user name>> --docker-registry-server-password <<some password>> as part of the webapp create command:

az webapp create --name myWebsite --plan myAppServicePlan --resource-group myResourceGroup --deployment-container-image-name https://mycontainerregistry.azurecr.io/mycontainerimage:latest --docker-registry-server-user <<some user name>> --docker-registry-server-password <<some password>>

Creating a Windows Containers web app without specifying a container image is not supported.

Please give it a try and if you are still experiencing issues let us know.

vinisoto avatar Aug 04 '20 14:08 vinisoto

Thanks guys, we appreciate the response and engagement. Keep up the good work!

Happy to report this does indeed work... however we’ve transitioned back to vanilla web apps due to deployment slot support and other features still being a little inconsistent on Windows containers. Size and cost also impacted the decision. Instead our brown field web apps will eventually transition to .Net core and Linux, but until then they’ll remain vanilla web apps.

tsgenge avatar Aug 05 '20 09:08 tsgenge

Thanks for the feedback @tsgenge . Closing the issue for now.

panchagnula avatar Aug 05 '20 15:08 panchagnula

@tsgenge could you tell us which features are still missing or inconsistent in Windows Containers on App Service compared to "classic" Web Apps?

I'm asking because we are getting prepared for GA and we will have a lot of interesting features and we are closing the gap and your feedback is very valuable for us moving forward.

Thanks,

Joaquín

jvano avatar Aug 05 '20 21:08 jvano

Hi guys, I was waiting for this fix to roll out for a couple of months now. I just tried again and got the same "access denied" issue, but I hadn't seen the following:

@vinisoto

--docker-registry-server-user <> --docker-registry-server-password <>

You have kept this tidbit of information well hidden!

However I am seeing this error when trying to create a new deployment slot, I am not trying to create a new web app - the web app already exists and has a container running in the default / primary slot.

I am using this command:

https://docs.microsoft.com/en-us/cli/azure/webapp/deployment/slot?view=azure-cli-latest#az-webapp-deployment-slot-create

and I get:

image

The tag its complaining about is the image thats running on the default slot.

dazinator avatar Aug 12 '20 16:08 dazinator

Also it seems if you have used WebHooks to deploy from ACR in the past, you will already have the docker image repository server url, username, and password added as configuration values:

image

When attempting to cretae a new deployment slot using the cli, does it try to use those value if they already exists? Or does it expect new values to be passed? It wasn't clear from the docs.

Also it seems a little off that the cli argument for user name is --docker-registry-server-user but the config value that WebHooks creates (as shown in my screenshot above) is DOCKER_REGISTRY_SERVER_USERNAME - i.e should the cli argument not be --docker-registry-server-username to be consistent? The other ones are consistent in this way (for url, and password)

dazinator avatar Aug 12 '20 16:08 dazinator

Hi @dazinator - thanks for reporting this.

Can you try specifying --configuration-source <<your-web-app-name>>? For example:

az webapp deployment slot create --name uniun-dev --resource-group development --slot pr199 --configuration-source uniun-dev

by doing that, the cli will use DOCKER_REGISTRY_SERVER_USERNAME, DOCKER_REGISTRY_SERVER_URL and DOCKER_REGISTRY_SERVER_PASSWORD from your production slot (as you suggested).

Probably it makes sense to either make this default behavior (as in, you wouldn't need to specify the production slot as the configuration source explicitly - at least for the container settings) or add the support for providing --docker-registry-server-user, --docker-registry-server-password and --deployment-container-image-name as part of slot creation.

Please let me know of the above unblocks you and thank you for using Windows Containers on App Service

vinisoto avatar Aug 12 '20 21:08 vinisoto

@vinisoto I tried with --configuration-source and it gives the same error:

image

Yet, I was able to log in via azure portal, and create the slot through the azure portal UI, selecting to "clone settings" from the production slot - and that worked. I have sometimes seen this error when attempting to create the slot in the azure portal UI though but not on this occassion. When it does happen in the Azure portal UI, I usually elect to clone a different slot, and that usually works, then after the slot is created, I change the image to the one I want.

dazinator avatar Aug 12 '20 21:08 dazinator

@vinisoto I did some more digging. It looks like installing the newer version of azure cli may have solved my problem with this command. I was seeing the above problem whilst using:

PS C:\Users\DarrellTunnell> az version
{
  "azure-cli": "2.5.1",
  "azure-cli-command-modules-nspkg": "2.0.3",
  "azure-cli-core": "2.5.1",
  "azure-cli-nspkg": "3.0.4",
  "azure-cli-telemetry": "1.0.4",
  "extensions": {
    "azure-devops": "0.17.0"
  }
}

I updated to 2.10.1 and re-ran the command, and now it seems to work. Sorry for the false alarm.

dazinator avatar Aug 12 '20 21:08 dazinator

@dazinator - glad it worked

Let us know of you find any other issues.

vinisoto avatar Aug 12 '20 21:08 vinisoto