local.settings.json
:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "node",
"WEBSITE_RUN_FROM_PACKAGE": 1,
"SCM_DO_BUILD_DURING_DEPLOYMENT": true
}
}
However, after successfully executing:
$ npm run-script build && zip -r azure_function.zip . && az functionapp deployment source config-zip -g acmeapp -n acmefunction2 --src azure_function.zip
...
Getting scm site credentials for zip deployment
Starting zip deployment. This operation can take a while to complete ...
Deployment endpoint responded with status code 202
{
"active": true,
"author": "N/A",
"author_email": "N/A",
"complete": true,
"deployer": "Push-Deployer",
"end_time": "2023-08-08T16:22:50.8690074Z",
"id": "3cba98a7-a231-45b8-847a-f0222e38731c",
"is_readonly": true,
"is_temp": false,
"last_success_end_time": "2023-08-08T16:22:50.8690074Z",
"log_url": "https://acmefunction2.scm.azurewebsites.net/api/deployments/latest/log",
"message": "Created via a push deployment",
"progress": "",
"received_time": "2023-08-08T16:21:36.1656327Z",
"site_name": "acmefunction2",
"start_time": "2023-08-08T16:21:38.0518534Z",
"status": 4,
"status_text": "",
"url": "https://acmefunction2.scm.azurewebsites.net/api/deployments/latest"
}
The function is deployed to Azure function app.
But in Settings | Configuration | Application settings
:
As you can see:
FUNCTIONS_WORKER_RUNTIME
is set to "node", which is as expected.
WEBSITE_RUN_FROM_PACKAGE
is set to 0, why not 1?
SCM_DO_BUILD_DURING_DEPLOYMENT
is set to false
, why?
2
Answers
Read this doc: https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=linux%2Cportal%2Cv2%2Cbash&pivots=programming-language-typescript#project-file-deployment
Use the
-publish-local-settings
option to automatically create app settings in your function app based on values in the local.settings.json file.In Azure Functions,
local.settings.json
file is meant for local development and isn’t directly used when you deploy the function to Azure. Instead, the settings inlocal.settings.json
need to be manually applied to the Application Settings in the Azure portal or through command-line tools like the Azure CLI. This separation ensures that developers can have local settings that don’t necessarily override the production settings.To ensure your settings in
local.settings.json
are reflected in the Azure Function App, you can use the Azure CLI to set them: