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() { base.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.
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
CMS; [assembly:AssemblyDiscoverable]
tag in the AssemblyInfo.cs file? I've missed that before.
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.
Hi Peter, Can you please try the below line for EVentLog
using (new CMSActionContext { LogEvents = true }) { EventLogProvider.LogEvent(EventType.INFORMATION, "AzureStorage", "AzureStorage", "ModuleInstalled"); }
Please, sign in to be able to submit a new answer.