From d3169082d78a167728a40fb35dd9add31e838641 Mon Sep 17 00:00:00 2001 From: maliming <6908465+maliming@users.noreply.github.com> Date: Thu, 11 Jun 2020 16:29:24 +0800 Subject: [PATCH 1/2] Document the Azure BLOB storage integration. Resolve #4299 --- docs/en/Blob-Storing-Azure.md | 68 ++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/docs/en/Blob-Storing-Azure.md b/docs/en/Blob-Storing-Azure.md index 9bf912c0d2..fb173722c0 100644 --- a/docs/en/Blob-Storing-Azure.md +++ b/docs/en/Blob-Storing-Azure.md @@ -1,3 +1,69 @@ # BLOB Storing Azure Provider -This feature will be available with v3.0! \ No newline at end of file +BLOB Storing Azure Provider can store BLOBs in [Azure Blob storage](https://azure.microsoft.com/en-us/services/storage/blobs/). + +> Read the [BLOB Storing document](Blob-Storing.md) to understand how to use the BLOB storing system. This document only covers how to configure containers to use a database as the storage provider. + +## Installation + +You can use dotnet cli to install [the package](https://www.nuget.org/packages/Volo.Abp.BlobStoring.Azure). + +````bash +dotnet add package Volo.Abp.BlobStoring.Azure +```` + +After installation, add `DepenedsOn` attribute of the `AbpBlobStoringAzureModule` module to your [module](Module-Development-Basics.md). + +Whenever you add a NuGet package to a project, also add the module class dependency. + +### Configuring the Containers + +Configuration is done in the `ConfigureServices` method of your [module](Module-Development-Basics.md) class, as explained in the [BLOB Storing document](Blob-Storing.md). + +**Example: Configure to use the azure storage provider by default** + +````csharp +Configure(options => +{ + options.Containerscontainer.UseAzure(azure => + { + azure.ConnectionString = "your azure connection string"; + azure.ContainerName = "your azure container name"; + azure.CreateContainerIfNotExists = false; + }); +}); +```` + +> See the [BLOB Storing document](Blob-Storing.md) to learn how to configure this provider for a specific container. + +## Options + +* **ConnectionString** (string): A connection string includes the authorization information required for your application to access data in an Azure Storage account at runtime using Shared Key authorization. Please refer to Azure documentation: https://docs.microsoft.com/en-us/azure/storage/common/storage-configure-connection-string + +* **ContainerName** (string): You can specify the container name in azure. If it is not specified, the `ContainerName` of the `BlobProviderArgs` will be used. However, please note that Azure has some rules for naming containers. A container name must be a valid DNS name, conforming to the [following naming rules](https://docs.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata#container-names). + +* Container-names rules: + - Container names must start or end with a letter or number, and can contain only letters, numbers, and the dash (-) character. + - Every dash (-) character must be immediately preceded and followed by a letter or number; consecutive dashes are not permitted in container names. + - All letters in a container name must be lowercase. + - Container names must be from 3 through 63 characters long. + +* **CreateContainerIfNotExists** (bool): Default value is `false`, If a container does not exist in azure, `AzureBlobProvider` will try to create it. Please refer to the naming rules mentioned above. + + +## Azure Blob Name Calculator + +Azure Blob Provider organizes BLOB name and implements some conventions. The full name of a BLOB is determined by the following rules by default: + +* Appends `host` string if [current tenant](Multi-Tenancy.md) is `null` (or multi-tenancy is disabled for the container - see the [BLOB Storing document](Blob-Storing.md) to learn how to disable multi-tenancy for a container). +* Appends `tenants/` string if current tenant is not `null`. + +```csharp +var blobName = CurrentTenant.Id == null + ? $"host/{args.BlobName}" + : $"tenants/{CurrentTenant.Id.Value.ToString("D")}/{args.BlobName}"; +``` + +### Other Services + +* `AzureBlobProvider` is the main service that implements the Azure BLOB storage provider, if you want to override/replace it via [dependency injection](Dependency-Injection.md) (don't replace `IBlobProvider` interface, but replace `AzureBlobProvider` class). \ No newline at end of file From ab724699c8e239214dd1888b94319386c27ed444 Mon Sep 17 00:00:00 2001 From: maliming <6908465+maliming@users.noreply.github.com> Date: Thu, 11 Jun 2020 16:30:29 +0800 Subject: [PATCH 2/2] Update Blob-Storing-Azure.md --- docs/en/Blob-Storing-Azure.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/Blob-Storing-Azure.md b/docs/en/Blob-Storing-Azure.md index fb173722c0..edc0b58a8e 100644 --- a/docs/en/Blob-Storing-Azure.md +++ b/docs/en/Blob-Storing-Azure.md @@ -2,7 +2,7 @@ BLOB Storing Azure Provider can store BLOBs in [Azure Blob storage](https://azure.microsoft.com/en-us/services/storage/blobs/). -> Read the [BLOB Storing document](Blob-Storing.md) to understand how to use the BLOB storing system. This document only covers how to configure containers to use a database as the storage provider. +> Read the [BLOB Storing document](Blob-Storing.md) to understand how to use the BLOB storing system. This document only covers how to configure containers to use a Azure blob as the storage provider. ## Installation @@ -66,4 +66,4 @@ var blobName = CurrentTenant.Id == null ### Other Services -* `AzureBlobProvider` is the main service that implements the Azure BLOB storage provider, if you want to override/replace it via [dependency injection](Dependency-Injection.md) (don't replace `IBlobProvider` interface, but replace `AzureBlobProvider` class). \ No newline at end of file +* `AzureBlobProvider` is the main service that implements the Azure BLOB storage provider, if you want to override/replace it via [dependency injection](Dependency-Injection.md) (don't replace `IBlobProvider` interface, but replace `AzureBlobProvider` class).