Open Closed

No BLOB Storage provider was registered! At least one provider must be registered to be able to use the BLOB Storing System. #4259


User avatar
0
trina.thompson created
  • ABP Framework version: v6.0.1
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

I have a solution with several modules added (one of them is called Core). In Core.Domain I have an entity called Attachments (Attachments are files that users can upload to the system). In Core.Domain I have AttachmentDataSeederContributor where I seed one attachment. As part of this seed data, I have a need to save the file contents in my seed data to blob storage.

When I run DBMigrator, my data seeds as expected. However, when I attempt to run my tests, I receive the following error for all tests: Message:  Volo.Abp.AbpInitializationException : An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module PlatformNext.Core.CoreTestBaseModule, PlatformNext.Core.TestBase, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null: An exception was thrown while activating PlatformNext.Core.Attachments.AttachmentDataSeederContributor -> λ:Volo.Abp.BlobStoring.IBlobContainer -> Volo.Abp.BlobStoring.BlobContainer1[[Volo.Abp.BlobStoring.DefaultContainer, Volo.Abp.BlobStoring, Version=6.0.1.0, Culture=neutral, PublicKeyToken=null]].. See the inner exception for details. ---- Autofac.Core.DependencyResolutionException : An exception was thrown while activating PlatformNext.Core.Attachments.AttachmentDataSeederContributor -> λ:Volo.Abp.BlobStoring.IBlobContainer -> Volo.Abp.BlobStoring.BlobContainer1[[Volo.Abp.BlobStoring.DefaultContainer, Volo.Abp.BlobStoring, Version=6.0.1.0, Culture=neutral, PublicKeyToken=null]]. -------- Autofac.Core.DependencyResolutionException : An exception was thrown while invoking the constructor 'Void .ctor(Volo.Abp.BlobStoring.IBlobContainerFactory)' on type 'BlobContainer`1'. ------------ Volo.Abp.AbpException : No BLOB Storage provider was registered! At least one provider must be registered to be able to use the BLOB Storing System.


7 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    No BLOB Storage provider was registered! At least one provider must be registered to be able to use the BLOB Storing System.

    Hi,

    You need to configure a BLOB Storage provider: https://docs.abp.io/en/abp/latest/Blob-Storing#blob-storage-providers

  • User Avatar
    0
    trina.thompson created

    No BLOB Storage provider was registered! At least one provider must be registered to be able to use the BLOB Storing System.

    Hi,

    You need to configure a BLOB Storage provider: https://docs.abp.io/en/abp/latest/Blob-Storing#blob-storage-providers

    It is configured in the WebModule.

    private void ConfigureBlobStorage(ServiceConfigurationContext context, IConfiguration configuration)
        {
            var env = context.Services.GetHostingEnvironment();
    
            Configure<AbpBlobStoringOptions>(options =>
            {
                options.Containers.ConfigureDefault(container =>
                {
                    //use database blob storage for development convenience, use Azure in production
                    if (env.IsDevelopment())
                    {
                        container.UseDatabase();
                    }
                    else
                    {
                        container.UseAzure(azure =>
                        {                        
                            azure.ConnectionString = configuration["AzureBlobProviderConfiguration:ConnectionString"];
                            azure.ContainerName = configuration["AzureBlobProviderConfiguration:ContainerName"] ?? "default";
                            azure.CreateContainerIfNotExists = bool.TryParse(configuration["AzureBlobProviderConfiguration:CreateContainerIfNotExists"], out bool createContainerIfNotExists) ? createContainerIfNotExists : true;
                        });
                    }
                });
            });
        }
    
  • User Avatar
    0
    trina.thompson created

    No BLOB Storage provider was registered! At least one provider must be registered to be able to use the BLOB Storing System.

    Hi,

    You need to configure a BLOB Storage provider: https://docs.abp.io/en/abp/latest/Blob-Storing#blob-storage-providers

    It appears that it needs this configuration somewhere in tests in order to work. Where should that go?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    It is configured in the WebModule. It appears that it needs this configuration somewhere in tests in order to work. Where should that go?

    Hi,

    DbMigrator and Web are two applications, you should to configuration it in the DbMigrator project too.

  • User Avatar
    0
    trina.thompson created

    DbMigrator is working without issue and is seeding data, including blob storage data, as expected.

    The issue is only occurring when running the automated tests. I am specifically looking for guidance on working with blob storage from the test projects.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Ok, so you need to configure it in the test project. for example: https://github.com/abpframework/abp/blob/dev/framework/test/Volo.Abp.BlobStoring.Azure.Tests/Volo/Abp/BlobStoring/Azure/AbpBlobStoringAzureTestModule.cs#L42

  • User Avatar
    0
    trina.thompson created

    I was able to solve the issue by adding the below to my EntityFrameworkCoreTestModule: new BlobStoringDbContext( new DbContextOptionsBuilder<BlobStoringDbContext>().UseSqlite(connection).Options ).GetService<IRelationalDatabaseCreator>().CreateTables();

    in the CreateDatabaseAndGetConnection method.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09