【问题标题】:Is there any difference between azure storage of local environment and with online storage本地环境的天蓝色存储和在线存储有什么区别
【发布时间】:2021-03-06 21:24:36
【问题描述】:

本地环境的天蓝色存储和在线存储有什么区别。

我们使用存储模拟器创建了一个 Azure 本地存储。请参考以下链接。

https://docs.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

但是,我们无法访问(读取文件)Azure 本地存储的文件。参考以下代码。

            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;

以上代码可以正常读取在线 Azure 存储中的文件。任何人都建议如何解决读取本地 Azure 存储中文件的问题。

【问题讨论】:

    标签: azure azure-blob-storage azure-storage-emulator


    【解决方案1】:

    document 清楚地解释了存储模拟器和 Azure 存储之间的区别。

    如果您想访问本地存储,可以调用此API。有关 URI 的更多详细信息,请参阅here

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

    【讨论】:

      猜你喜欢
      • 2020-12-21
      • 2013-07-21
      • 1970-01-01
      • 2013-08-05
      • 1970-01-01
      • 2018-04-20
      • 2014-09-18
      • 2014-03-08
      • 1970-01-01
      相关资源
      最近更新 更多