Skip to content

Commit 8c289a3

Browse files
authored
Merge pull request #113167 from ggailey777/jeff
[functions] hostjson app setting config
2 parents 861d3c9 + a15eacd commit 8c289a3

File tree

4 files changed

+44
-15
lines changed

4 files changed

+44
-15
lines changed

articles/azure-functions/functions-app-settings.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ The connection string for Application Insights. Use `APPLICATIONINSIGHTS_CONNECT
3333

3434
In version 2.x and later versions of the Functions runtime, configures app behavior based on the runtime environment. This value is [read during initialization](https://github.com/Azure/azure-functions-host/blob/dev/src/WebJobs.Script.WebHost/Program.cs#L43). You can set `AZURE_FUNCTIONS_ENVIRONMENT` to any value, but [three values](/dotnet/api/microsoft.aspnetcore.hosting.environmentname) are supported: [Development](/dotnet/api/microsoft.aspnetcore.hosting.environmentname.development), [Staging](/dotnet/api/microsoft.aspnetcore.hosting.environmentname.staging), and [Production](/dotnet/api/microsoft.aspnetcore.hosting.environmentname.production). When `AZURE_FUNCTIONS_ENVIRONMENT` isn't set, it defaults to `Development` on a local environment and `Production` on Azure. This setting should be used instead of `ASPNETCORE_ENVIRONMENT` to set the runtime environment.
3535

36+
## AzureFunctionsJobHost__\*
37+
38+
In version 2.x and later versions of the Functions runtime, application settings can override [host.json](functions-host-json.md) settings in the current environment. These overrides are expressed as application settings named `AzureFunctionsJobHost__path__to__setting`. For more information, see [Override host.json values](functions-host-json.md#override-hostjson-values).
39+
3640
## AzureWebJobsDashboard
3741

3842
Optional storage account connection string for storing logs and displaying them in the **Monitor** tab in the portal. This setting is only valid for apps that target version 1.x of the Azure Functions runtime. The storage account must be a general-purpose one that supports blobs, queues, and tables. To learn more, see [Storage account requirements](storage-considerations.md#storage-account-requirements).

articles/azure-functions/functions-bindings-service-bus-output.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ The following table explains the binding configuration properties that you set i
283283
|**queueName**|**QueueName**|Name of the queue. Set only if sending queue messages, not for a topic.
284284
|**topicName**|**TopicName**|Name of the topic. Set only if sending topic messages, not for a queue.|
285285
|**connection**|**Connection**|The name of an app setting that contains the Service Bus connection string to use for this binding. If the app setting name begins with "AzureWebJobs", you can specify only the remainder of the name. For example, if you set `connection` to "MyServiceBus", the Functions runtime looks for an app setting that is named "AzureWebJobsMyServiceBus". If you leave `connection` empty, the Functions runtime uses the default Service Bus connection string in the app setting that is named "AzureWebJobsServiceBus".<br><br>To obtain a connection string, follow the steps shown at [Get the management credentials](../service-bus-messaging/service-bus-quickstart-portal.md#get-the-connection-string). The connection string must be for a Service Bus namespace, not limited to a specific queue or topic.|
286-
|**accessRights**|**Access**|Access rights for the connection string. Available values are `manage` and `listen`. The default is `manage`, which indicates that the `connection` has the **Manage** permission. If you use a connection string that does not have the **Manage** permission, set `accessRights` to "listen". Otherwise, the Functions runtime might fail trying to do operations that require manage rights. In Azure Functions version 2.x and higher, this property is not available because the latest version of the Service Bus SDK doesn't support manage operations.|
286+
|**accessRights** (v1 only)|**Access**|Access rights for the connection string. Available values are `manage` and `listen`. The default is `manage`, which indicates that the `connection` has the **Manage** permission. If you use a connection string that does not have the **Manage** permission, set `accessRights` to "listen". Otherwise, the Functions runtime might fail trying to do operations that require manage rights. In Azure Functions version 2.x and higher, this property is not available because the latest version of the Service Bus SDK doesn't support manage operations.|
287287

288288
[!INCLUDE [app settings to local.settings.json](../../includes/functions-app-settings-local.md)]
289289

@@ -362,9 +362,9 @@ This section describes the global configuration settings available for this bind
362362
"serviceBus": {
363363
"prefetchCount": 100,
364364
"messageHandlerOptions": {
365-
"autoComplete": false,
365+
"autoComplete": true,
366366
"maxConcurrentCalls": 32,
367-
"maxAutoRenewDuration": "00:55:00"
367+
"maxAutoRenewDuration": "00:05:00"
368368
},
369369
"sessionHandlerOptions": {
370370
"autoComplete": false,
@@ -376,13 +376,15 @@ This section describes the global configuration settings available for this bind
376376
}
377377
}
378378
```
379+
If you have `isSessionsEnabled` set to `true`, the `sessionHandlerOptions` will be honored. If you have `isSessionsEnabled` set to `false`, the `messageHandlerOptions` will be honored.
379380

380381
|Property |Default | Description |
381382
|---------|---------|---------|
382383
|prefetchCount|0|Gets or sets the number of messages that the message receiver can simultaneously request.|
383384
|maxAutoRenewDuration|00:05:00|The maximum duration within which the message lock will be renewed automatically.|
384-
|autoComplete|true|Whether the trigger should immediately mark the message as complete (autocomplete) or wait for function to exit successfully to call complete.|
385-
|maxConcurrentCalls|16|The maximum number of concurrent calls to the callback that the message pump should initiate. By default, the Functions runtime processes multiple messages concurrently. To direct the runtime to process only a single queue or topic message at a time, set `maxConcurrentCalls` to 1. |
385+
|autoComplete|true|Whether the trigger should automatically call complete after processing, or if the function code will manually call complete.|
386+
|maxConcurrentCalls|16|The maximum number of concurrent calls to the callback that the message pump should initiate per scaled instance. By default, the Functions runtime processes multiple messages concurrently.|
387+
|maxConcurrentSessions|2000|The maximum number of sessions that can be handled concurrently per scaled instance.|
386388

387389
## Next steps
388390

articles/azure-functions/functions-bindings-service-bus-trigger.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ ms.author: cshoe
1111

1212
# Azure Service Bus trigger for Azure Functions
1313

14-
Use the Service Bus trigger to respond to messages from a Service Bus queue or topic.
14+
Use the Service Bus trigger to respond to messages from a Service Bus queue or topic.
15+
Starting with extension version 3.1.0, you can trigger on a session-enabled queue or topic.
1516

1617
For information on setup and configuration details, see the [overview](functions-bindings-service-bus-output.md).
1718

@@ -219,7 +220,7 @@ In [C# class libraries](functions-dotnet-class-library.md), use the following at
219220
}
220221
```
221222

222-
You can set the `Connection` property to specify the name of an app setting that contains the Service Bus connection string to use, as shown in the following example:
223+
Since the `Connection` property isn't defined, Functions looks for an app setting named `AzureWebJobsServiceBus`, which is the default name for the Service Bus connection string. You can also set the `Connection` property to specify the name of an application setting that contains the Service Bus connection string to use, as shown in the following example:
223224

224225
```csharp
225226
[FunctionName("ServiceBusQueueTriggerCSharp")]
@@ -353,21 +354,24 @@ The `maxAutoRenewDuration` is configurable in *host.json*, which maps to [OnMess
353354
354355
## Message metadata
355356

356-
The Service Bus trigger provides several [metadata properties](./functions-bindings-expressions-patterns.md#trigger-metadata). These properties can be used as part of binding expressions in other bindings or as parameters in your code. These properties are members of the [BrokeredMessage](https://docs.microsoft.com/dotnet/api/microsoft.servicebus.messaging.brokeredmessage) class.
357+
The Service Bus trigger provides several [metadata properties](./functions-bindings-expressions-patterns.md#trigger-metadata). These properties can be used as part of binding expressions in other bindings or as parameters in your code. These properties are members of the [Message](/dotnet/api/microsoft.azure.servicebus.message?view=azure-dotnet) class.
357358

358359
|Property|Type|Description|
359360
|--------|----|-----------|
360-
|`DeliveryCount`|`Int32`|The number of deliveries.|
361+
|`ContentType`|`string`|A content type identifier utilized by the sender and receiver for application-specific logic.|
362+
|`CorrelationId`|`string`|The correlation ID.|
361363
|`DeadLetterSource`|`string`|The dead letter source.|
362-
|`ExpiresAtUtc`|`DateTime`|The expiration time in UTC.|
364+
|`DeliveryCount`|`Int32`|The number of deliveries.|
363365
|`EnqueuedTimeUtc`|`DateTime`|The enqueued time in UTC.|
366+
|`ExpiresAtUtc`|`DateTime`|The expiration time in UTC.|
367+
|`Label`|`string`|The application-specific label.|
364368
|`MessageId`|`string`|A user-defined value that Service Bus can use to identify duplicate messages, if enabled.|
365-
|`ContentType`|`string`|A content type identifier utilized by the sender and receiver for application-specific logic.|
369+
|`MessageReceiver`|`MessageReceiver`|Service Bus message receiver. Can be used to abandon, complete, or deadletter the message.|
370+
|`MessageSession`|`MessageSession`|A message receiver specifically for session-enabled queues and topics.|
366371
|`ReplyTo`|`string`|The reply to queue address.|
367-
|`SequenceNumber`|`Int64`|The unique number assigned to a message by the Service Bus.|
372+
|`SequenceNumber`|`long`|The unique number assigned to a message by the Service Bus.|
368373
|`To`|`string`|The send to address.|
369-
|`Label`|`string`|The application-specific label.|
370-
|`CorrelationId`|`string`|The correlation ID.|
374+
|`UserProperties`|`IDictionary<string, object>`|Properties set by the sender.|
371375

372376
See [code examples](#example) that use these properties earlier in this article.
373377

articles/azure-functions/functions-host-json.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: host.json reference for Azure Functions 2.x
33
description: Reference documentation for the Azure Functions host.json file with the v2 runtime.
44
ms.topic: conceptual
5-
ms.date: 01/06/2020
5+
ms.date: 04/28/2020
66
---
77

88
# host.json reference for Azure Functions 2.x and later
@@ -20,6 +20,8 @@ Other function app configuration options are managed in your [app settings](func
2020

2121
Configurations in host.json related to bindings are applied equally to each function in the function app.
2222

23+
You can also [override or apply settings per environment](#override-hostjson-values) using application settings.
24+
2325
## Sample host.json file
2426

2527
The following sample *host.json* file for version 2.x+ has all possible options specified (excluding any that are for internal use only).
@@ -384,6 +386,23 @@ A set of [shared code directories](functions-reference-csharp.md#watched-directo
384386
}
385387
```
386388

389+
## Override host.json values
390+
391+
There may be instances where you wish to configure or modify specific settings in a host.json file for a specific environment, without changing the host.json file itself. You can override specific host.json values be creating an equivalent value as an application setting. When the runtime finds an application setting in the format `AzureFunctionsJobHost__path__to__setting`, it overrides the equivalent host.json setting located at `path.to.setting` in the JSON. When expressed as an application setting, the dot (`.`) used to indicate JSON hierarchy is replaced by a double underscore (`__`).
392+
393+
For example, say that you wanted to disable Application Insight sampling when running locally. If you changed the local host.json file to disable Application Insights, this change might get pushed to your production app during deployment. The safer way to do this is to instead create an application setting as `"AzureFunctionsJobHost__logging__applicationInsights__samplingSettings__isEnabled":"false"` in the `local.settings.json` file. You can see this in the following `local.settings.json` file, which doesn't get published:
394+
395+
```json
396+
{
397+
"IsEncrypted": false,
398+
"Values": {
399+
"AzureWebJobsStorage": "{storage-account-connection-string}",
400+
"FUNCTIONS_WORKER_RUNTIME": "{language-runtime}",
401+
"AzureFunctionsJobHost__logging__applicationInsights__samplingSettings__isEnabled":"false"
402+
}
403+
}
404+
```
405+
387406
## Next steps
388407

389408
> [!div class="nextstepaction"]

0 commit comments

Comments
 (0)