This project provides a number of helpful wrappers around the Microsoft Azure Storage API's to allow for more rapid development. Including the ability to do single-line upload of files from an IFormFile into Azure Blob Storage.
Install from NuGet
Install-Package ICG.AspNetCore.Utilities.CloudStorage
Inside of of your project's Startus.cs within the RegisterServices method add this line of code.
services.UseIcgNetCoreUtilities(Configuration);
services.UseIcgAspNetCoreUtilitiesCloudStorage();
Lastly, before using you will need to configure your storage options. An example configuation is below.
"AzureCloudStorageOptions": {
"StorageConnectionString": "<Your Storage Connection String>",
"RootClientPath": "<Either your CDN Endpoint, or Path to Blob >",
"DefaultSASTokenDurationMinutes": 60
}
Note
Root client path could be https://youraccount.blob.core.windows.net or if you have configured a CDN your CDN path. This is what will be used to provide the return path of uploaded objects
Warning
Be sure to consider security of these credentials, this library fully supports IOptions
so you can utilize environment variables, the appsettings.json
file or any other mechanism that injects values to Configuration
Object | Purpose |
---|---|
IAzureCloudStorageProvider | Provides the tools necessary to upload objects to Azure |
IMimeTypeMapper | An implementation of a mime-type mapper, copied from similar code in .NET Core, but moved internal to limit dependencies |
Usage of this package will automatically add the following additional NuGet packages
- ICG.AspNetCore.Utilities - Used to provide the IUrlSlugProvider for one overload in the ICloudStorageProvider implementation
- Azure.Storage.Blobs - Used to actually communicate with Azure.
Detailed information can be found in the XML Comment documentation for the objects, we are working to add to this document as well.
To adhere to Microsoft API standards the application has been updated to require the usage of a Storage Connection String, rather than a Account Name and Access Key.