-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Samples] Updated the exception handling middleware sample to handle …
…multiple output binding case (#1071) * Update exception handling middleware sample to handle multiple output binding case * Update SDK package to latest stable * Add line break
- Loading branch information
Showing
4 changed files
with
70 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
samples/CustomMiddleware/HttpTriggerWithMultipleOutputBindings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Net; | ||
using Microsoft.Azure.Functions.Worker; | ||
using Microsoft.Azure.Functions.Worker.Http; | ||
|
||
namespace CustomMiddleware | ||
{ | ||
public static class HttpTriggerWithMultipleOutputBindings | ||
{ | ||
[Function(nameof(HttpTriggerWithMultipleOutputBindings))] | ||
public static MyOutputType Run([HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequestData req) | ||
{ | ||
if (req.Url.Query.Contains("throw-exception")) | ||
{ | ||
throw new Exception("App code failed"); | ||
} | ||
|
||
var response = req.CreateResponse(HttpStatusCode.OK); | ||
response.WriteString("Success!"); | ||
|
||
return new MyOutputType() | ||
{ | ||
Name = "Azure Functions", | ||
HttpResponse = response | ||
}; | ||
} | ||
} | ||
|
||
public class MyOutputType | ||
{ | ||
[QueueOutput("functionstesting2", Connection = "AzureWebJobsStorage")] | ||
public string Name { get; set; } | ||
|
||
public HttpResponseData HttpResponse { get; set; } | ||
} | ||
} |