Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jason D 67 posts 219 karma points
    Dec 11, 2023 @ 21:32
    Jason D
    0

    Using local Media folder when not in Production Environment

    Hi, I don't have the best of luck getting help on this forum, but anyhow, I have our Umbraco 12 site setup to use an Azure Blog Storage Container.

    I can't find information on setting the site to use the local /media folder instead, when developing locally. Or, is my only choice to create another Blog Container so that back-office testing of media images and files doesn't do anything to production versions?

    Thanks, Jason

  • Owain Jones 55 posts 384 karma points MVP 3x c-trib
    Dec 13, 2023 @ 18:00
    Owain Jones
    101

    If you comment out: .AddAzureBlobMediaFileSystem() and/or .AddAzureBlobImageSharpCache() in your startup.cs, Umbraco should use the local Media folder.

    You could automate this by adding an if statement to the ConfigureServices() method of your Startup.cs:

    public void ConfigureServices(IServiceCollection services)
    {
         var umbracoBuilder = services.AddUmbraco(_env, _config)
              .AddBackOffice()
              .AddWebsite()
              .AddComposers();
    
         if (!_env.IsDevelopment())
         {
              umbracoBuilder.AddAzureBlobMediaFileSystem()
                   .AddAzureBlobImageSharpCache();
         }
    
         umbracoBuilder.Build();
    }
    

    Here the blob storage middleware is only registered if you are not running the Development environment.

    (_env is IWebHostEnvironment, which should already be injected in your constructor)

  • Jason D 67 posts 219 karma points
    Dec 13, 2023 @ 18:39
    Jason D
    0

    Thank you! That's what I was looking for.

Please Sign in or register to post replies

Write your reply to:

Draft