Azure Functions- Publish local.settings.json

Viewed 3029

How Can I publish my Azure Function's local.settings.json?

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "CosmoDbAuthKey": "***********************************",
    "CosmoDbEndpoint": "https://**************************:443/",
    "CosmosDbId": "***Notifications"
  }
}
3 Answers

This answer is not condoning the practice of publishing the local.settings.json file, since it is intended to be used for local development and debugging only. Others have already emphasized that, but they are apparently mistaken that there is "no way to publish". There is indeed a method to publish it and it's specified in Microsoft's online docs:

By default, these settings are not migrated automatically when the project is published to Azure. Use the --publish-local-settings switch when you publish to make sure these settings are added to the function app in Azure. Note that values in ConnectionStrings are never published.

You cannot publish local.settings.json file to Azure. This file is for local development only.

To add settings for your deployed function:

  1. Go to https://portal.azure.com
  2. Navigate to your function app
  3. In the left hand side menu, look for Settings
  4. Select Configuration
  5. The default loaded tab should be Application Settings
  6. Select New application setting
  7. Add Name and Value. Name should be the same as your local.setting.json entry i.e. CosmosDbId. Value may change depending on your environment.

Azure function app portal

You cannot publish local.settings.json, what you need to do is to add them under the "Application settings" tab of the published function app in the Azure Portal

enter image description here

Related