【问题标题】:Operation returned an invalid status 'unauthorized' when deploying Python appOperation returned an invalid status \'unauthorized\' when deploying Python app
【发布时间】:2022-12-02 06:29:30
【问题描述】:

I am following this guide to deploy python app on Azure. https://learn.microsoft.com/en-us/azure/devops/pipelines/ecosystems/python-webapp?view=azure-devops

I was successfully able to clone the repo and authenticated through Github in Azure Portal Shell.

But I got above error when I tried to deploy the app using the following command. az webapp up -n PythonFlaskAppExampleApp

【问题讨论】:

    标签: python azure azure-web-app-service


    【解决方案1】:

    We need to make sure that all the configurations has been done which building python webapp. below are few key points where we need to look into:

    1. For FlaskApp App service looks for App.py which has below content:
       If application.py
      gunicorn --bind=0.0.0.0 --timeout 600 application:app
       If app.py
      gunicorn --bind=0.0.0.0 --timeout 600 app:app
      
      1. Check for customized build automations in MS Docs

      Also below are few predefined configs which needs to be set, check them one by one based on your requirement:

          az group create -n <some_name> --location westus
          az appservice plan create --name <some_name> -g <some_name> --sku s1 --location westus --is-linux
          az webapp create -g <some_name> -n <some_globaly_unique_name> --plan <some_name> --runtime "PYTHON|3.7"
          az webapp config appsettings set -g <some_name> -n <some_globaly_unique_name> --settings WEBSITE_RUN_FROM_PACKAGE="1"
          az webapp config appsettings set -g <some_name> -n <some_globaly_unique_name> --settings SCM_DO_BUILD_DURING_DEPLOYMENT=true
          az webapp restart -n <some_globaly_unique_name> -g <some_name>
      
          git clone https://github.com/Azure-Samples/python-docs-hello-world
          cd .python-docs-hello-world
          Compress-Archive -Path * -DestinationPath package.zip
          az webapp deployment source config-zip -n <some_globaly_unique_name> -g <some_name> --src .package.zip
      

      Note: Check for your current versions and replace them accordingly.

    【讨论】:

      【解决方案2】:

      For some reason, I had to manually create app-service from Azure Portal UI, as az webapp up -n &lt;your-appservice&gt; command didn't work. It deployed app successfully after creating it.

      【讨论】:

        【解决方案3】:

        Try running az account set -s &lt;Subscription ID&gt; first.

        Even if you already logged in with the Azure CLI, that still may not pick a subscription for billing. You have to set that first. This is what solved the problem for me. The selected answer did it through the web portal, which does pick a subscription for you.

        【讨论】:

        • Please consider adding some explanation describing how the command solves the problem.
        猜你喜欢
        • 2015-10-17
        • 2019-03-26
        • 2022-12-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-11-20
        • 2022-12-01
        • 1970-01-01
        相关资源
        最近更新 更多