Azure blob files not showing in Kntico medi library

Dinesh Negi asked on August 15, 2019 07:01

Hi ,

I have just started Kentio task and very new in kentico.

My task is, to restore prod environment in dev. My kentico project is hosted in Azure. In prod Azure blob is using for holding media files and working fine, but when i restored prod db in dev, media file table containing all folders and media library also showing all those folders as library (Folders seems no relation with blob folders, all are just showing, because database table have those values), but all are blank. in blob all folders have some media files. As per Kentico post, i have added both keys in web.config.

key="CMSAzureAccountName" value="myblob" />

key="CMSAzureSharedKey" value="******" />

also code:

    AbstractStorageProvider mediaProvider = new StorageProvider("Azure", "CMS.AzureStorage");

    // Specifies the target container
    mediaProvider.CustomRootPath = "com2017media";// This is blob container

    // Makes the container publicly accessible
    mediaProvider.PublicExternalFolderObject = true;

    // Maps a directory to the provider
    StorageHelper.MapStoragePath("~/Acm/Media/", mediaProvider); // blob files path is: "myblob\com2017media\acm\media\folders"(each folders containing media files). 
    Code deployed successfully, no error in event log.
    But still showing empty media libraries and if i upload manually something it's Direct path showing my site url , not blob url.

Thanks, Dinesh

Recent Answers


Brenden Kehren answered on August 15, 2019 15:00

The CustomRootPath property always needs to be set to "cmsstorage". Unfortunately, there isn't a way around this because that's how Kentico is setup. Also, I'm assuming you only have 1 site running, but if you had 2 or more, you'd need to initialize it for all sites.

0 votesVote for this answer Mark as a Correct answer

Jordan Walters answered on August 15, 2019 16:09

I am having the same exact issue except my Kentico instance has 2 sites. When you say initialize for all sites, how would you go about doing this? I do not see anything in the docs that would help me find this answer.

https://docs.kentico.com/k9/custom-development/working-with-physical-files-using-the-api/configuring-file-system-providers/configuring-azure-storage

Thank you!

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on August 15, 2019 16:23

Jordan,

The code I have for multiple sites is as follows:

var sites = SiteInfoProvider.GetSites().WhereEquals("SiteIsOffline", 0).And().WhereEquals("SiteStatus", "RUNNING");
// loop through all sites in this instance and create a new provider for each one
foreach (SiteInfo site in sites)
{
    // Creates a new StorageProvider instance
    AbstractStorageProvider mediaProvider = new StorageProvider("Azure", "CMS.AzureStorage");

    // Specifies the target container
    mediaProvider.CustomRootPath = "cmsstorage";

    // Makes the container publicly accessible
    mediaProvider.PublicExternalFolderObject = true;

    // Maps a directory to the provider
    string path = string.Format("/{0}/media", site.SiteName);
    StorageHelper.MapStoragePath("~" + path, mediaProvider);
}
2 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.