November Happy Hour will be moved to Thursday December 5th.

Azure Blob Storage for local dev

Vote:
 

I would like to use my own Azure Blob storage for local development. 

I have considered the documentation here - https://docs.developers.optimizely.com/content-management-system/docs/how-to-add-azure-blob-provider-to-your-net-core-application 
i.e.

#

using EPiServer.ServiceLocation;
using Microsoft.Extensions.DependencyInjection;
using System;

namespace SampleBlob {
  public class Startup {
    public void ConfigureServices(IServiceCollection services) {
      services.AddAzureBlobProvider("Azure", o => {
        o.ConnectionString = {
          The Azure storage connection string
        };
        o.ContainerName = {
          The container name
        };
      });
    }
  }
}


... but this does not even compile :( 

I've tried the following in my startup class (note, that's not the real connection string). This compiles...

services.AddAzureBlobProvider(o =>
{
        o.ConnectionString =
                "DefaultEndpointsProtocol=https;AccountName=my_account_name;AccountKey=my_account_key;EndpointSuffix=core.windows.net";
        o.ContainerName = "my_container_name";
 });

... but when the app starts, I get an exception with message 'No valid combination of account information found."

I have checked in Azure Storage Explorer and the connection string works. So I must be missing a step in configuring this in Optimizely.

Any advice would be greatly appreciated



#328290
Edited, Aug 29, 2024 0:05
Vote:
 

Hi Daniel

The sample code in the doc seems pseudo code.

You code looks fine to me and works fine (see attached). I'm able to upload images to my azure blob container via CMS. It might be something else caused the issue. Have tried this with Alloy template? 

#328323
Aug 29, 2024 6:30
Vote:
 

Hi Vince! 

Thanks for taking a look and confirming that the code I shared should work. Per your suggestion, I tried this in a different optimizely solution, and yes, it works. However, for some reason it still does not work in one of my sites. So weird!

What does work is setting it up like so:

This in app Settings:

"ConnectionStrings": {
  "EPiServerAzureBlobs": "DefaultEndpointsProtocol=https;AccountName=my_account_name;AccountKey=my_account_key;EndpointSuffix=core.windows.net",
},
"EpiServer": {
  "Cms": {
    "BlobProvidersOptions": {
      "DefaultProvider": "azureBlobs",
      "Providers": {
        "azureBlobs": "EPiServer.Azure.Blobs.AzureBlobProvider, EPiServer.Azure"
      }
    },
    "AzureBlobStorage": {
      "ContainerName": "my_container_name"
    }
  }
}

.. and simply this, in startup.cs

services.AddAzureBlobProvider();
#328654
Sep 02, 2024 0:09
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.