Comments (9)
Hi @dhanore, Thank you for your feedback! We will check for the possibilities internally and update you with the findings.
from azure-functions-dotnet-extensions.
Tagging @fabiocav / @brettsam , for further insights
from azure-functions-dotnet-extensions.
Thank you for picking up this bug.
Hope you got a chance to review this bug. Would you please let me know the findings or fixes which you suggest to solve this bug on our side?
from azure-functions-dotnet-extensions.
Hi, Did you get a chance to look into this issue or any plan for upcoming days to give some feedback?.
from azure-functions-dotnet-extensions.
@v-bbalaiagar
Hi, I cannot see any status update and any comments on this issue. Could you please help me with the status or position of this issue. And I can see this issue has been transferred, could you please help me to identify the location of this issue here?
from azure-functions-dotnet-extensions.
@v-bbalaiagar @fabiocav @brettsam - Can you please let me know what is the status of this issue and where is this issue has transferred so I can see the status of it and any workaround for this issue as this is a priority task in our board?
from azure-functions-dotnet-extensions.
@dhanore would you mind sharing the full startup implementations for both cases (or a reduced repro) either here or in a repo?
Thank you!
from azure-functions-dotnet-extensions.
Below is WebJobStartup code - which is not giving Url for request in appInsights and FunctionStartup code which is giving result after that
using AzureFunctions.Extensions.Swashbuckle;
using AzureFunctions.Extensions.Swashbuckle.Settings;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.AspNetCore.Builder;
using Microsoft.Azure.ServiceBus;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using Willezone.Azure.WebJobs.Extensions.DependencyInjection;
using TestApplication.Infrastructure;
[assembly: WebJobsStartup(typeof(Startup))]
namespace TestApplication.Infrastructure
{
[ExcludeFromCodeCoverage]
internal class Startup : IWebJobsStartup
{
public void Configure(IApplicationBuilder app)
{
app.UseSwagger();
}
public void Configure(IWebJobsBuilder builder)
{
builder.AddDependencyInjection(ConfigureServices);
builder.AddSwashBuckle(Assembly.GetExecutingAssembly(), opts =>
{
opts.SpecVersion = OpenApiSpecVersion.OpenApi3_0;
opts.Documents = new[]
{
new SwaggerDocument
{
Name = "v1",
Title = "Test App",
Description = "Test App",
Version = "v1"
}
};
opts.ConfigureSwaggerGen = (c =>
{
c.AddSecurityDefinition(SecuritySchemes.DevtokenSecurityId,
SecuritySchemes.DevTokenSecurityScheme);
c.AddSecurityDefinition(SecuritySchemes.JwtSecurityId,
SecuritySchemes.JwtSecurityScheme);
c.OperationFilter<SecurityOperationFilter>();
c.CustomOperationIds(apiDesc =>
{
var info = apiDesc.TryGetMethodInfo(out MethodInfo methodInfo) ? methodInfo : null;
var customAttrInfo = (FunctionNameAttribute)info?.GetCustomAttributes()?
.FirstOrDefault(attr => attr is FunctionNameAttribute);
return customAttrInfo?.Name;
});
});
opts.XmlPath = "TestApp.xml";
});
}
readonly HttpClient httpClient = new HttpClient() { Timeout = new TimeSpan(0, 10, 0) };
private void ConfigureServices(IServiceCollection services)
{
services.AddTransient<IRegistryHelper, RegistryHelper>();
services.AddSingleton<IConfigHelper>(
new ConfigHelper(services.BuildServiceProvider().GetRequiredService<IRegistryHelper>()));
var configHelper =
services
.BuildServiceProvider()
.GetRequiredService<IConfigHelper>();
services.AddMemoryCache();
services.AddTransient<IJwtHelper, JwtHelper>(s => new JwtHelper());
services.AddSingleton(new TelemetryClient());
// Registering services
services.AddTransient<IFunctionLogger, FunctionLogger>();
services.AddTransient<IRequestSecurityHelper, RequestSecurityHelper>();
services.AddTransient<ITestManager, TestManager>();
services.AddTransient<IExternalServiceHelper, ExternalServiceHelper>();
services.AddTransient<ITestDatabaseHelper, TestDatabaseHelper>();
services.AddTransient<IHttpClientManager, HttpClientManager>();
services.AddHttpClient("TestClient")
.ConfigurePrimaryHttpMessageHandler(() =>
{
return new HttpClientHandler()
{
AllowAutoRedirect = false,
UseDefaultCredentials = true
};
});
var logger =
services
.BuildServiceProvider()
.GetRequiredService<IFunctionLogger>();
try
{
#region db setup
var cosmosUnifiedConfigurationDB = new CosmosDBConfiguration
{
ThroughputType = ThroughputType.AutoScale,
DatabaseId = Constants.DATABASENAME,
ThroughputLevel = ThroughputLevel.DatabaseLevel,
RetryOptions = new CosmosDBRetryOptions()
{ MaxRetryWaitTimeInSeconds = 100, MaxRetryAttempts = 60 },
DoNotOverrideThroughputSettings = true
};
var containerConfig = new CosmosDBContainerSettings
{
ContainerId = Constants.COLLECTION_NAME,
PartitionKeyPath = Constants.PARTITION_KEY
};
services.AddTransient<ICosmosDBRepository<TestAzureEntity>>(s =>
new CosmosDBRepository<TestAzureEntity>(containerConfig, cosmosUnifiedConfigurationDB));
// initialize db:
// the following line is about making sure the DB collection is created
// so that it doesn´t run on every new instance of a server
logger.LogTrace($"Initializing DB DBId: {Constants.DATABASENAME} Container: {Constants.COLLECTION_NAME} PartitionKey: / id", "RegisterServices", SeverityLevel.Information, Category.Request);
DBSetupHelper.InitializeDBCollection(services);
// Please keep it running until bootstrapper V3 code
// with a bug fix for multiple concurrent initializations.
// for more details on the subject
DBSetupHelper.initRepos(services);
#endregion
}
catch (Exception ex)
{
// log the exception
logger.LogException(ex, "Startup.RegisterServices", "Exception thrown in db setup of startup class for service.",
Category.Startup, SubCategory.Incoming, null);
}
#region setup for service bus
// Service bus DI
services.AddSingleton<ITopicClient>(
t => new TopicClient(configHelper.ServiceBusConnectionString, configHelper.TopicName)
);
services.AddTransient<ISubscriptionSetup, SubscriptionSetup>();
services.AddTransient<IServiceBusManager, ServiceBusManager>();
services.AddSingleton<IAsbHelper, AsbHelper>();
// build subscription setup instance
var subscriptionSetup =
services
.BuildServiceProvider()
.GetRequiredService<ISubscriptionSetup>();
// setup subscriptions
subscriptionSetup.SetupSubscriptionClient();
#endregion
}
}
internal class ApiKeyScheme : OpenApiSecurityScheme
{
}
}
Function Startup which is giving Url of Request in AppInsights
using AzureFunctions.Extensions.Swashbuckle.Settings;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using Microsoft.Azure.ServiceBus;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi;
using Swashbuckle.AspNetCore.SwaggerGen;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using TestApplication.Infrastructure.Function
[assembly: FunctionsStartup(typeof(Startup))]
namespace TestApplication.Infrastructure.Function
{
[ExcludeFromCodeCoverage]
public class Startup : FunctionsStartup
{
// static string appInstanceId = Guid.NewGuid().ToString();
/// <summary>
/// Configure startup
/// </summary>
/// <param name="builder"></param>
public override void Configure(IFunctionsHostBuilder builder)
{
RegisterServices(builder.Services);
builder.AddSwashBuckle(Assembly.GetExecutingAssembly(), opts =>
{
opts.SpecVersion = OpenApiSpecVersion.OpenApi3_0;
opts.Documents = new[]
{
new SwaggerDocument
{
Name = "v1",
Title = "Test Application",
Description = "Test Application",
Version = "v1"
}
};
opts.ConfigureSwaggerGen = (c =>
{
c.AddSecurityDefinition(SecuritySchemes.DevtokenSecurityId,
SecuritySchemes.DevTokenSecurityScheme);
c.AddSecurityDefinition(SecuritySchemes.JwtSecurityId,
SecuritySchemes.JwtSecurityScheme);
c.OperationFilter<SecurityOperationFilter>();
c.CustomOperationIds(apiDesc =>
{
var info = apiDesc.TryGetMethodInfo(out MethodInfo methodInfo) ? methodInfo : null;
var customAttrInfo = (FunctionNameAttribute)info?.GetCustomAttributes()?
.FirstOrDefault(attr => attr is FunctionNameAttribute);
return customAttrInfo?.Name;
});
});
opts.XmlPath = "TestApplication.xml";
});
}
private void RegisterServices(IServiceCollection services)
{
services.AddTransient<IRegistryHelper, RegistryHelper>();
services.AddSingleton<IConfigHelper>(
new ConfigHelper(services.BuildServiceProvider().GetRequiredService<IRegistryHelper>()));
var configHelper =
services
.BuildServiceProvider()
.GetRequiredService<IConfigHelper>();
services.AddMemoryCache();
// Registering services
services.AddTransient<IJwtHelper, JwtHelper>(s => new JwtHelper());
var telemetryConfig = TelemetryConfiguration.CreateDefault();
telemetryConfig.TelemetryInitializers.Add(new CloudRoleNameInitializer());
services.AddSingleton(new TelemetryClient(telemetryConfig));
services.AddTransient<IFunctionLogger, FunctionLogger>();
services.AddTransient<IRequestSecurityHelper, RequestSecurityHelper>();
services.AddTransient<ITestManager, TestManager>();
services.AddTransient<IExternalServiceHelper, ExternalServiceHelper>();
services.AddTransient<ITestDatabaseHelper, TestDatabaseHelper>();
services.AddTransient<IHttpClientManager, HttpClientManager>();
services.AddHttpClient("TestApplication")
.ConfigurePrimaryHttpMessageHandler(() =>
{
return new HttpClientHandler()
{
AllowAutoRedirect = false,
UseDefaultCredentials = true
};
});
var logger =
services
.BuildServiceProvider()
.GetRequiredService<IFunctionLogger>();
try
{
#region db setup
var cosmosUnifiedConfigurationDB = new CosmosDBConfiguration
{
ThroughputType = ThroughputType.AutoScale,
DatabaseId = Constants.DATABASENAME,
ThroughputLevel = ThroughputLevel.DatabaseLevel,
RetryOptions = new CosmosDBRetryOptions()
{ MaxRetryWaitTimeInSeconds = 100, MaxRetryAttempts = 60 },
DoNotOverrideThroughputSettings = true
};
var containerConfig = new CosmosDBContainerSettings
{
ContainerId = Constants.COLLECTION_NAME,
PartitionKeyPath = Constants.PARTITION_KEY
};
services.AddTransient<ICosmosDBRepository<BoosterAzureEntity>>(s =>
new CosmosDBRepository<BoosterAzureEntity>(containerConfig, cosmosUnifiedConfigurationDB));
// initialize db:
// the following line is about making sure the DB collection is created
// so that it doesn´t run on every new instance of a server
DBSetupHelper.InitializeDBCollection(services);
// with a bug fix for multiple concurrent initializations.
// also check Azure function Bootstrapper V3 Documentation.docx
// for more details on the subject
DBSetupHelper.initRepos(services);
#endregion
}
catch (Exception ex)
{
// log the exception
logger.LogException(ex, "Startup.RegisterServices", "Exception thrown in db setup of startup class for service.",
Category.Startup, SubCategory.Incoming, null);
}
#region setup for service bus
// Service bus DI
services.AddSingleton<ITopicClient>(
t => new TopicClient(configHelper.ServiceBusConnectionString, configHelper.TopicName)
);
services.AddTransient<ISubscriptionSetup, SubscriptionSetup>();
services.AddTransient<IServiceBusManager, ServiceBusManager>();
services.AddSingleton<IAsbHelper, AsbHelper>();
// build subscription setup instance
var subscriptionSetup =
services
.BuildServiceProvider()
.GetRequiredService<ISubscriptionSetup>();
// setup subscriptions
subscriptionSetup.SetupSubscriptionClient();
#endregion
}
}
}
from azure-functions-dotnet-extensions.
@fabiocav, @brettsam - I have shared the code for both the files above (IWebJob and FunctionStartup). I hope this helps you and let us know if you find anything. Please let me know if you need any other assistance from my side.
from azure-functions-dotnet-extensions.
Related Issues (20)
- Azure function v3 fails to start up in Visual Studio 2019 for Mac when using Microsoft.Azure.Functions.Extensions.DependencyInjection HOT 8
- Could not load type 'Microsoft.Azure.WebJobs.Hosting.IWebJobsStartup2' HOT 16
- Registering implementation type X is not assignable to service type IX when using Generics HOT 6
- [FEATURE REQ] Fluent Strongly Typed Context
- [Feature] Remove local.settings.json and be consistent with how AspNet Core work HOT 1
- [Question] How to use appsetting.json values in a trigger? HOT 2
- DependencyInjection stops working when we add User Secrets (Error: "Microsoft.Extensions.DependencyInjection.Abstractions: Unable to resolve [injected service] while attempting to activate [function])
- Upgrading Microsoft.Extensions.DependencyInjection.Abstractions to latest version (5.0.0) breaks DI HOT 1
- [Feature Request] Specify Startup per function HOT 2
- Dependency Injection not instantiating instances when using function.json rather than attributes
- Error during startup when using SignalR.Client HOT 1
- The Functions scale controller may not scale the following functions correctly because some configuration values were modified in an external startup class HOT 16
- [Pls Help] Why DI doesn't work as expected when using Azure Function HOT 2
- Dotnet 6 and Azure Functions V4 HOT 5
- Why is the context not available on IFunctionsHostBuilder, but on internal interface IFunctionsHostBuilderExt HOT 7
- This repo is missing important files HOT 1
- Incompatiblity with EF Core 7 HOT 11
- Is there any documentation available for migrating from IWebJobsStartup to FunctionsStartup in Azure Function? HOT 3
- Update Microsoft.Azure.WebJobs to latest, Newtonsoft.Json 11.0.2 dependency HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-functions-dotnet-extensions.