DHS.ICE.TechOps.AzureFunction.V8.Common 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package DHS.ICE.TechOps.AzureFunction.V8.Common --version 1.0.3
                    
NuGet\Install-Package DHS.ICE.TechOps.AzureFunction.V8.Common -Version 1.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DHS.ICE.TechOps.AzureFunction.V8.Common" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DHS.ICE.TechOps.AzureFunction.V8.Common" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="DHS.ICE.TechOps.AzureFunction.V8.Common" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DHS.ICE.TechOps.AzureFunction.V8.Common --version 1.0.3
                    
#r "nuget: DHS.ICE.TechOps.AzureFunction.V8.Common, 1.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DHS.ICE.TechOps.AzureFunction.V8.Common@1.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DHS.ICE.TechOps.AzureFunction.V8.Common&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=DHS.ICE.TechOps.AzureFunction.V8.Common&version=1.0.3
                    
Install as a Cake Tool

A set of common utility tools for Azure Function in isolated mode with .Net8

A small program provides a set of utility tools, which makes programming easier for Azure Function with isolated mode.

Blob Storage Logger

This is a logger tool, which extends ILogger and ILoggerProvider and writes log entries into permenant blob storage.
In program.cs, add following codes

builder.Logging.AddProvider(new BlobStorageLoggerProvider());

or

.ConfigureLogging(logging =>
{
    logging.AddProvider(new BlobStorageLoggerProvider());
})

If you do not want to or do not need add "RelevantId" for log entris, you are pretty much done!
In order to trace by "RelevantId", you can adopt one of the two ways below.
For a single log entry, try template method.

logger.LogInformation("Started job abc with {RelevantId}.", new { CaseNumber = caseNumber, RequestGuid = requestGuid });

For a section with multiple log entries, try the using block.

using (logger.BeginScope(new Dictionary<string, object> { ["RelevantId"] = new { CaseNumber = caseNumber, RequestGuid = requestGuid } }));
{
    ...
    logger.LogInformation("Started job abc.");    
    ...
    logger.LogInformation("Finished job abc.");    
}

For more advanced settings and usages, please review the source codes.

Resource Pool for Dyanmics 365 Service Client

This is an auto scaling resource pool for Dynamics 365 "ServiceClient" instances, which can overcome some design imperfectness for MS.
This component will allow you to use short-lived, scoped Dynamics 365 "ServiceClient" instances without worries about the socket depletion issue.
In program.cs, add following codes.

services.AddSingleton<IPooledServiceClientFactory>(new PooledServiceClientFactory(YOUR_CONNECTION_STRING));                

In hosted service for start/stop handler, add following codes.

private readonly IPooledServiceClientFactory _pooledServiceClientFactory;

public HostStartupHandler(IPooledServiceClientFactory pooledServiceClientFactory)
{
    _pooledServiceClientFactory = pooledServiceClientFactory;
}

public Task StartAsync(CancellationToken cancellationToken)
{
    _pooledServiceClientFactory.Initialize();
    return Task.CompletedTask;
}

Use the resource in your codes as following.

ServiceClient client = _pooledServiceClientFactory.Acquire();
try
{
    ...
}
finally
{
    _pooledServiceClientFactory.Release(client);
}

For more advanced settings and usages, please review the source codes.

Blob Storage Factory and Service Bus Factory

MS does not provide an easy way for isolated mode to output multiple blob storage files and / or service bus messages.
Those two tools adopt a factory design pattern, which can minimize the connections to the back services with the same access token and allow you easily output multiple files and / or messages.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.4 353 6/11/2025
1.0.3 131 6/6/2025