Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure functions - function.json where is it located?

I can see all over the net that bindings are configured in the function.json file. I have created a Azure Function project in Visual Studio, and I can see the file is generated in the out folder. But it is not part of my project. Is the idea, that you add it to your local.settings.json file, and then visual studio takes it from there to generate the file (including the deployment)? Or where should I add the bindings? Seems kind of strange, I would expect the local.settings.json to be a file that dosent get deployed to Azure.

like image 488
Thomas Segato Avatar asked Feb 08 '19 14:02

Thomas Segato


People also ask

Where are Azure functions stored?

[! IMPORTANT] When using the Consumption/Premium hosting plan, your function code and binding configuration files are stored in Azure Files in the main storage account.

Where are Azure functions deployed?

In Azure, you can run your functions directly from a deployment package file in your function app. The other option is to deploy your files in the d:\home\site\wwwroot (Windows) or /home/site/wwwroot (Linux) directory of your function app. This article describes the benefits of running your functions from a package.

Where is Azure_functions_environment set?

AZURE_FUNCTIONS_ENVIRONMENT is set to Development locally by the functions host/runtime. It is not automatically set in azure to Production . One can set this in App Settings in azure. ASPNETCORE_ENVIRONMENT is not set by the functions host/runtime either locally or in Azure.


1 Answers

If you're using compiled C# class library functions, the build process creates function.json (look in the bin directory)

See here: https://docs.microsoft.com/en-us/azure/azure-functions/functions-dotnet-class-library#functions-class-library-project

The build process creates a function.json file for each function. This function.json file is not meant to be edited directly. You can't change binding configuration or disable the function by editing this file. To learn how to disable a function, see How to disable functions.

Bindings are configured using attributes (see here)

[FunctionName("ServiceBusQueueTriggerCSharp")]                    
public static void Run(
    [ServiceBusTrigger("myqueue", AccessRights.Manage, Connection = "ServiceBusConnection")] 
    string myQueueItem,
    Int32 deliveryCount,
    DateTime enqueuedTimeUtc,
    string messageId,

    [Blob("sample-images-md/{name}", FileAccess.Write, Connection = "StorageConnectionAppSetting")] Stream outputBlob)

    ILogger log)
{
    log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
    log.LogInformation($"EnqueuedTimeUtc={enqueuedTimeUtc}");
    log.LogInformation($"DeliveryCount={deliveryCount}");
    log.LogInformation($"MessageId={messageId}");

    //now store something to outputBlob
}

StorageConnectionAppSetting is defined in config. For local, that's local.settings.json

like image 159
Alex Avatar answered Oct 11 '22 08:10

Alex