Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
bbeba63
Implement SDK-binding tables converter (#1506)
aishwaryabh May 25, 2023
5230add
Refactor Tables converter & update tests (#1716, #1723, #1727)
liliankasem Jul 7, 2023
9240f02
Update Tables converters to use IOptionsMonitor (#1776)
liliankasem Aug 11, 2023
79779b6
Prepare Tables extension for release (#1776)
liliankasem Jul 21, 2023
0b92d75
remove prerelease flag from readme instructions
mattchenderson Aug 16, 2023
e1148b2
Cleanup extension samples and reset release notes (#1814)
liliankasem Aug 16, 2023
38e2712
Adding support for blob trigger event sources (Event Grid support)
fabiocav Aug 17, 2023
86f8186
Adding "global::" namespace prefix to avoid namespace conflict inside…
kshyju Aug 23, 2023
ddfdc35
Adding connection property to event grid output attribute (#1835)
aishwaryabh Aug 23, 2023
9917849
BugFix-FunctionMetadataProvider emits incorrect binding name property…
kshyju Aug 23, 2023
e1862bf
Bumping up versions for SDK and SDK.Generators. (#1857)
kshyju Aug 24, 2023
7099e74
Reset worker.sdk release notes. (#1858)
kshyju Aug 24, 2023
20a5a6f
Updating ServiceBus and EventHub extensions for release (#1859)
liliankasem Aug 24, 2023
16748f2
Replace RPC worker startup with explicit call (#1860)
jviau Aug 28, 2023
c1ee4a0
Updating ASP.NET Core integration version for release
fabiocav Aug 29, 2023
170945f
App builder extension method to register extension options (#1843)
liliankasem Aug 29, 2023
790ebfd
Update blob extension WebJobs version (#1867)
liliankasem Aug 29, 2023
ce04c27
Update extension WebJob versions in tests & exclude Worker.Extensions…
liliankasem Aug 30, 2023
b4e4ba8
[Source Gen] Parse named args by type correctly (#1877)
satvu Aug 31, 2023
cd7d102
Reset and update extension release notes (#1885)
liliankasem Sep 7, 2023
479fc30
Adding optional parameter support (#1868)
kshyju Sep 8, 2023
cde6da4
Update E2E test app to Net7 (#1894)
surgupta-msft Sep 11, 2023
508636e
Fixing context binding extension methods
fabiocav Sep 1, 2023
b2b5d47
[Source Gen] Add diagnostic logs for errors when parsing attribute ar…
satvu Sep 12, 2023
762d8e4
Updating FunctionsNetHost to handle the new "functions-" prefix cmdli…
kshyju Sep 13, 2023
f406711
Handle new command line arguments with "functions-" prefix (#1897)
kshyju Sep 15, 2023
fec76f4
[Source Gen] Refactor to walk dependent assemblies (#1896)
satvu Sep 18, 2023
b5f074b
Prepare for Extensions.Rpc 1.0.0 release (#1913)
jviau Sep 19, 2023
145fefd
Update extensions-variables.yml to allow tags for release (#1918)
liliankasem Sep 20, 2023
40d73ee
Setup E2E test app for Net Framework (#1905)
surgupta-msft Sep 21, 2023
fe02835
Updating inner build target TFM when running on V4
fabiocav Sep 26, 2023
8cf9990
Use project namespace for generated code (#1930)
kshyju Sep 27, 2023
4e59409
Update Cosmos WebJobs extension to v4.4.0 & release prep (#1923)
liliankasem Sep 27, 2023
b3cbf89
Update Sdk.Generators.csproj for release
fabiocav Sep 27, 2023
643ef77
Publish 1.0.0 version of FunctionsNetHost (#1922)
kshyju Sep 28, 2023
9492b21
[Docs] Add doc snippet tags for safer references from Learn (#1936)
ggailey777 Sep 28, 2023
52c030e
Merge branch 'main' into jviau/merge-main
jviau Oct 3, 2023
b9c2d6a
Merge branch 'feature/ext-proj' into jviau/merge-main
jviau Oct 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions DotNetWorker.sln
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Worker.Extensions.Tables",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Worker.Extensions.Shared", "extensions\Worker.Extensions.Shared\Worker.Extensions.Shared.csproj", "{277D77B9-8915-41E3-8763-0B66328ADDDA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkerBindingSamples", "samples\WorkerBindingSamples\WorkerBindingSamples.csproj", "{901DA3C3-3ABA-4859-89D3-63343ED2A0AC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Worker.Extensions.Rpc", "extensions\Worker.Extensions.Rpc\src\Worker.Extensions.Rpc.csproj", "{93B64F12-EBDD-46CE-B4FB-0904701F0032}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions", "{AA4D318D-101B-49E7-A4EC-B34165AEDB33}"
Expand All @@ -135,6 +133,7 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetIntegration", "samples\AspNetIntegration\AspNetIntegration.csproj", "{D2F67410-9933-42E8-B04A-E17634D83A30}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Net7Worker", "samples\Net7Worker\Net7Worker.csproj", "{EC1A321B-70F6-420B-85D4-56C7869BB71B}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DependentAssemblyWithFunctions", "test\DependentAssemblyWithFunctions\DependentAssemblyWithFunctions.csproj", "{AB6E1E7A-0D2C-4086-9487-566887C1E753}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -306,10 +305,6 @@ Global
{277D77B9-8915-41E3-8763-0B66328ADDDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{277D77B9-8915-41E3-8763-0B66328ADDDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{277D77B9-8915-41E3-8763-0B66328ADDDA}.Release|Any CPU.Build.0 = Release|Any CPU
{901DA3C3-3ABA-4859-89D3-63343ED2A0AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{901DA3C3-3ABA-4859-89D3-63343ED2A0AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{901DA3C3-3ABA-4859-89D3-63343ED2A0AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{901DA3C3-3ABA-4859-89D3-63343ED2A0AC}.Release|Any CPU.Build.0 = Release|Any CPU
{93B64F12-EBDD-46CE-B4FB-0904701F0032}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{93B64F12-EBDD-46CE-B4FB-0904701F0032}.Debug|Any CPU.Build.0 = Debug|Any CPU
{93B64F12-EBDD-46CE-B4FB-0904701F0032}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -338,6 +333,10 @@ Global
{EC1A321B-70F6-420B-85D4-56C7869BB71B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC1A321B-70F6-420B-85D4-56C7869BB71B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC1A321B-70F6-420B-85D4-56C7869BB71B}.Release|Any CPU.Build.0 = Release|Any CPU
{AB6E1E7A-0D2C-4086-9487-566887C1E753}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AB6E1E7A-0D2C-4086-9487-566887C1E753}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AB6E1E7A-0D2C-4086-9487-566887C1E753}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AB6E1E7A-0D2C-4086-9487-566887C1E753}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -388,7 +387,6 @@ Global
{65DE66B6-568F-46AC-8F0D-C79A02F48214} = {083592CA-7DAB-44CE-8979-44FAFA46AEC3}
{004DEF24-7EBB-499D-BD1C-E940AC4E122D} = {A7B4FF1E-3DF7-4F28-9333-D0961CDDF702}
{277D77B9-8915-41E3-8763-0B66328ADDDA} = {A7B4FF1E-3DF7-4F28-9333-D0961CDDF702}
{901DA3C3-3ABA-4859-89D3-63343ED2A0AC} = {9D6603BD-7EA2-4D11-A69C-0D9E01317FD6}
{93B64F12-EBDD-46CE-B4FB-0904701F0032} = {A7B4FF1E-3DF7-4F28-9333-D0961CDDF702}
{AA4D318D-101B-49E7-A4EC-B34165AEDB33} = {FD7243E4-BF18-43F8-8744-BA1D17ACF378}
{B13C9E5F-0E4B-413E-90AE-20B84B100364} = {AA4D318D-101B-49E7-A4EC-B34165AEDB33}
Expand All @@ -397,6 +395,7 @@ Global
{17BDCE12-6964-4B87-B2AC-68CE270A3E9A} = {FD7243E4-BF18-43F8-8744-BA1D17ACF378}
{D2F67410-9933-42E8-B04A-E17634D83A30} = {9D6603BD-7EA2-4D11-A69C-0D9E01317FD6}
{EC1A321B-70F6-420B-85D4-56C7869BB71B} = {9D6603BD-7EA2-4D11-A69C-0D9E01317FD6}
{AB6E1E7A-0D2C-4086-9487-566887C1E753} = {B5821230-6E0A-4535-88A9-ED31B6F07596}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {497D2ED4-A13E-4BCA-8D29-F30CA7D0EA4A}
Expand Down
20 changes: 10 additions & 10 deletions build/pipelines/templates/extensions-variables.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
variables:
${{ if not(contains(variables['Build.SourceBranch'], '/release/' )) }}:
buildNumberTemp: $(Build.BuildNumber)
${{ if contains(variables['Build.SourceBranch'], '/release/' ) }}:
isReleaseBuildTemp: true
buildNumber: $[variables.buildNumberTemp]
isReleaseBuild: $[variables.isReleaseBuildTemp]
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
variables:
${{ if and( not(contains(variables['Build.SourceBranch'], '/release/')), not(startsWith(variables['Build.SourceBranch'], 'refs/tags')) ) }}:
buildNumberTemp: $(Build.BuildNumber)
${{ if or( contains(variables['Build.SourceBranch'], '/release/'), startsWith(variables['Build.SourceBranch'], 'refs/tags') ) }}:
isReleaseBuildTemp: true
buildNumber: $[variables.buildNumberTemp]
isReleaseBuild: $[variables.isReleaseBuildTemp]
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
25 changes: 25 additions & 0 deletions docs/analyzer-rules/AZFW0013.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# AZFW0013: Unable to parse binding argument

| | Value |
|-|-|
| **Rule ID** |AZFW0013|
| **Category** |[AzureFunctionsSyntax]|
| **Severity** |Error|

## Cause

This rule is triggered when a binding attribute argument is an invalid or null value.

## Rule description

[Attributes](https://learn.microsoft.com/en-us/dotnet/csharp/advanced-topics/reflection-and-attributes/) are used to define bindings, and the function metadata generator parses the arguments passed into these attributes to generate binding information during start up.

If the arguments passed in are invalid for any reason (such as being null), this rule is enforced.

## How to fix violations

Review the binding attribute.

## When to suppress warnings

This rule should not be suppressed because this error will prevent your functions from running.
5 changes: 3 additions & 2 deletions extensions/Worker.Extensions.CosmosDB/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- My change description (#PR/#issue)
-->

### Microsoft.Azure.Functions.Worker.Extensions.CosmosDB 4.4.1
### Microsoft.Azure.Functions.Worker.Extensions.CosmosDB 4.5.0

- [Bug] Update CosmosOptions from using IOptionsSnapshot to IOptionsMonitor to avoid DI scoping issues
- Updated `Microsoft.Azure.WebJobs.Extensions.CosmosDB` to 4.4.0
- Release notes for v4.4.0 can be found [here](https://github.com/Azure/azure-webjobs-sdk-extensions/releases/tag/cosmos-v4.4.0)
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ internal class CosmosDBBindingOptionsSetup : IConfigureNamedOptions<CosmosDBBind
{
private readonly IConfiguration _configuration;
private readonly AzureComponentFactory _componentFactory;
private readonly IOptionsMonitor<WorkerOptions> _workerOptions;

public CosmosDBBindingOptionsSetup(IConfiguration configuration, AzureComponentFactory componentFactory)
public CosmosDBBindingOptionsSetup(IConfiguration configuration, AzureComponentFactory componentFactory, IOptionsMonitor<WorkerOptions> workerOptions)
{
_configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
_componentFactory = componentFactory ?? throw new ArgumentNullException(nameof(componentFactory));
_workerOptions = workerOptions ?? throw new ArgumentNullException(nameof(workerOptions));
}

public void Configure(CosmosDBBindingOptions options)
Expand Down Expand Up @@ -53,6 +55,8 @@ public void Configure(string connectionName, CosmosDBBindingOptions options)

options.Credential = _componentFactory.CreateTokenCredential(connectionSection);
}

options.Serializer = new WorkerCosmosSerializer(_workerOptions.CurrentValue.Serializer);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using Microsoft.Azure.Cosmos;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Core;
using Microsoft.Extensions.Azure;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;

[assembly: WorkerExtensionStartup(typeof(CosmosExtensionStartup))]

Expand All @@ -22,16 +18,7 @@ public override void Configure(IFunctionsWorkerApplicationBuilder applicationBui
throw new ArgumentNullException(nameof(applicationBuilder));
}

applicationBuilder.Services.AddAzureClientsCore(); // Adds AzureComponentFactory

applicationBuilder.Services.AddOptions<CosmosDBBindingOptions>()
.Configure<IOptions<WorkerOptions>>((cosmosOptions, workerOptions) =>
{
CosmosSerializer cosmosSerializer = new WorkerCosmosSerializer(workerOptions?.Value?.Serializer);
cosmosOptions.Serializer = cosmosSerializer;
});

applicationBuilder.Services.AddSingleton<IConfigureOptions<CosmosDBBindingOptions>, CosmosDBBindingOptionsSetup>();
applicationBuilder.ConfigureCosmosDBExtension();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using Microsoft.Extensions.Azure;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;

namespace Microsoft.Azure.Functions.Worker
{
/// <summary>
/// Provides extension methods to work with a <see cref="IFunctionsWorkerApplicationBuilder"/>.
/// </summary>
public static class FunctionsWorkerApplicationBuilderExtensions
{
/// <summary>
/// Configures the CosmosDB extension.
/// </summary>
/// <param name="builder">The <see cref="IFunctionsWorkerApplicationBuilder"/> to configure.</param>
/// <returns>The same instance of the <see cref="IFunctionsWorkerApplicationBuilder"/> for chaining.</returns>
public static IFunctionsWorkerApplicationBuilder ConfigureCosmosDBExtension(this IFunctionsWorkerApplicationBuilder builder)
{
if (builder is null)
{
throw new System.ArgumentNullException(nameof(builder));
}

builder.Services.AddAzureClientsCore(); // Adds AzureComponentFactory
builder.Services.AddOptions<CosmosDBBindingOptions>();
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<CosmosDBBindingOptions>, CosmosDBBindingOptionsSetup>());

return builder;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
using System.Runtime.CompilerServices;
using Microsoft.Azure.Functions.Worker.Extensions.Abstractions;

[assembly: ExtensionInformation("Microsoft.Azure.WebJobs.Extensions.CosmosDB", "4.3.0")]
[assembly: ExtensionInformation("Microsoft.Azure.WebJobs.Extensions.CosmosDB", "4.4.0")]
[assembly: InternalsVisibleTo("Microsoft.Azure.Functions.Worker.Extensions.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001005148be37ac1d9f58bd40a2e472c9d380d635b6048278f7d47480b08c928858f0f7fe17a6e4ce98da0e7a7f0b8c308aecd9e9b02d7e9680a5b5b75ac7773cec096fbbc64aebd429e77cb5f89a569a79b28e9c76426783f624b6b70327eb37341eb498a2c3918af97c4860db6cdca4732787150841e395a29cfacb959c1fd971c1")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Description>Azure Cosmos DB extensions for .NET isolated functions</Description>

<!--Version information-->
<VersionPrefix>4.4.1</VersionPrefix>
<VersionPrefix>4.5.0</VersionPrefix>

<!--Temporarily opting out of documentation. Pending documentation-->
<GenerateDocumentationFile>false</GenerateDocumentationFile>
Expand Down
2 changes: 1 addition & 1 deletion extensions/Worker.Extensions.EventGrid/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

### Microsoft.Azure.Functions.Worker.Extensions.EventGrid <version>

- <event>
- <entry>
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,10 @@ public EventGridOutputAttribute()

/// <summary>Gets or sets the Topic Key setting. You can find information on getting the Key for a topic here: https://docs.microsoft.com/en-us/azure/event-grid/custom-event-quickstart#send-an-event-to-your-topic </summary>
public string? TopicKeySetting { get; set; }

/// <summary>
/// Gets or sets the app setting name that contains the Event Grid topic's connection information. When setting the `Connection` property, the `TopicEndpointUri` and `TopicKeySetting` properties should NOT be set.
/// </summary>
public string? Connection { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Description>Azure Event Grid extensions for .NET isolated functions</Description>

<!--Version information-->
<VersionPrefix>3.3.0</VersionPrefix>
<VersionPrefix>3.4.0</VersionPrefix>

<!--Temporarily opting out of documentation. Pending documentation-->
<GenerateDocumentationFile>false</GenerateDocumentationFile>
Expand Down
2 changes: 1 addition & 1 deletion extensions/Worker.Extensions.EventHubs/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

### Microsoft.Azure.Functions.Worker.Extensions.EventHubs <version>

- <entry>
- <entry>
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
using System.Runtime.CompilerServices;
using Microsoft.Azure.Functions.Worker.Extensions.Abstractions;

[assembly: ExtensionInformation("Microsoft.Azure.WebJobs.Extensions.EventHubs", "5.4.0")]
[assembly: ExtensionInformation("Microsoft.Azure.WebJobs.Extensions.EventHubs", "5.5.0")]
[assembly: InternalsVisibleTo("Microsoft.Azure.Functions.Worker.Extensions.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001005148be37ac1d9f58bd40a2e472c9d380d635b6048278f7d47480b08c928858f0f7fe17a6e4ce98da0e7a7f0b8c308aecd9e9b02d7e9680a5b5b75ac7773cec096fbbc64aebd429e77cb5f89a569a79b28e9c76426783f624b6b70327eb37341eb498a2c3918af97c4860db6cdca4732787150841e395a29cfacb959c1fd971c1")]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Description>Azure Event Hubs extensions for .NET isolated functions</Description>

<!--Version information-->
<VersionPrefix>5.5.0</VersionPrefix>
<VersionPrefix>5.6.0</VersionPrefix>

</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions extensions/Worker.Extensions.Http.AspNetCore/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
- My change description (#PR/#issue)
-->

### Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore
### Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore <version>

- Adding support for binding to request body (`FromBodyAttribute` support)
- <entry>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

<!--Version information-->
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>-preview4</VersionSuffix>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

Expand Down
6 changes: 2 additions & 4 deletions extensions/Worker.Extensions.Kafka/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
- My change description (#PR/#issue)
-->

### Microsoft.Azure.Functions.Worker.Extensions.Kafka 3.9.0
### Microsoft.Azure.Functions.Worker.Extensions.Kafka <version>

- Add `BindingCapabilities` attribute to KafkaTrigger to express function-level retry capabilities. (#1457)
- Updated Kafka Extension nuget package to most recent version (3.9.0) (#1713)
- Exposed an important scaling parameter `LagThreshold`` to let a user configure their scaling preferences within Kafka Trigger function. (#1713)
- <entry>
11 changes: 3 additions & 8 deletions extensions/Worker.Extensions.Rpc/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
- My change description (#PR/#issue)
-->

### Microsoft.Azure.Functions.Worker.Extensions.Rpc 1.0.0-preview1
### Microsoft.Azure.Functions.Worker.Extensions.Rpc 1.0.0

- Add `IHttpClientBuilder.ConfigureForFunctionsHostGrpc` extension method. (#1616)
- Used along with `IServiceCollection.AddGrpcClient<TClient>()` to configure for Functions host communication.
- **NOTE**: when using Grpc.Net.ClientFactory <= 2.54.0-pre1 use `IServiceCollection.AddGrpcClient<TClient>(_ => { })`
- See [grpc/grpc-dotnet/issues/2158](https://github.com/grpc/grpc-dotnet/issues/2158)
- Available in `>=net6.0` only.
- Add `FunctionsGrpcOptions`, which can be used to get a built `CallInvoker` for gRPC communication with the functions host. (#1637)
- Available in all TFMs.
- Initial public release
- Adds API for getting a `CallInvoker` pre-configured for communication with Functions host.
18 changes: 15 additions & 3 deletions extensions/Worker.Extensions.Rpc/src/ConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,22 @@ internal static class ConfigurationExtensions
/// </exception>
public static Uri GetFunctionsHostGrpcUri(this IConfiguration configuration)
{
string uriString = $"http://{configuration["HOST"]}:{configuration["PORT"]}";
if (!Uri.TryCreate(uriString, UriKind.Absolute, out Uri? grpcUri))
Uri? grpcUri;
var functionsUri = configuration["Functions:Worker:HostEndpoint"];
if (functionsUri is not null)
{
throw new InvalidOperationException($"The gRPC channel URI '{uriString}' could not be parsed.");
if (!Uri.TryCreate(functionsUri, UriKind.Absolute, out grpcUri))
{
throw new InvalidOperationException($"The gRPC channel URI '{functionsUri}' could not be parsed.");
}
}
else
{
var uriString = $"http://{configuration["HOST"]}:{configuration["PORT"]}";
if (!Uri.TryCreate(uriString, UriKind.Absolute, out grpcUri))
{
throw new InvalidOperationException($"The gRPC channel URI '{uriString}' could not be parsed.");
}
}

return grpcUri;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

#if !NETSTANDARD
using System;
using Grpc.Core;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;

namespace Microsoft.Azure.Functions.Worker.Extensions.Rpc
{
/// <summary>
/// <see cref="IServiceCollection" /> extensions for RPC.
/// </summary>
public static partial class RpcServiceCollectionExtensions
{
private static void ConfigureCallInvoker(IServiceCollection services)
{
// Instead of building the GrpcChannel/CallInvoker ourselves, we use Grpc.Net.ClientFactory to
// construct and configure the CallInvoker for us, then we attach that to our options.
services.AddGrpcClient<CallInvokerExtractor>(_ => { })
.ConfigureForFunctionsHostGrpc();
services.TryAddEnumerable(
ServiceDescriptor.Transient<IConfigureOptions<FunctionsGrpcOptions>, ConfigureOptions>());
}

// Used as a roundabout way of getting the configured CallInvoker from Grpc.Net.ClientFactory.
private class CallInvokerExtractor
{
public CallInvokerExtractor(CallInvoker callInvoker)
{
CallInvoker = callInvoker ?? throw new ArgumentNullException(nameof(callInvoker));
}

public CallInvoker CallInvoker { get; }
}

private class ConfigureOptions : IConfigureOptions<FunctionsGrpcOptions>
{
private readonly CallInvokerExtractor _extractor;

public ConfigureOptions(CallInvokerExtractor extractor)
{
_extractor = extractor;
}

public void Configure(FunctionsGrpcOptions options)
{
options.CallInvoker = _extractor.CallInvoker;
}
}
}
}
#endif
Loading