https://pulumi.com logo
#azure
Title
# azure
s

swift-hamburger-98290

04/13/2021, 1:24 PM
Does anyone know how to deploy a python
App Service
with ZIP? How to make Azure (Oryx?) create the virtualenv? Have this now:
Copy code
...
let app = new web.WebApp("app", {
  resourceGroupName: rg.name,
  serverFarmId: asp.id,
  siteConfig: {
    alwaysOn: true,
    appCommandLine: "python /home/site/wwwroot/__init__.py",
    appSettings: [
      {
        name: "WEBSITE_RUN_FROM_PACKAGE",
        value: codeUrl,
      },
    ],
    linuxFxVersion: "PYTHON|3.8",
  },
});
But the virtual env is not created, and dependencies are not installed.
c

cool-fireman-90027

04/13/2021, 2:06 PM
You could set the virtual env via:
Copy code
$ python3 -m venv venv
$ source venv/bin/activate
$ pip3 install -r requirements.txt
as per the readme in azure-py-appservice. The appservice settings are also set there. Here is how you could do it:
Copy code
const app = new web.WebApp("fa", {
    resourceGroupName: resourceGroup.name,
    name: "myuniqueapp",
    location: resourceGroup.location,
    serverFarmId: plan.id,
    kind: "functionapp",
    siteConfig: {
        appSettings: [
            { name: "AzureWebJobsStorage", value: storageConnectionString },            
            { name: "FUNCTIONS_EXTENSION_VERSION", value: "~3" },            
            { name: "FUNCTIONS_WORKER_RUNTIME", value: "node" },
            { name: "WEBSITE_NODE_DEFAULT_VERSION", value: "10.14.1" },
            { name: "WEBSITE_RUN_FROM_PACKAGE", value: "<https://mikhailworkshop.blob.core.windows.net/zips/app.zip>" },
        ]    
    },
});
s

swift-hamburger-98290

04/13/2021, 2:14 PM
I work with venv locally (macOS), but I am using a Linux AppServicePlan. So in case of native dependencies, it won't work. I would like to deploy only my code (
requirements.txt
and
main.py
) and have Azure do
python3 -m venv venv; source ...
on each deployment.
Just an update in case someone finds this: • Azure (Oryx) does not run
pip install
because
pulumi up
is not seen as a deployment (it does not appear in the deployments under Kudu • Running
az webapp deployment
works fine
4 Views