Is there any difference between azure storage of local environment and with online storage

181 Views Asked by At

Is there any difference between azure storage of local environment and with online storage.

We have created a Azure local storage using storage emulator. Refer the below link.

https://learn.microsoft.com/en-us/azure/storage/common/storage-use-emulator

https://medium.com/oneforall-undergrad-software-engineering/setting-up-the-azure-storage-emulator-environment-on-windows-5f20d07d3a04

But, we are unable to access the files for (read files) Azure local storage. Refer the below code.

            const string accountName = "devstoreaccount1";// Provide the account name

            const string key = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==";// Provide the account key

            var storageCredentials = new StorageCredentials(accountName, key);

            var cloudStorageAccount = new CloudStorageAccount(storageCredentials, true);


            // Connect to the blob storage
            CloudBlobClient serviceClient = cloudStorageAccount.CreateCloudBlobClient();
            // Connect to the blob container
            CloudBlobContainer container = serviceClient.GetContainerReference(**"container name"**);
            container.SetPermissionsAsync(new
     BlobContainerPermissions
            {
                PublicAccess =
                  BlobContainerPublicAccessType.Blob
            });
            // Connect to the blob file
            CloudBlockBlob blob = container.GetBlockBlobReference("sample.txt");
            blob.DownloadToFileAsync("sample.txt", System.IO.FileMode.Create);

            // Get the blob file as text
            string contents = blob.DownloadTextAsync().Result;

The above code works correctly for reading the files in online Azure storage. Anyone suggest how to resolve the issue in reading the files in local Azure storage.

1

There are 1 best solutions below

0
On

The document explains clearly about differences between the Storage Emulator and Azure Storage.

If you would like to access the local storage, you could call this API. For more details about URI, see here.

Get http://<local-machine-address>:<port>/<account-name>/<resource-path>