Media Library files not uploading to azure blob storage

Anthony Ativo asked on September 26, 2016 12:06

I have a problem on my Website project kentico. It's not uploading the files in the azure blob storage. I already followed the instructions written in the docs. I already put the azure credentials in the web config file. But still not working. It store the files in the local system not in the azure.

Recent Answers


Brenden Kehren answered on September 26, 2016 16:24

Have you checked the event log for errors/issues? Have you tried using something like CloudBerry to connect to Blob storage to ensure your credentials work and permissions are set properly?

1 votesVote for this answer Mark as a Correct answer

Anthony Ativo answered on September 26, 2016 16:43

Sir I already checked the event log but the event log said that it was successfullly uploaded to the file system directory. I also placed a break point on the attribute in the code but also the code was fired when the application starts.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on September 26, 2016 18:13

Then I'd suggest running through the setup again and making sure you have all the pieces setup properly. If your website is hosted in Azure then you might want to also do a restart on the website after you have made your changes.

Again, check you're able to access blob using the credentials using CloudBerry too.

1 votesVote for this answer Mark as a Correct answer

Anthony Ativo answered on September 27, 2016 03:56

Thanks sir. I'll try. I update you once my problem was solve.

0 votesVote for this answer Mark as a Correct answer

Anthony Ativo answered on September 27, 2016 11:16

Sir do I need to add this code <add key="CMSExternalStorageName" value="azure" /> in the web.config file ? Because my only goal was to use azure as my media library blob storage ?

0 votesVote for this answer Mark as a Correct answer

Thomas Begley answered on January 9, 2017 02:42 (last edited on January 9, 2017 02:44)

Hi was there ever I resolution for this? I have the same issue.

I can access blob storage using CloudBerry, no file are available

I have checked the logs when uploading an image and there are no errors (see event log detail below)

I have restarted the application and can see the code getting hit on initialize.

Yet when I upload it stores the image at the local path, rather than blob storage.

Running Kentico 9 .net 4.6.2 locally attached to Azure SQL database, just trying to set media items only for blob storage

I have all required setting in web.config

<add key="CMSAzureAccountName" value="vectorwebstoragedev" />
<add key="CMSAzureSharedKey" value="################" />
<add key="AzureContainerMediaPath" value="vectordev" />

EVENT LOG DETAIL on upload

Event ID: 38421

Event type: Information

Event time: 1/9/2017 1:41:14 PM

Source: Media file

Event code: CREATEOBJ

User ID: 53

User name: administrator

IP address: 127.0.0.1

Description: Create Media file 'right_icons-01'

Site name: ######

Machine name: THOMASBE-LT002

Event URL: /CMSModules/MediaLibrary/CMSPages/MultiFileUploader.ashx?InstanceGuid=ff44bc26-f763-4da6-952e-f9d4fb72e464&filename=right_icons-01.png&FilesCount=1&ResizeArgs=0;0;0&complete=true&StartByte=0&MediaLibraryArgs=MediaLibraryID%7c21%7cMediaFolderPath%7c%7cMediaFileID%7c0%7cIsMediaThumbnail%7cFalse%7cMediaFileName%7c%7cHash%7c0c00a268387bc3103e1eefc3f3458bbd23d013b43cb5ec1118010c2f0c4d1b0a&AdditionalParameters=SourceType%7cMediaLibraries%7cParentElementID%7clibraries%7cIsInsertMode%7cTrue%7cAfterSaveJavascript%7c%7cTargetFolderPath%7c%7cTargetFileName%7c%7cIncludeNewItemInfo%7cTrue%7cOnlyImages%7cFalse%7cRaiseOnClick%7cFalse%7cTargetAliasPath%7c%7cTargetCulture%7c%7cEventTarget%7c%7cHash%7cc97c152adc7db50a06a1f930c891ba0dbdc3b67b93b040243eb82788158597ca&CurrentFileIndex=1&FileSize=7085&AllowedExtensions=pdf;doc;docx;ppt;pptx;xls;xlsx;htm;html;xml;bmp;gif;jpg;jpeg;png;wav;wma;wmv;mp3;mp4;mpg;mpeg;mov;avi;swf;rar;zip;txt;rtf;webm;ogg;wav;ogv;oga;svg|Hash|520b9b3da2b69e40e3b0f747283d446be07a199da012675abd5babc7983fc319

URL referrer: https://kentico/CMSModules/MediaLibrary/Tools/Library_Edit_Files.aspx?objectid=21&tabselemid=m_c_plc_lt_ctl00_VerticalTabs_l_t_tabsElem

User agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36

CUSTOM CLASS

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CMS.IO;
using CMS.Base;

[CustomStorage]
public partial class CMSModuleLoader
{
    private class CustomStorageAttribute : CMSLoaderAttribute
    {
        /// <summary>
        /// The system executes the Init method of the CMSModuleLoader attributes when the application starts.
        /// </summary>
        public override void Init()
        {
            // Creates a new StorageProvider instance
            AbstractStorageProvider mediaProvider = new StorageProvider("Azure", "CMS.AzureStorage");

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

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

            // Maps a directory to the provider
            StorageHelper.MapStoragePath($"~/{Vector.PublicWeb.Common.Helpers.SettingsHelper.System.AzureContainerMediaPath}/Media/", mediaProvider);
        }
    }
}
0 votesVote for this answer Mark as a Correct answer

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