Fixed my problem. I missed the most important step, and that is to upload my local settings. Usually after a function is deployed to Azure, a prompt will come up asking you to upload local settings. You can click on that, but if you aren't sure, manually invoke uploading the local settings with this: ![12026-image.png][1] [1]: /api/attachments/12026-image.png?platform=QnA
Azure Function in Python works locally but when pushed to cloud, trigger doesn't work
Hi, I created a blob triggered Azure Function that will copy the file uploaded into a Blob container into another blob container.
Here's my function.json:
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "myblob",
"type": "blobTrigger",
"direction": "in",
"path": "dropzone/{name}.xlsx",
"connection": "mystorage_STORAGE"
},
{
"type": "blob",
"direction": "out",
"name": "outputBlob",
"path": "processed/{name}.xlsx",
"connection": "mystorage_STORAGE"
}
]
}
My init.py file:
import logging
import azure.functions as func
def main(myblob: func.InputStream, outputBlob: func.Out[func.InputStream]):
logging.info(f"Python blob trigger function processed blob \n"
f"Name: {myblob.name}\n"
f"Blob Size: {myblob.length} bytes")
outputBlob.set(myblob)
When I debug locally, it works ok! But once I publish to the cloud, it doesn't work at all.
I noticed in my app settings via Azure Portal, the storage connection "mystorage_STORAGE" was not there. Should I be using the default "AzureWebJobsStorage"?
Any ideas anyone?
Regards,
Max
1 additional answer
Sort by: Most helpful
-
MayankBargali-MSFT 70,826 Reputation points
2020-07-14T10:09:20.393+00:00 Hi anonymous user
Yes, your understanding is correct. Once the deployment is completed it will prompt you to upload your setting. Alternatively, as you have mentioned you can upload it on the later point following the steps that you have mentioned : https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-vs-code?tabs=csharp#application-settings-in-azure
The local.settings.json is only intended to be used when developing on your local machine (stage or prod environment should be configured in Azure Functions' app settings). The function.json does not accept environment variables defined outside local.settings.json.
If you want to test against different environments from your local machine, you can create two sets of local.settings.json, say local.stage.settings.json an local.dev.settings.json.
And use a wrapper script to switch between different environment
#!/bin/sh if [ -f "local.settings.json" ]; then mv local.settings.json backup.json fi cp local.dev.settings.json local.settings.json func host start