Azure Storage not used

Claudio Bley asked on September 22, 2021 21:53

Hi.

We are using .NET Core and have configured the Azure storage provider. We have upgraded our Xperience instance from hotfix 38 to 44 a few days ago.

Now we noticed that all images from the media library have vanished.

Uploading a new image results in a new file on the server in the folder C:\home\site\wwwroot\MediaLibraries\medialib.

Requesting the file by its getmedia / permanent URL from the admin instance works, but requesting it on the live app fails with a 404 since the live app tries to fetch the image from Azure storage.

Our settings:

Storage
 --------------------------------------------------

 Media libraries folder: ~/MediaLibraries/ (inherited)

 Use site-specific subfolders for custom media libraries folder: False (inherited)

 Media file hidden folder: __thumbnails (inherited)

 Media file thumbnail suffix: _thumbnail (inherited)

We have the following code in CMSModules/Azure/AzureStorageInitializer.cs, both in the live app and the admin app:

using CMS;
using CMS.Base;
using CMS.DataEngine;
using CMS.IO;

// Registers the custom module into the system
[assembly: RegisterModule(typeof(AzureStorageInitializer))]
public class AzureStorageInitializer : Module
{
    // Module class constructor, the system registers the module under the name "CustomInit"
    public AzureStorageInitializer()
        : base("CustomInit")
    {
    }

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

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

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

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

        // Maps the local media library directory to the storage provider
        StorageHelper.MapStoragePath("~/MediaLibraries/", mediaProvider);
    }
}

Also, CMSAzureAccountName as well as CMSAzureSharedKey are set up correctly, AFAICS.

There are no errors / exceptions visible in application insights on Azure.

What could be the reason for this behavior? How can I further debug this?

Thanks in advance!

Correct Answer

Claudio Bley answered on October 5, 2021 10:37

FTR, I have extracted the AzureStorageInitializer module into its own assembly, which fixed the problem apparently.

I did not find out the real reason why it stopped working in the first place...

0 votesVote for this answer Unmark Correct answer

Recent Answers


Dmitry Bastron answered on September 23, 2021 06:41

Hi Claudio,

Was it working correctly on 38 hotfix? If so, and the hotfix installation was the only difference made, I'd probably suggest reaching out to Kentico support regarding this issue.

The symptoms are, your AzureStorageInitializer module is not loading correctly in .NET Core application. Could you add logging to the module and check if it is executed at all?

0 votesVote for this answer Mark as a Correct answer

Claudio Bley answered on September 23, 2021 08:04 (last edited on September 23, 2021 08:06)

Was it working correctly on 38 hotfix? If so, and the hotfix installation was the only difference made, I'd probably suggest reaching out to Kentico support regarding this issue.

Yes, it was working before. And, the hotfix was the only relevant change in the last few days. (there were only CI Repository updates, nothing else)

The symptoms are, your AzureStorageInitializer module is not loading correctly in .NET Core application. Could you add logging to the module and check if it is executed at all?

It is the other way around: it works fine in the .NET Core app, no longer works in the Admin App. I'll try to add logging...

But isn't there some logging in Xperience itself? Could I enable tracing to see which modules are loaded?

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on September 23, 2021 08:10

In Kentico Event Log for each start of the app there is a message with Event code: STARTAPP, in the details of this message there should be a list of all modules loaded, you can check it I think.

0 votesVote for this answer Mark as a Correct answer

Claudio Bley answered on September 23, 2021 08:59

Thanks! Unfortunately I have no logs from before the hotfix update.

Looking through the events, searching for EventCode:STARTAPP and Description DOES NOT CONTAIN CMS.AspNetCore.Platform (to restrict searching for the admin app - machine name is really unhelpful on Azure, since all machines are called the same, such as "pd0sdwk00000M") I can only find events that do not contain "CustomInit".

BTW, do you know how I can customize the machine name in the event log?

0 votesVote for this answer Mark as a Correct answer

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