Deploy a simple VS2017 Django app to Azure - server error

前端 未结 3 805
再見小時候
再見小時候 2021-01-27 03:53

I\'ve been trying to create a Django web app using VS2017 Preview (which includes Python tools for Visual Studio), and deploy the resulting app to Azure (I\'m currently on the 3

3条回答
  •  清歌不尽
    2021-01-27 04:26

    Right now, publishing support in VS 2017 is in a bit of a transition period. In the next couple of updates we want to get it back to a one-click system (and in the process, make it possible to publish Python apps from anywhere, not just within VS), but for now there are a couple of manual steps.

    (I'll summarize the steps below, but the canonical documentation will be at https://aka.ms/PythonOnAppService - right now it's a blog post with these steps and some of the backstory)

    1. After creating your new site (either through the portal or through VS - publishing content is okay too), install one of the Python site extensions Installing a site extension through the Azure Portal

    2. Configure your web.config file to have the correct path to the site extension you installed in the scriptProcessor attribute (something like D:\home\python361x64\python.exe - see the description of each extension for the actual paths - VS 2017 also includes item templates to help set these up, so look through Add New Item for ideas)

    3. Update the WSGI_HANDLER and DJANGO_SETTINGS_MODULE variables as necessary (a typical value for WSGI_HANDLER for a Django app is myapp.wsgi.application, assuming you have a wsgi.py file in your project)

    4. Publish your site through VS.

    5. Use the console to install your packages - e.g. D:\home\python361x64\python.exe -m pip install -r requirements.txt

    You may need to restart your site at this point if things were already running, but in general you can now publish quickly through VS without having to reinstall Python or any packages.

    If you are deploying your site through ARM with a JSON template, you can also specify the site extension there: (from here)

    "resources": [
      {
        "apiVersion": "2015-08-01",
        "name": "[parameters('siteName')]",
        "type": "Microsoft.Web/sites",
        ...
        "resources": [
          {
            "apiVersion": "2015-08-01",
            "name": "python352x64",
            "type": "siteextensions",
            "properties": { },
            "dependsOn": [
              "[resourceId('Microsoft.Web/sites', parameters('siteName'))]"
            ]
          },
        ...
    

提交回复
热议问题