File: GeneratedFunctionMetadataProvider.g.cs
Project: src\playground\AzureFunctionsEndToEnd\AzureFunctionsEndToEnd.Functions\AzureFunctionsEndToEnd.Functions.csproj (AzureFunctionsEndToEnd.Functions)
// <auto-generated/>
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Core.FunctionMetadata;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
 
namespace AzureFunctionsEndToEnd.Functions
{
    /// <summary>
    /// Custom <see cref="IFunctionMetadataProvider"/> implementation that returns function metadata definitions for the current worker.
    /// </summary>
    [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Azure.Functions.Worker.Sdk.Generators", "1.3.5.0")]
    public class GeneratedFunctionMetadataProvider : IFunctionMetadataProvider
    {
        /// <inheritdoc/>
        public Task<ImmutableArray<IFunctionMetadata>> GetFunctionMetadataAsync(string directory)
        {
            var metadataList = new List<IFunctionMetadata>();
            var Function0RawBindings = new List<string>();
            Function0RawBindings.Add(@"{""name"":""$return"",""type"":""blob"",""direction"":""Out"",""blobPath"":""test-files/{name}.txt"",""connection"":""blob""}");
            Function0RawBindings.Add(@"{""name"":""triggerString"",""type"":""blobTrigger"",""direction"":""In"",""properties"":{""supportsDeferredBinding"":""True""},""path"":""myblobcontainer/{name}"",""connection"":""blob"",""dataType"":""String""}");
 
            var Function0 = new DefaultFunctionMetadata
            {
                Language = "dotnet-isolated",
                Name = "MyAzureBlobTrigger",
                EntryPoint = "AzureFunctionsEndToEnd.Functions.MyAzureBlobTrigger.RunAsync",
                RawBindings = Function0RawBindings,
                ScriptFile = "AzureFunctionsEndToEnd.Functions.dll"
            };
            metadataList.Add(Function0);
            var Function1RawBindings = new List<string>();
            Function1RawBindings.Add(@"{""name"":""message"",""type"":""queueTrigger"",""direction"":""In"",""properties"":{""supportsDeferredBinding"":""True""},""queueName"":""queue"",""connection"":""queue""}");
 
            var Function1 = new DefaultFunctionMetadata
            {
                Language = "dotnet-isolated",
                Name = "MyAzureQueueTrigger",
                EntryPoint = "AzureFunctionsEndToEnd.Functions.MyAzureQueueTrigger.Run",
                RawBindings = Function1RawBindings,
                ScriptFile = "AzureFunctionsEndToEnd.Functions.dll"
            };
            metadataList.Add(Function1);
            var Function2RawBindings = new List<string>();
            Function2RawBindings.Add(@"{""name"":""input"",""type"":""eventHubTrigger"",""direction"":""In"",""eventHubName"":""myhub"",""connection"":""myhub"",""cardinality"":""Many"",""dataType"":""String""}");
 
            var Function2 = new DefaultFunctionMetadata
            {
                Language = "dotnet-isolated",
                Name = "MyEventHubTrigger",
                EntryPoint = "AspirePlusFunctions.Functions.MyEventHubTrigger.Run",
                RawBindings = Function2RawBindings,
                ScriptFile = "AzureFunctionsEndToEnd.Functions.dll"
            };
            metadataList.Add(Function2);
            var Function3RawBindings = new List<string>();
            Function3RawBindings.Add(@"{""name"":""req"",""type"":""httpTrigger"",""direction"":""In"",""authLevel"":""Anonymous"",""methods"":[""get"",""post""]}");
            Function3RawBindings.Add(@"{""name"":""$return"",""type"":""http"",""direction"":""Out""}");
 
            var Function3 = new DefaultFunctionMetadata
            {
                Language = "dotnet-isolated",
                Name = "injected-resources",
                EntryPoint = "AzureFunctionsEndToEnd.Functions.MyHttpTrigger.Run",
                RawBindings = Function3RawBindings,
                ScriptFile = "AzureFunctionsEndToEnd.Functions.dll"
            };
            metadataList.Add(Function3);
 
            return global::System.Threading.Tasks.Task.FromResult(metadataList.ToImmutableArray());
        }
    }
 
    /// <summary>
    /// Extension methods to enable registration of the custom <see cref="IFunctionMetadataProvider"/> implementation generated for the current worker.
    /// </summary>
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Azure.Functions.Worker.Sdk.Generators", "1.3.5.0")]
    public static class WorkerHostBuilderFunctionMetadataProviderExtension
    {
        ///<summary>
        /// Adds the GeneratedFunctionMetadataProvider to the service collection.
        /// During initialization, the worker will return generated function metadata instead of relying on the Azure Functions host for function indexing.
        ///</summary>
        public static IHostBuilder ConfigureGeneratedFunctionMetadataProvider(this IHostBuilder builder)
        {
            builder.ConfigureServices(s => 
            {
                s.AddSingleton<IFunctionMetadataProvider, GeneratedFunctionMetadataProvider>();
            });
            return builder;
        }
    }
    /// <summary>
    /// Auto startup class to register the custom <see cref="IFunctionMetadataProvider"/> implementation generated for the current worker.
    /// </summary>
    [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Azure.Functions.Worker.Sdk.Generators", "1.3.5.0")]
    public class FunctionMetadataProviderAutoStartup : global::Microsoft.Azure.Functions.Worker.IAutoConfigureStartup
    {
        /// <summary>
        /// Configures the <see cref="IHostBuilder"/> to use the custom <see cref="IFunctionMetadataProvider"/> implementation generated for the current worker.
        /// </summary>
        /// <param name="hostBuilder">The <see cref="IHostBuilder"/> instance to use for service registration.</param>
        public void Configure(IHostBuilder hostBuilder)
        {
            hostBuilder.ConfigureGeneratedFunctionMetadataProvider();
        }
    }
}