Azure storage images not uploaded to ~/content/images.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
Hello, my site is running in an Azure Appservice and I am using Azure Blob Storage to store my images. When a user uploads ands save an image for a product, the thumbnails get generated in Azure Storage, but nothing is uploaded to ~/Content/Images. The product pictures will show on the site and the url used is the Azure storage URL, but after an appservice restart, the images are no longer available and default to the "no image" picture.

I've tried tracking this down and the image is added to the database via /Admin/Picture/AsyncUpload which returns something like


{"success":true,"pictureId":3035,"imageUrl":"https://myblobstorage.blob.core.windows.net/sitestorage/0003035_100.jpeg"}


And actually adds the file
0003035_100.jpeg
to Azure storage.

When clicking the Save button it then posts to the admin action
ProductController.ProductPictureAdd
.
The picture is being associated in the Product_Picture_Mapping table correctly.

I then click the add product picture and the image in azure storage is rename to
0003035_{seo_name}.jpeg



When PictureService.GetPictureUrl is called is tries to load the binary:

   string url = string.Empty;
            byte[] pictureBinary = null;
            if (picture != null)
                pictureBinary = LoadPictureBinary(picture);
            if (picture == null || pictureBinary == null || pictureBinary.Length == 0)
            {
                if (showDefaultPicture)
                {
                    url = GetDefaultPictureUrl(targetSize, defaultPictureType, storeLocation);
                }
                return url;
            }


Now, because AzurePictureService doesn't override LoadPictureBinary and the images are never placed on ~/content/images on the AppService, this always returns the default image url for images uploaded to azure after an application restart (I'm not sure why it works before application restart, I'm assuming the url is cached.)
7 years ago
Go to admin area > configuration > media settings. What is the value of "Pictures are stored into..." setting?

What is your site URL?
7 years ago
Pictures are stored on filesystem. The store url is (including the trailing slash)
shop.longaberger.com/


I'm using a custom domain for my Azure app service (shop.longaberger.com). SSL is enabled and the secure URL is
https://shop.longaberger.com/
7 years ago
Does it always happen when you restart the site?

Do you have multiple instances enabled in Azure?

Do you experience this issue when you set "Pictures are stored into..." to "database"?
7 years ago
It only happens when I restart the site and pictures have been uploaded between the last restart. If pictures are added and then I manually place images on disk in the Content\Images folder with the right ID naming, they show up after restart.

I am not using multiple instances, just one.

I haven't tried switching to Pictures are stored in the DB. It seems that the PictureController.AsyncUpload method temporarily adds the binary to the database (and that works), and then when the form is posted to ProductController.ProductPictureAdd, the binary is retrieved and then added to Azure storage, but because the StoreInDB setting is false, it removes the binary data before finally saving the entity back to the Picture table.
7 years ago
After some local testing I cannot reproduce this issue ("Pictures are stored into... file system"). All uploaded pictures are stored into /content/images/.

Try doing the same and debug PictureService class
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.