【问题标题】:Not getting all the methods from Azure Storage package未从 Azure 存储包中获取所有方法
【发布时间】:2018-02-07 20:29:34
【问题描述】:

所以我尝试在 Azure 存储中使用队列,因此我创建了一个控制台应用程序并在 NuGet 中添加了 WindowsAzure.Storage 包。然后我把这段代码放进去,它会为我创建一个队列。

    static void Main(string[] args)
    {
        string connection = "myConnectionString......";
        CloudStorageAccount storageAcc = CloudStorageAccount.Parse(connection);

        CloudQueueClient queueClient = storageAcc.CreateCloudQueueClient();
        CloudQueue queue = queueClient.GetQueueReference("myQueue");
        queue.CreateIfNotExistsAsync();
        Console.ReadKey();
    }

但是应该有一个我可以调用的非异步版本

        queue.CreateIfNotExists();

但 Visual Studio 2017 并未将 CreateIfNotExists 识别为 CloudQueue 的成员。

如果我尝试构建它会引发编译错误。

我似乎缺少很多非 Async 方法,例如 AddMessage 和 GetMessage 知道是什么原因造成的吗?

【问题讨论】:

  • 如果您使用的是 .Net Core,那么这是一个已知问题。 .Net Core 版本的 SDK 中未实现同步方法。
  • 是否有任何关于将 SDK 与 .NET Core 结合使用的文档或博客文章?
  • 与 .Net 相同。您唯一需要记住的是仅使用异步方法。

标签: c# visual-studio azure


【解决方案1】:

我似乎缺少很多非 Async 方法,例如 AddMessage 和 GetMessage 知道是什么原因造成的吗?

根据您的描述,我想您创建了一个 Console .NET Core 项目。我创建了一个简单的演示,结果类似于this。这个 .NET Core 项目只支持异步方法。现在没有这些同步方法。所以你没有错过这些方法。

如果你只想使用 queue.CreateIfNotExists() 等同步方法,我建议你可以选择 Console App(.NET Framework) 项目并安装 WindowsAzure.Storage 包再试一次。或者您可以参考这个article 来使用 Azure 队列。

【讨论】:

    猜你喜欢
    • 2021-04-18
    • 1970-01-01
    • 2020-12-18
    • 1970-01-01
    • 1970-01-01
    • 2021-02-22
    • 2020-09-05
    • 2016-06-02
    • 2013-08-11
    相关资源
    最近更新 更多