Cannot access blobs in Azure Emulator

439 views Asked by At

Some computers connect to the Azure Emulator blob and others do not, and I can't tell the difference.

code is the process of downloading the blob data. The following errors have been encountered.

Err : Service Unavailable Microsoft.Azure.Storage.StorageException: Service Unavailable

The code is as follows

    CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(connectionString);
    CloudBlobClient blobClient = cloudStorageAccount.CreateCloudBlobClient();
    CloudBlobContainer container = blobClient.GetContainerReference(containerName);
    CloudBlockBlob blob = container.GetBlockBlobReference(filepath);
    blob.DownloadToStreamAsync(st)

We believe that it is not the code or the way the storage is built, as we know that there are computers that do not have errors with the same code.

The Emulator is Microsoft Azure Emulator and the development environment is VisualStudio 2019. Storage itself can be accessed, but when debugging in VisualStudio, it does not connect.

I am wondering if there is some setting in VisualStudio, I am looking for it but it has been stagnant for about a week and I am having trouble.

We would like to know of any possible causes. This is a corporate event, and there are proxy servers, etc. Emulator is local, so I don't think it will be affected.

・Avoidance of Proxy. ・Confirmation that blob storage is connected using VisualStudio's CloudExplorer. ・Confirmation that VisualStudio CloudExplorer can upload files to blob storage. ・Confirmation that StorageAccount etc. are correct.


P.S. Hi, Venkatesan-san Sorry for the delay, I was on vacation.

I have tried Azurite. As a result, I got the following error.

Service request failed. Status: 503 (Service Unavailable)

For the endpoints, we use blob connection destinations written in MS-DOCS.

https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=visual-studio

DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;

I am using .Net Core3.1.

1

There are 1 answers

1
Venkatesan On

According to MS-DOCS , Azure Storage Emulator for development and testing is deprecated. so, Microsoft recommends that you use the Azurite emulator for local development with Azure Storage.

For Azure Functions or ASP.NET projects start Azurite automatically. For .NET Console Apps, there is no option to run the Azurite Automatically. We need to start it manually from the Command Prompt.

C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\Extensions\Microsoft\Azure Storage Emulator\

enter image description here

If you need to download files from azure blob storage through visual studio you can use Azure-storage-blob- 12.14.1 NuGet package.

Code:

using Azure.Storage.Blobs;

    class program
    {
         public static void Main()
        {
            var connectionString = <Connection string>;
            var downloadPath = "< path of folder upto filename >";
            var containerName = "test";
            var blobName = "file.json";
            using Stream file = File.OpenWrite(Path.Combine(downloadPath));
            BlobClient blobClient = new BlobClient(connectionString,containerName,blobName);
            blobClient.DownloadTo(file);
            Console.WriteLine("file downloaded");
        }
    }

Console:

enter image description here