pro*_*eus 3 azure c#-4.0 cloud-storage
我正在开发一个 webjob 来将项目放入队列 (C#)。我是新手,正在学习一些教程,但我不知道如何CloudStorageAccount为本地开发存储创建 a 的实例。在我的配置文件中,我有这个
<add name="AzureWebJobsStorage" connectionString="UseDevelopmentStorage=true;" />Run Code Online (Sandbox Code Playgroud)
并且在我的 C# 方法中,我想创建一个我的实例CloudStorageAccount,就像这样
var account = new CloudStorageAccount(new StorageCredentials(accountName, accountKey), true);
Run Code Online (Sandbox Code Playgroud)
什么都要accountName和accountKey对本地存储的发展?
本地开发存储的 accountName 和 accountKey 应该是什么?
Account name: devstoreaccount1
Account key: Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
Run Code Online (Sandbox Code Playgroud)
参考:https : //docs.microsoft.com/en-us/azure/storage/storage-use-emulator
但是,您将无法使用以下代码,因为存储模拟器仅适用于 HTTP 并侦听自定义端口。
var account = new CloudStorageAccount(new StorageCredentials(accountName, accountKey), true);
Run Code Online (Sandbox Code Playgroud)
正确的做法是像下面这样:
var storageCredentials = new StorageCredentials("devstoreaccount1", "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==");
var blobEndpoint = new Uri("http://127.0.0.1:10000");
var queueEndpoint = new Uri("http://127.0.0.1:10001");
var tableEndpoint = new Uri("http://127.0.0.1:10002");
var acc = new CloudStorageAccount(storageCredentials, blobEndpoint, queueEndpoint, tableEndpoint, null);
Run Code Online (Sandbox Code Playgroud)
或者为简单起见,您可以简单地执行以下操作:
var acc = CloudStorageAccount.Parse("UseDevelopmentStorage=true");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1639 次 |
| 最近记录: |