1
votes

After deploying my Python Function App, when I try to run it on Azure cloud, it fails with the following error: How can I install azure-storage on the machine running the app service? Please help.

import azure.functions as func import datetime

import os, uuid, sys from azure.storage.blob import BlockBlobService, PublicAccess ..... ......

1
the error: ----- exception while executing function: Functions.HttpTrigger Result: Failure Exception: ModuleNotFoundError: No module named 'azure.storage' Stack: File "/usr/local/lib/python3.6/site-packages/azure/functions_worker/dispatcher.py", line 230, in _D Workie
Do you have a requirements.txt file containing the packages that your function requires? link to docsthmsdnnr
Yes, this is the content of the txt file azure-storage-blob==1.5.0 azure-storage-common==1.4.2 azure-storage-file==1.4.0 azure-storage-queue==1.4.0 azure-functions azure-functions-worker grpcio==1.14.1 grpcio-tools==1.14.1 protobuf==3.6.1 six==1.11.0D Workie
And then I get this error on deployment if I have the requirements.txt populated with the above: There was an error restoring dependencies.ERROR: cannot install cryptography-2.7 dependency: binary dependencies without wheels are not supported. Use the --build-native-deps option to automatically build and configure the dependencies using a Docker container. More information at aka.ms/func-python-publishD Workie
@Thmsdnnr Thank you so much for pointing that out. I actually followed that and did not work. However after fresh install of the Core tools and Docker, I managed to build the package and run it. This is the build command I used: func azure functionapp publish <app name> --build-native-depsD Workie

1 Answers

0
votes

Connect to your Azure CLI or You can Open Azure CLI from the Azure portal as well.

Create Storage Account:

az storage account create --name --location --resource-group --sku Standard_LRS

Ex:- az storage account create --name apistorage --location westindia --resource-group apiGroup --sku Standard_LRS

Create Resource Group:

az group create --name --location

Ex:-
az group create --name apiGroup --location westindia

Now you can create your azure function from CLI:

Ex:- az functionapp create --resource-group apiGroup --os-type Linux --consumption-plan-location westindia --runtime python --name ServiceName --storage-account apistorage

Reference:

https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-python