Skip to content

Commit 7d0dfbd

Browse files
authored
Merge pull request #252499 from ggailey777/dotnet-tabs
[Functions] Swap order of .NET tabs (isolated for in-proc)
2 parents 78c0398 + c3cff4b commit 7d0dfbd

File tree

69 files changed

+2594
-2854
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2594
-2854
lines changed

articles/azure-functions/functions-add-output-binding-azure-sql-vs-code.md

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ Because you're using an Azure SQL output binding, you must have the correspondin
8989

9090
With the exception of HTTP and timer triggers, bindings are implemented as extension packages. Run the following [dotnet add package](/dotnet/core/tools/dotnet-add-package) command in the Terminal window to add the Azure SQL extension package to your project.
9191

92-
# [In-process](#tab/in-process)
92+
# [Isolated worker model](#tab/isolated-process)
9393
```bash
94-
dotnet add package Microsoft.Azure.WebJobs.Extensions.Sql
94+
dotnet add package Microsoft.Azure.Functions.Worker.Extensions.Sql
9595
```
96-
# [Isolated process](#tab/isolated-process)
96+
# [In-process model](#tab/in-process)
9797
```bash
98-
dotnet add package Microsoft.Azure.Functions.Worker.Extensions.Sql
98+
dotnet add package Microsoft.Azure.WebJobs.Extensions.Sql
9999
```
100100
---
101101
::: zone-end
@@ -131,14 +131,7 @@ Open the *HttpExample.cs* project file and add the following `ToDoItem` class, w
131131

132132
In a C# class library project, the bindings are defined as binding attributes on the function method. The *function.json* file required by Functions is then auto-generated based on these attributes.
133133

134-
# [In-process](#tab/in-process)
135-
Open the *HttpExample.cs* project file and add the following parameter to the `Run` method definition:
136-
137-
:::code language="csharp" source="~/functions-sql-todo-sample/PostToDo.cs" range="25":::
138-
139-
The `toDoItems` parameter is an `IAsyncCollector<ToDoItem>` type, which represents a collection of ToDo items that are written to your Azure SQL Database when the function completes. Specific attributes indicate the names of the database table (`dbo.ToDo`) and the connection string for your Azure SQL Database (`SqlConnectionString`).
140-
141-
# [Isolated process](#tab/isolated-process)
134+
# [Isolated worker model](#tab/isolated-process)
142135

143136
Open the *HttpExample.cs* project file and add the following output type class, which defines the combined objects that will be output from our function for both the HTTP response and the SQL output:
144137

@@ -157,6 +150,13 @@ Add a using statement to the `Microsoft.Azure.Functions.Worker.Extensions.Sql` l
157150
using Microsoft.Azure.Functions.Worker.Extensions.Sql;
158151
```
159152

153+
# [In-process model](#tab/in-process)
154+
Open the *HttpExample.cs* project file and add the following parameter to the `Run` method definition:
155+
156+
:::code language="csharp" source="~/functions-sql-todo-sample/PostToDo.cs" range="25":::
157+
158+
The `toDoItems` parameter is an `IAsyncCollector<ToDoItem>` type, which represents a collection of ToDo items that are written to your Azure SQL Database when the function completes. Specific attributes indicate the names of the database table (`dbo.ToDo`) and the connection string for your Azure SQL Database (`SqlConnectionString`).
159+
160160
---
161161

162162
::: zone-end
@@ -247,7 +247,40 @@ In this code, `arg_name` identifies the binding parameter referenced in your cod
247247

248248
::: zone pivot="programming-language-csharp"
249249

250-
# [In-process](#tab/in-process)
250+
# [Isolated worker model](#tab/isolated-process)
251+
252+
Replace the existing Run method with the following code:
253+
254+
```cs
255+
[Function("HttpExample")]
256+
public static OutputType Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req,
257+
FunctionContext executionContext)
258+
{
259+
var logger = executionContext.GetLogger("HttpExample");
260+
logger.LogInformation("C# HTTP trigger function processed a request.");
261+
262+
var message = "Welcome to Azure Functions!";
263+
264+
var response = req.CreateResponse(HttpStatusCode.OK);
265+
response.Headers.Add("Content-Type", "text/plain; charset=utf-8");
266+
response.WriteString(message);
267+
268+
// Return a response to both HTTP trigger and Azure SQL output binding.
269+
return new OutputType()
270+
{
271+
ToDoItem = new ToDoItem
272+
{
273+
id = System.Guid.NewGuid().ToString(),
274+
title = message,
275+
completed = false,
276+
url = ""
277+
},
278+
HttpResponse = response
279+
};
280+
}
281+
```
282+
283+
# [In-process model](#tab/in-process)
251284

252285
Add code that uses the `toDoItems` output binding object to create a new `ToDoItem`. Add this code before the method returns.
253286

@@ -304,39 +337,6 @@ public static async Task<IActionResult> Run(
304337
}
305338
```
306339

307-
# [Isolated process](#tab/isolated-process)
308-
309-
Replace the existing Run method with the following code:
310-
311-
```cs
312-
[Function("HttpExample")]
313-
public static OutputType Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req,
314-
FunctionContext executionContext)
315-
{
316-
var logger = executionContext.GetLogger("HttpExample");
317-
logger.LogInformation("C# HTTP trigger function processed a request.");
318-
319-
var message = "Welcome to Azure Functions!";
320-
321-
var response = req.CreateResponse(HttpStatusCode.OK);
322-
response.Headers.Add("Content-Type", "text/plain; charset=utf-8");
323-
response.WriteString(message);
324-
325-
// Return a response to both HTTP trigger and Azure SQL output binding.
326-
return new OutputType()
327-
{
328-
ToDoItem = new ToDoItem
329-
{
330-
id = System.Guid.NewGuid().ToString(),
331-
title = message,
332-
completed = false,
333-
url = ""
334-
},
335-
HttpResponse = response
336-
};
337-
}
338-
```
339-
340340
---
341341

342342
::: zone-end

articles/azure-functions/functions-add-output-binding-cosmos-db-vs-code.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ Because you're using an Azure Cosmos DB output binding, you must have the corres
9494

9595
Except for HTTP and timer triggers, bindings are implemented as extension packages. Run the following [dotnet add package](/dotnet/core/tools/dotnet-add-package) command in the Terminal window to add the Azure Cosmos DB extension package to your project.
9696

97-
# [In-process](#tab/in-process)
97+
# [Isolated worker model](#tab/isolated-process)
9898
```command
99-
dotnet add package Microsoft.Azure.WebJobs.Extensions.CosmosDB --version 3.0.10
99+
dotnet add package Microsoft.Azure.Functions.Worker.Extensions.CosmosDB --version 3.0.9
100100
```
101-
# [Isolated process](#tab/isolated-process)
101+
# [In-process model](#tab/in-process)
102102
```command
103-
dotnet add package Microsoft.Azure.Functions.Worker.Extensions.CosmosDB --version 3.0.9
103+
dotnet add package Microsoft.Azure.WebJobs.Extensions.CosmosDB --version 3.0.10
104104
```
105105
---
106106
::: zone-end
@@ -121,14 +121,7 @@ Now, you can add the Azure Cosmos DB output binding to your project.
121121
::: zone pivot="programming-language-csharp"
122122
In a C# class library project, the bindings are defined as binding attributes on the function method.
123123

124-
# [In-process](#tab/in-process)
125-
Open the *HttpExample.cs* project file and add the following parameter to the `Run` method definition:
126-
127-
:::code language="csharp" source="~/functions-docs-csharp/functions-add-output-binding-cosmos-db/HttpExample.cs" range="18-20":::
128-
129-
The `documentsOut` parameter is an `IAsyncCollector<T>` type, which represents a collection of JSON documents that are written to your Azure Cosmos DB container when the function completes. Specific attributes indicate the names of the container and its parent database. The connection string for your Azure Cosmos DB account is set by the `ConnectionStringSettingAttribute`.
130-
131-
# [Isolated process](#tab/isolated-process)
124+
# [Isolated worker model](#tab/isolated-process)
132125

133126
Open the *HttpExample.cs* project file and add the following classes:
134127

@@ -138,6 +131,13 @@ The `MyDocument` class defines an object that gets written to the database. The
138131

139132
The `MultiResponse` class allows you to both write to the specified collection in the Azure Cosmos DB and return an HTTP success message. Because you need to return a `MultiResponse` object, you need to also update the method signature.
140133

134+
# [In-process model](#tab/in-process)
135+
Open the *HttpExample.cs* project file and add the following parameter to the `Run` method definition:
136+
137+
:::code language="csharp" source="~/functions-docs-csharp/functions-add-output-binding-cosmos-db/HttpExample.cs" range="18-20":::
138+
139+
The `documentsOut` parameter is an `IAsyncCollector<T>` type, which represents a collection of JSON documents that are written to your Azure Cosmos DB container when the function completes. Specific attributes indicate the names of the container and its parent database. The connection string for your Azure Cosmos DB account is set by the `ConnectionStringSettingAttribute`.
140+
141141
---
142142

143143
Specific attributes specify the name of the container and the name of its parent database. The connection string for your Azure Cosmos DB account is set by the `CosmosDbConnectionString`.
@@ -233,7 +233,13 @@ In this code, `arg_name` identifies the binding parameter referenced in your cod
233233

234234
::: zone pivot="programming-language-csharp"
235235

236-
# [In-process](#tab/in-process)
236+
# [Isolated worker model](#tab/isolated-process)
237+
238+
Replace the existing Run method with the following code:
239+
240+
:::code language="csharp" source="~/functions-docs-csharp/functions-add-output-binding-cosmos-db-isolated/HttpExample.cs" range="11-34":::
241+
242+
# [In-process model](#tab/in-process)
237243

238244
Add code that uses the `documentsOut` output binding object to create a JSON document. Add this code before the method returns.
239245

@@ -289,12 +295,6 @@ public static async Task<IActionResult> Run(
289295
}
290296
```
291297

292-
# [Isolated process](#tab/isolated-process)
293-
294-
Replace the existing Run method with the following code:
295-
296-
:::code language="csharp" source="~/functions-docs-csharp/functions-add-output-binding-cosmos-db-isolated/HttpExample.cs" range="11-34":::
297-
298298
---
299299

300300
::: zone-end

articles/azure-functions/functions-add-output-binding-storage-queue-vs.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ Because you're using a Queue storage output binding, you need the Storage bindin
4646

4747
1. In the console, run the following [Install-Package](/nuget/tools/ps-ref-install-package) command to install the Storage extensions:
4848

49-
# [In-process](#tab/in-process)
49+
# [Isolated worker model](#tab/isolated-process)
5050
```bash
51-
Install-Package Microsoft.Azure.WebJobs.Extensions.Storage
51+
Install-Package /dotnet/api/microsoft.azure.webjobs.blobattribute.Queues -IncludePrerelease
5252
```
53-
# [Isolated process](#tab/isolated-process)
53+
# [In-process model](#tab/in-process)
5454
```bash
55-
Install-Package /dotnet/api/microsoft.azure.webjobs.blobattribute.Queues -IncludePrerelease
55+
Install-Package Microsoft.Azure.WebJobs.Extensions.Storage
5656
```
5757
---
5858

articles/azure-functions/functions-bindings-azure-data-explorer-input.md

Lines changed: 75 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,81 @@ The Azure Data Explorer input binding retrieves data from a database.
2020

2121
[!INCLUDE [functions-bindings-csharp-intro-with-csx](../../includes/functions-bindings-csharp-intro-with-csx.md)]
2222

23-
# [In-process](#tab/in-process)
23+
# [Isolated worker model](#tab/isolated-process)
24+
25+
More samples for the Azure Data Explorer input binding (out of process) are available in the [GitHub repository](https://github.com/Azure/Webjobs.Extensions.Kusto/tree/main/samples/samples-outofproc).
26+
27+
This section contains the following examples:
28+
29+
* [HTTP trigger, get row by ID from query string](#http-trigger-look-up-id-from-query-string-c-oop)
30+
* [HTTP trigger, get multiple rows from route data](#http-trigger-get-multiple-items-from-route-data-c-oop)
31+
32+
The examples refer to a `Product` class and the Products table, both of which are defined in the previous sections.
33+
34+
<a id="http-trigger-look-up-id-from-query-string-c-oop"></a>
35+
36+
### HTTP trigger, get row by ID from query string
37+
38+
The following example shows a [C# function](functions-dotnet-class-library.md) that retrieves a single record. The function is triggered by an HTTP request that uses a query string to specify the ID. That ID is used to retrieve a `Product` record with the specified query.
39+
40+
> [!NOTE]
41+
> The HTTP query string parameter is case sensitive.
42+
>
43+
44+
```cs
45+
using System.Text.Json.Nodes;
46+
using Microsoft.Azure.Functions.Worker;
47+
using Microsoft.Azure.Functions.Worker.Extensions.Kusto;
48+
using Microsoft.Azure.Functions.Worker.Http;
49+
using Microsoft.Azure.WebJobs.Extensions.Kusto.SamplesOutOfProc.OutputBindingSamples.Common;
50+
51+
namespace Microsoft.Azure.WebJobs.Extensions.Kusto.SamplesOutOfProc.InputBindingSamples
52+
{
53+
public static class GetProductsQuery
54+
{
55+
[Function("GetProductsQuery")]
56+
public static JsonArray Run(
57+
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "getproductsquery")] HttpRequestData req,
58+
[KustoInput(Database: "productsdb",
59+
KqlCommand = "declare query_parameters (productId:long);Products | where ProductID == productId",
60+
KqlParameters = "@productId={Query.productId}",Connection = "KustoConnectionString")] JsonArray products)
61+
{
62+
return products;
63+
}
64+
}
65+
}
66+
```
67+
68+
<a id="http-trigger-get-multiple-items-from-route-data-c-oop"></a>
69+
70+
### HTTP trigger, get multiple rows from route parameter
71+
72+
The following example shows a [C# function](functions-dotnet-class-library.md) that retrieves records returned by the query (based on the name of the product, in this case). The function is triggered by an HTTP request that uses route data to specify the value of a query parameter. That parameter is used to filter the `Product` records in the specified query.
73+
74+
```cs
75+
using Microsoft.Azure.Functions.Worker;
76+
using Microsoft.Azure.Functions.Worker.Extensions.Kusto;
77+
using Microsoft.Azure.Functions.Worker.Http;
78+
using Microsoft.Azure.WebJobs.Extensions.Kusto.SamplesOutOfProc.OutputBindingSamples.Common;
79+
80+
namespace Microsoft.Azure.WebJobs.Extensions.Kusto.SamplesOutOfProc.InputBindingSamples
81+
{
82+
public static class GetProductsFunction
83+
{
84+
[Function("GetProductsFunction")]
85+
public static IEnumerable<Product> Run(
86+
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "getproductsfn/{name}")] HttpRequestData req,
87+
[KustoInput(Database: "productsdb",
88+
KqlCommand = "declare query_parameters (name:string);GetProductsByName(name)",
89+
KqlParameters = "@name={name}",Connection = "KustoConnectionString")] IEnumerable<Product> products)
90+
{
91+
return products;
92+
}
93+
}
94+
}
95+
```
96+
97+
# [In-process model](#tab/in-process)
2498

2599
More samples for the Azure Data Explorer input binding are available in the [GitHub repository](https://github.com/Azure/Webjobs.Extensions.Kusto/blob/main/samples/samples-csharp).
26100

@@ -135,84 +209,6 @@ namespace Microsoft.Azure.WebJobs.Extensions.Kusto.Samples.InputBindingSamples
135209
}
136210
```
137211

138-
# [Isolated process](#tab/isolated-process)
139-
140-
More samples for the Azure Data Explorer input binding (out of process) are available in the [GitHub repository](https://github.com/Azure/Webjobs.Extensions.Kusto/tree/main/samples/samples-outofproc).
141-
142-
This section contains the following examples:
143-
144-
* [HTTP trigger, get row by ID from query string](#http-trigger-look-up-id-from-query-string-c-oop)
145-
* [HTTP trigger, get multiple rows from route data](#http-trigger-get-multiple-items-from-route-data-c-oop)
146-
147-
The examples refer to a `Product` class and the Products table, both of which are defined in the previous sections.
148-
149-
<a id="http-trigger-look-up-id-from-query-string-c-oop"></a>
150-
151-
### HTTP trigger, get row by ID from query string
152-
153-
The following example shows a [C# function](functions-dotnet-class-library.md) that retrieves a single record. The function is triggered by an HTTP request that uses a query string to specify the ID. That ID is used to retrieve a `Product` record with the specified query.
154-
155-
> [!NOTE]
156-
> The HTTP query string parameter is case sensitive.
157-
>
158-
159-
```cs
160-
using System.Text.Json.Nodes;
161-
using Microsoft.Azure.Functions.Worker;
162-
using Microsoft.Azure.Functions.Worker.Extensions.Kusto;
163-
using Microsoft.Azure.Functions.Worker.Http;
164-
using Microsoft.Azure.WebJobs.Extensions.Kusto.SamplesOutOfProc.OutputBindingSamples.Common;
165-
166-
namespace Microsoft.Azure.WebJobs.Extensions.Kusto.SamplesOutOfProc.InputBindingSamples
167-
{
168-
public static class GetProductsQuery
169-
{
170-
[Function("GetProductsQuery")]
171-
public static JsonArray Run(
172-
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "getproductsquery")] HttpRequestData req,
173-
[KustoInput(Database: "productsdb",
174-
KqlCommand = "declare query_parameters (productId:long);Products | where ProductID == productId",
175-
KqlParameters = "@productId={Query.productId}",Connection = "KustoConnectionString")] JsonArray products)
176-
{
177-
return products;
178-
}
179-
}
180-
}
181-
```
182-
183-
<a id="http-trigger-get-multiple-items-from-route-data-c-oop"></a>
184-
185-
### HTTP trigger, get multiple rows from route parameter
186-
187-
The following example shows a [C# function](functions-dotnet-class-library.md) that retrieves records returned by the query (based on the name of the product, in this case). The function is triggered by an HTTP request that uses route data to specify the value of a query parameter. That parameter is used to filter the `Product` records in the specified query.
188-
189-
```cs
190-
using Microsoft.Azure.Functions.Worker;
191-
using Microsoft.Azure.Functions.Worker.Extensions.Kusto;
192-
using Microsoft.Azure.Functions.Worker.Http;
193-
using Microsoft.Azure.WebJobs.Extensions.Kusto.SamplesOutOfProc.OutputBindingSamples.Common;
194-
195-
namespace Microsoft.Azure.WebJobs.Extensions.Kusto.SamplesOutOfProc.InputBindingSamples
196-
{
197-
public static class GetProductsFunction
198-
{
199-
[Function("GetProductsFunction")]
200-
public static IEnumerable<Product> Run(
201-
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "getproductsfn/{name}")] HttpRequestData req,
202-
[KustoInput(Database: "productsdb",
203-
KqlCommand = "declare query_parameters (name:string);GetProductsByName(name)",
204-
KqlParameters = "@name={name}",Connection = "KustoConnectionString")] IEnumerable<Product> products)
205-
{
206-
return products;
207-
}
208-
}
209-
}
210-
```
211-
212-
<!-- Uncomment to support C# script examples.
213-
# [C# Script](#tab/csharp-script)
214-
215-
-->
216212
---
217213

218214
::: zone-end

0 commit comments

Comments
 (0)