Last active
January 4, 2019 05:38
Revisions
-
sjwaight revised this gist
Jan 4, 2019 . 1 changed file with 17 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,15 @@ # # Build and deploy Python Azure Function v2 (preview) on Azure DevOps # # Paste this as an inline script into an "Azure CLI" Build Task running on an Ubuntu 16.04 managed host. # # Set Build Variables: # # FunctionFolder = name of folder containing your Function # FunctionAppName = name of the target Azure Function that will receive the deployment. # Step 1: Install Python 3.6 & Functions Core tools # Functions source wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb @@ -17,10 +28,12 @@ sudo apt-get install azure-functions-core-tools sudo apt-get install python3.6 sudo apt-get install python3.6-venv # Step 2: Initialise Python Virtual Environment (venv) python3.6 -m venv .env source .env/bin/activate # Step 3: Initialise and build Function App # Backup our source requirements.txt file mv $(FunctionFolder)/requirements.txt $(FunctionFolder)/requirements.orig.txt @@ -34,9 +47,9 @@ rm $(FunctionFolder)/requirements.txt # Restore our original requirements.txt file mv $(FunctionFolder)/requirements.orig.txt $(FunctionFolder)/requirements.txt # Install Functions extensions for Function cd $(FunctionFolder) func extensions install # Step 4: Deploy (uses Docker) - FunctionAppName should be an existing Linux Consumption App Plan func azure functionapp publish $(FunctionAppName) --build-native-deps -
sjwaight created this gist
Jan 4, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ # install Functions core tools & Python 3.6 # Functions source wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb # Python 3.6 package for Ubuntu 16.04 sudo add-apt-repository ppa:deadsnakes/ppa # Update packages list sudo apt-get update # Install Azure Functions Core Tools sudo apt-get install azure-functions-core-tools # install Python3 and Virtual Environment support sudo apt-get install python3.6 sudo apt-get install python3.6-venv # init Python venv python3.6 -m venv .env source .env/bin/activate # Backup our source requirements.txt file mv $(FunctionFolder)/requirements.txt $(FunctionFolder)/requirements.orig.txt # Initialise Function environment locally so it sets runtime to Python # Note: this also overwrites requirements.txt func init $(FunctionFolder) --worker-runtime python # Delete the newly created requirements.txt file rm $(FunctionFolder)/requirements.txt # Restore our original requirements.txt file mv $(FunctionFolder)/requirements.orig.txt $(FunctionFolder)/requirements.txt # now install Functions extensions for Function cd $(FunctionFolder) func extensions install # deploy (uses Docker) - FunctionAppName should be an existing Linux Consumption App Plan func azure functionapp publish $(FunctionAppName) --build-native-deps