add azure storage to Kentico 11

Peter Mogilnitski asked on January 23, 2018 23:28

I have blob container and I am trying to configuring Azure storage in Kentico 11. For basic execution of initialization code, I only need to register a "code-only" module through the API. So basically I added CMSAzureAccountName and CMSAzureSharedKey to web.config and created App_Code/CustomInit.cs like this:

// Registers the custom module into the system
[assembly: RegisterModule(typeof(CustomInitializationModule))]

    public class CustomInitializationModule : Module
        // Module class constructor, the system registers the module under the name "CustomInit"
        public CustomInitializationModule()
            : base("CustomInit")

        // Contains initialization code that is executed when the application starts
        protected override void OnInit()

                EventLogProvider.LogInformation("AzureStorage", "ModuleInstalled");

                // Creates a new StorageProvider instance for Azure
                var mediaProvider = StorageProvider.CreateAzureStorageProvider();

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

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

                // Maps a directory to the provider
                StorageHelper.MapStoragePath("~/corporatesite/media/", mediaProvider);

For some reason I don't see "ModuleInstalled" in the event log. Am I missing somehtings for a "code-only" module registration.

Recent Answers

Trevor Fayas answered on January 24, 2018 05:06

Is this directly in the App_Code folder or is it in a separate project, and if it's in the separate project do you have the using



tag in the AssemblyInfo.cs file? I've missed that before.

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on January 24, 2018 13:41

Trevor, it is directly in app folder, it is webapp project. I have a default K11 installation and I am playing with it. I did exactly as it was in the help.

0 votesVote for this answer Mark as a Correct answer

Saurav Kumar answered on January 25, 2018 10:57

Hi Peter,
Can you please try the below line for EVentLog

    using (new CMSActionContext { LogEvents = true })
                    EventLogProvider.LogEvent(EventType.INFORMATION, "AzureStorage", "AzureStorage", "ModuleInstalled");
0 votesVote for this answer Mark as a Correct answer

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