fortedigital / EpiResponsivePicture

Smart responsive images in Episerver with ImageResizing.Net and Focal point
MIT License
6 stars 3 forks source link

Error when blob container does not exits #47

Closed tomaszmadeyski closed 1 year ago

tomaszmadeyski commented 1 year ago

Once I configure package to be used with AzureBlobStorageCache like this:

services.AddForteEpiResponsivePicture(o =>
{
    o.ConnectionString = configuration.GetValue<string>("ConnectionStrings:EPiServerAzureBlobs");
    o.ContainerName = "container-name"
});

and the container with name of container-name does not exist I'm getting an error when trying to access an image that should be resized (for example with width GET parameter), ie https://localhost:53650/contentassets/632a4571069040fbad30c72ea8426f90/bench.jpg?width=130

error:

An unhandled exception occurred while processing the request.
RequestFailedException: The specified container does not exist.
RequestId:970fab7f-f17e-4041-8bac-ef85ea508d53
Time:2023-03-15T11:28:29.355Z
Status: 404 (The specified container does not exist.)
ErrorCode: ContainerNotFound

Content:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Error>
<Code>ContainerNotFound</Code>
<Message>The specified container does not exist.
RequestId:970fab7f-f17e-4041-8bac-ef85ea508d53
Time:2023-03-15T11:28:29.355Z</Message>
</Error>

BTW when working on this issue it would be nice to add some sort of validation of options, because if I forget to pass for example container-name:

services.AddForteEpiResponsivePicture(o =>
{
    o.ConnectionString = configuration.GetValue<string>("ConnectionStrings:EPiServerAzureBlobs");
});

I will get nasty error (without proper error message) when trying to access image