You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-dotnet-class-library.md
+18-25Lines changed: 18 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,12 +90,12 @@ Version 4.x of the Functions runtime provides equivalent functionality for .NET
90
90
91
91
In Visual Studio, the **Azure Functions** project template creates a C# class library project that contains the following files:
92
92
93
-
*[host.json](functions-host-json.md) - stores configuration settings that affect all functions in the project when running locally or in Azure.
94
-
*[local.settings.json](functions-develop-local.md#local-settings-file) - stores app settings and connection strings that are used when running locally. This file contains secrets and isn't published to your function app in Azure. Instead, [add app settings to your function app](functions-develop-vs.md#function-app-settings).
93
+
-[host.json](functions-host-json.md) - stores configuration settings that affect all functions in the project when running locally or in Azure.
94
+
-[local.settings.json](functions-develop-local.md#local-settings-file) - stores app settings and connection strings that are used when running locally. This file contains secrets and isn't published to your function app in Azure. Instead, [add app settings to your function app](functions-develop-vs.md#function-app-settings).
95
95
96
96
When you build the project, a folder structure that looks like the following example is generated in the build output directory:
97
97
98
-
```
98
+
```text
99
99
<framework.version>
100
100
| - bin
101
101
| - MyFirstFunction
@@ -110,7 +110,6 @@ This directory is what gets deployed to your function app in Azure. The binding
110
110
> [!IMPORTANT]
111
111
> The build process creates a *function.json* file for each function. This *function.json* file isn't 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](disable-function.md).
112
112
113
-
114
113
## Methods recognized as functions
115
114
116
115
In a class library, a function is a method with a `FunctionName` and a trigger attribute, as shown in the following example:
@@ -136,16 +135,16 @@ The trigger attribute specifies the trigger type and binds input data to a metho
136
135
137
136
The method signature might contain parameters other than the one used with the trigger attribute. Here are some of the other parameters that you can include:
138
137
139
-
*[Input and output bindings](functions-triggers-bindings.md) marked as such by decorating them with attributes.
140
-
* An `ILogger` or `TraceWriter` ([version 1.x-only](functions-versions.md#creating-1x-apps)) parameter for [logging](#logging).
141
-
* A `CancellationToken` parameter for [graceful shutdown](#cancellation-tokens).
142
-
*[Binding expressions](./functions-bindings-expressions-patterns.md) parameters to get trigger metadata.
138
+
-[Input and output bindings](functions-triggers-bindings.md) marked as such by decorating them with attributes.
139
+
- An `ILogger` or `TraceWriter` ([version 1.x-only](functions-versions.md#creating-1x-apps)) parameter for [logging](#logging).
140
+
- A `CancellationToken` parameter for [graceful shutdown](#cancellation-tokens).
141
+
-[Binding expressions](./functions-bindings-expressions-patterns.md) parameters to get trigger metadata.
143
142
144
143
The order of parameters in the function signature doesn't matter. For example, you can put trigger parameters before or after other bindings, and you can put the logger parameter before or after trigger or binding parameters.
145
144
146
145
### Output bindings
147
146
148
-
A function can have zero or multiple output bindings defined by using output parameters.
147
+
A function can have zero or multiple output bindings defined by using output parameters.
149
148
150
149
The following example modifies the preceding one by adding an output queue binding named `myQueueItemCopy`. The function writes the contents of the message that triggers the function to a new message in a different queue.
151
150
@@ -189,7 +188,7 @@ public static class BindingExpressionsExample
189
188
190
189
## Autogenerated function.json
191
190
192
-
The build process creates a *function.json* file in a function folder in the build folder. As noted earlier, this file isn't meant to be edited directly. You can't change binding configuration or disable the function by editing this file.
191
+
The build process creates a *function.json* file in a function folder in the build folder. As noted earlier, this file isn't meant to be edited directly. You can't change binding configuration or disable the function by editing this file.
193
192
194
193
The purpose of this file is to provide information to the scale controller to use for [scaling decisions on the Consumption plan](event-driven-scaling.md). For this reason, the file only has trigger info, not input/output bindings.
195
194
@@ -214,7 +213,7 @@ The generated *function.json* file includes a `configurationSource` property tha
214
213
215
214
## Microsoft.NET.Sdk.Functions
216
215
217
-
The *function.json* file generation is performed by the NuGet package [Microsoft\.NET\.Sdk\.Functions](https://www.nuget.org/packages/Microsoft.NET.Sdk.Functions).
216
+
The *function.json* file generation is performed by the NuGet package [Microsoft\.NET\.Sdk\.Functions](https://www.nuget.org/packages/Microsoft.NET.Sdk.Functions).
218
217
219
218
The following example shows the relevant parts of the `.csproj` files that have different target frameworks of the same `Sdk` package:
220
219
@@ -245,7 +244,6 @@ The following example shows the relevant parts of the `.csproj` files that have
245
244
```
246
245
---
247
246
248
-
249
247
Among the `Sdk` package dependencies are triggers and bindings. A 1.x project refers to 1.x triggers and bindings because those triggers and bindings target the .NET Framework, while 4.x triggers and bindings target .NET Core.
250
248
251
249
The `Sdk` package also depends on [Newtonsoft.Json](https://www.nuget.org/packages/Newtonsoft.Json), and indirectly on [WindowsAzure.Storage](https://www.nuget.org/packages/WindowsAzure.Storage). These dependencies make sure that your project uses the versions of those packages that work with the Functions runtime version that the project targets. For example, `Newtonsoft.Json` has version 11 for .NET Framework 4.6.1, but the Functions runtime that targets .NET Framework 4.6.1 is only compatible with `Newtonsoft.Json` 9.0.1. So your function code in that project also has to use `Newtonsoft.Json` 9.0.1.
@@ -292,7 +290,7 @@ Each binding has its own supported types; for instance, a blob trigger attribute
292
290
293
291
## Binding to method return value
294
292
295
-
You can use a method return value for an output binding, by applying the attribute to the method return value. For examples, see [Triggers and bindings](./functions-triggers-bindings.md).
293
+
You can use a method return value for an output binding, by applying the attribute to the method return value. For examples, see [Triggers and bindings](./functions-triggers-bindings.md).
296
294
297
295
Use the return value only if a successful function execution always results in a return value to pass to the output binding. Otherwise, use `ICollector` or `IAsyncCollector`, as shown in the following section.
[BlobAttribute](https://github.com/Azure/azure-webjobs-sdk/blob/master/src/Microsoft.Azure.WebJobs.Extensions.Storage/Blobs/BlobAttribute.cs) defines the [Storage blob](functions-bindings-storage-blob.md) input or output binding, and [TextWriter](/dotnet/api/system.io.textwriter) is a supported output binding type.
andpassingtheattributearrayinto `BindAsync<T>()`. Usea `Binder` parameter, not `IBinder`. Forexample:
699
+
Theprecedingexamplegetstheappsettingforthefunctionapp's main Storage account connection string (which is `AzureWebJobsStorage`). You can specify a custom app setting to use for the Storage account by adding the [StorageAccountAttribute](https://github.com/Azure/azure-webjobs-sdk/blob/master/src/Microsoft.Azure.WebJobs/StorageAccountAttribute.cs) and passing the attribute array into `BindAsync<T>()`. Use a `Binder` parameter, not `IBinder`. For example:
707
700
708
701
```cs
709
702
publicstaticclassIBinderExampleMultipleAttributes
@@ -728,7 +721,7 @@ public static class IBinderExampleMultipleAttributes
0 commit comments