I want to deploy python
app to an existing azure
app service from bitbucket
pipeline using azure cli, but I found only single way to deploy python app to azure app service (docs)
az webapp up --name <app_name>
This seems not to work for already created azure app service. Also I found that it cannot be used for deployment in to the existing apps in this comment
Since I want to run it from bitbucket local git
is not an option to me. I also don't want direct integration with bitbucket via deployment center because I want to trigger the deployment on demand from bitbucket.
For example you can easily deploy .net
app with zip deployment by running the following:
az webapp deployment source config-zip --resource-group <resource_group> --name <app_name> --src <zip_name>
Can you do something similar for python
?
The below script creates a new web app and deploys the python flask example from the docs you sent. It uses az webapp deployment source config-zip
as you wanted. The part of the configuration worth exploring is the setting SCM_DO_BUILD_DURING_DEPLOYMENT=true
described here. When set to true there are additional steps running during deployment e.g. installing python packages.
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 that I used Compress-Archive
, if you're not using Powershell, then you'll need to create a zip package different way.