AzureAutoNumber 1.2.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package AzureAutoNumber --version 1.2.1                
NuGet\Install-Package AzureAutoNumber -Version 1.2.1                
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="AzureAutoNumber" Version="1.2.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AzureAutoNumber --version 1.2.1                
#r "nuget: AzureAutoNumber, 1.2.1"                
#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.
// Install AzureAutoNumber as a Cake Addin
#addin nuget:?package=AzureAutoNumber&version=1.2.1

// Install AzureAutoNumber as a Cake Tool
#tool nuget:?package=AzureAutoNumber&version=1.2.1                

How to use

The project relies on Azure Blob Storage. AutoNumber package will generate ids by using a single text file on the Azure Blob Storage.

var blobStorageAccount = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(connectionString);

var blobOptimisticDataStore = new BlobOptimisticDataStore(blobStorageAccount, "unique-ids");

var idGen = new UniqueIdGenerator(blobOptimisticDataStore);

// generate ids with different scopes

var id = idGen.NextId("urls");
var id2 = idGen.NextId("orders");

With Microsoft DI

The project has an extension method to add it and its dependencies to Microsoft ASP.NET DI. The only caveat is you need to registry type of CloudStorageAccount in DI before registring AutoNumber.

Use options builder to configure the service, take into account the default settings will read from appsettings.json.

services.AddAutoNumber(Configuration, x =>
{
	return x.UseContainerName("container-name")
	 .UseStorageAccount("connection-string-or-connection-string-name")
   //.UseStorageAccount(cloudStorageAccountInstance)
	 .SetBatchSize(10)
	 .SetMaxWriteAttempts(100)
	 .Options;
});
Deprecated way to register the service:
// configure the services
// you need to register an instane of CloudStorageAccount before using this
serviceCollection.AddAutoNumber();
Inject IUniqueIdGenerator in constructor
public class Foo
{
  public Foo(IUniqueIdGenerator idGenerator)
  {
      _idGenerator = idGenerator;
  }
}

Configuration

These are default configuration for AutoNumber. If you prefer registering AutoNumber with AddAddNumber method, these options can be set via appsettings.json.

{
  "AutoNumber": {
    "BatchSize": 50,
    "MaxWriteAttempts": 25,
    "StorageContainerName": "unique-urls"
  }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 is compatible.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on AzureAutoNumber:

Package Downloads
ASPOT_API_SharedUtilities

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.5.0 616 10/25/2024
1.4.0 104,647 8/25/2022
1.3.3 94,721 3/28/2022
1.3.2 34,684 7/29/2021
1.3.0 38,333 1/8/2021
1.2.2 16,193 8/28/2020
1.2.1 29,717 6/30/2020
1.1.0 751 6/26/2020
1.0.0 39,909 2/17/2020

Bug fixed:
1. AddAutoNumber extension throws a scoping exception (aspnet core 3.1)

Breacking changes:
1. The AddAutoNumber is deprecated now, use another overload with options builder instead.