Reputation: 37
I am new to Azure functions. I have a python function on my local system with azure.storage.blob imported. When I try to publish it directly from Visual Studio Code I get the error this cannot be build and use --build-native-deps. For this I opened Azure CLI but I am not sure where to keep my code on Azure cloud in this to be published.
Appreciate all the help in advance.
This worked with functions with consumption plan. But when I try to do the same with App Service Plan I have created this does not work. When I run
func azure functionapp publish remote-gc-copy --build remote
I just get Remote Build Successful but doesn't publish.
Upvotes: 2
Views: 1370
Reputation: 15724
You can just use func azure functionapp publish command
func azure functionapp publish <APP_NAME> --build remote
First you need to create a resource group and a storage account. You can do it on Azure portal or by Azure CLI command. Here are the commands if you want to use Azure CLI.
az group create --name myResourceGroup --location westeurope
az storage account create --name <storage_name> --location westeurope --resource-group myResourceGroup --sku Standard_LRS
Second you need to create your azure function app:
az functionapp create --resource-group myResourceGroup --os-type Linux --consumption-plan-location westeurope --runtime python --name <APP_NAME> --storage-account <STORAGE_NAME>
The func azure functionapp publish is Azure Functions Core Tools command, so you need to install Azure Functions Core Tools command before that, please refer to this tutorial to install it. And then in your powershell connect to your Azure account(if you use rm command: Connect-AzureRmAccount), navigate to your python dir and run the func azure functionapp publish command(shown as below)
For further information, you can refer to this tutorial.
By the way, Azure function just support 3.6.x version of python, so if you install python 3.7 it may cause the error when you publish it from vs code to azure.
Upvotes: 1