I'm trying to use ImageSharp.web for image processing using .net Core. After testing with an image stored in wwwroot, which successfully worked, I'm now trying to process images that are stored in Azure Blob storage and I'm not being successful, getting "The server responded with a status of 404 ()" (Not found).
I've followed the Sixlabors tutorials and I can't get an image result on:
https://localhost:44344/X/foto-teste10515264.jpg -> X is the container name.
I've got the following configurations in startup.cs:
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorPages();
services.AddImageSharp()
.SetRequestParser<QueryCollectionRequestParser>()
.Configure<AzureBlobStorageImageProviderOptions>(options =>
{
// The "BlobContainers" collection allows registration of multiple containers.
options.BlobContainers.Add(new AzureBlobContainerClientOptions
{
ConnectionString = "DefaultEndpointsProtocol=https;AccountName=***;AccountKey=***;EndpointSuffix=core.windows.net",
ContainerName = "X"
});
})
.SetCache<PhysicalFileSystemCache>()
.SetCacheHash<CacheHash>()
.AddProvider<AzureBlobStorageImageProvider>()
.AddProcessor<ResizeWebProcessor>()
.AddProcessor<FormatWebProcessor>()
.AddProcessor<BackgroundColorWebProcessor>();
}
And my Configure:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseDefaultFiles();
app.UseImageSharp();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
});
}
I've since changed the URL to https://localhost:5001/X/foto-teste10515264.jpg and now I get net::ERR_CONNECTION_REFUSED
I solved it by using port 44344 and clearing the providers before. Thanks anywawy!