Comments (2)
csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.3.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.21.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.2.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.17.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.3.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.2" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
<PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" Version="8.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.Publisher.ApplicationInsights" Version="8.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="8.0.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageReference Include="Worker.Extensions.HttpTelemetryProcessor" Version="1.0.2" />
</ItemGroup>
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="appsettings.Production.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="appsettings.Staging.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<PropertyGroup>
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
</PropertyGroup>
<ItemGroup>
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
</ItemGroup>
</Project>
Trimmed down function raising object desposed function:
public class BrokenFunction(IRequestProcessor requestProcessor,
IRequestReader requestReader, IAuthenticationService authenticationService,
ILogger<BrokenFunction> logger) : AuthorizedFunction(authenticationService)
{
[Function("BrokenFunction")]
public async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest httpRequest, ExecutionContext executionContext)
{
var result = await AuthorizeAsync(httpRequest);
if (!result.Succeeded)
{
logger.LogWarning(result.Failure, "Unauthenticated request");
return new UnauthorizedResult();
}
try
{
var request = await requestReader.ReadRequest(logger, httpRequest);
using var scope = logger.BeginScope(new Dictionary<string, object>
{
["RequestId"] = request.RequestId,
["Email"] = httpRequest.HttpContext.User.FindFirst(ClaimTypes.Email)?.Value,
["CustomerId"] = httpRequest.HttpContext.User.FindFirst("customer_id")?.Value,
});
var response = await requestProcessor.ProcessRequest(logger, request);
var serializerSettings = SerializerSettings.GetSettings();
var jsonResponse = JsonConvert.SerializeObject(response, serializerSettings);
logger.LogInformation("response: {json}", jsonResponse);
return new OkObjectResult(response);
}
catch (UnauthorizedAccessException)
{
return new UnauthorizedResult();
}
}
}
public abstract class AuthorizedFunction(IAuthenticationService authenticationService)
{
protected async Task<AuthenticateResult> AuthorizeAsync(HttpRequest httpRequest)
{
var result = await authenticationService.AuthenticateAsync(httpRequest.HttpContext, null);
if (result.Succeeded)
{
httpRequest.HttpContext.User = result.Principal;
}
return result;
}
}
Behind the scenes some other api's are being called. They can be slow, but we could not correlate duration vs ObjectDisposedexception.
from azure-functions-dotnet-worker.
We don't have a reproducible sample as this exception did only happens seemingly random.
Can you share what you have and what you're currently doing? Even if it's random it would be helpful to have some steps that could help us figure out what is causing this.
from azure-functions-dotnet-worker.
Related Issues (20)
- Graceful shutdown of a QueueTrigger function via observing the CancellationToken HOT 2
- HTTP body conversion will throw an InvalidOperationException when the request have an empty body
- [1ES] Investigate dotnet-host.public pipeline windows artifact build issue
- [1ES] Remove `_manifest` folder from FunctionsNetHost nuget payload
- CORS error in Azure Func with Linux Flex Consumption HOT 6
- Inheriting FunctionAttribute not supported? HOT 4
- Error: 'Having multiple overloads of method 'Configure' is not supported.' after upgrading .NET 6.0 to .NET 8.0 using Upgrade Assistant HOT 1
- HttpTrigger GET parameters not mapped to custom class in .NET 8 and isolated
- .NET 8 Isolated Logging to Application Insights I can't change LogLevel from Azure Environment Variables
- .NET 8 Isolated function do not startup on Azure environment HOT 2
- Is it possible to disable automatic abandoning of service bus messages? HOT 4
- Kafka Trigger Avro Deserialization for isolated model
- Replacement for ILifeCycleNotificationHelper in Isolated Worker Process
- IFunctionBindingsFeature is internal and pevent unit testing in middleware
- ExtensionStartupRunnerGenerator generating code which conflicts with customer code (namespace)
- Update to Microsoft.Azure.Functions.Worker.Core version 1.18 breaks Open Telemetry Tracing for .net8 isolated function
- Azure function with QueueTrigger fails to pass whitesource scan (Azure Identity Libraries and Microsoft Authentication Library Elevation of Privilege Vulnerability)) HOT 1
- CosmosDBInput returning 500 instead of 404 when item does not exist
- ServiceBusOutput does not support byte[] as claimed
- Add support to clear Service Bus session state
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-worker.