Azure表存储: can't create a table with a CloudTableClient instance

标签 azure azure-storage azure-java-sdk

我在这里关注 Azure 关于 Java API 的基本教程:https://www.windowsazure.com/en-us/develop/java/how-to-guides/table-service/#CreateTable

但遇到以下错误:

cannot find symbol

symbol : method createTableIfNotExists(java.lang.String)

location: class com.microsoft.windowsazure.services.table.client.CloudTableClient

完整的小程序(从Azure教程复制):

import com.microsoft.windowsazure.services.core.storage.*;
import com.microsoft.windowsazure.services.table.client.*;
import com.microsoft.windowsazure.services.table.client.TableQuery.*;

public class AzureTableWrite {
  public static void main(String[] args) {
    // Define the connection-string with your values
    final String storageConnectionString =
        "DefaultEndpointsProtocol=http;" +
        "AccountName=skivvy;" +
        "AccountKey=foobar";

    // Retrieve storage account from connection-string
    CloudStorageAccount storageAccount =
        CloudStorageAccount.parse(storageConnectionString);

    // Create the table client.
    CloudTableClient tableClient = storageAccount.createCloudTableClient();

    // Create the table if it doesn't exist.
    String tableName = "people";
    tableClient.createTableIfNotExists(tableName);
  }
}

有人遇到过同样的问题吗?如有任何帮助,我们将不胜感激!

最佳答案

正如我在 MSDN 论坛 ( http://social.msdn.microsoft.com/Forums/en-US/windowsazuredata/thread/78c12f97-4209-41a1-86d6-267f5e9f51f6 ) 上的回复中提到的,您使用的示例似乎存在问题。

请改用这个:

    CloudTableClient tableClient = storageAccount.createCloudTableClient();
    CloudTable table = tableClient.getTableReference("people");
    table.createIfNotExists();

希望这有帮助。

关于Azure表存储: can't create a table with a CloudTableClient instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12668170/

相关文章:

c# - AzureADB2CDefaults 已过时,如何替换它?

powershell - 如何在Azure网站上远程运行PowerShell

azure - Elastic Sc​​ale 拆分/合并工具意外失败

c# - Azure 存储,使用 BlobRequestOptions 而不使用 CloudBlobClient

azure - 使用 Azure Java SDK 获取资源组中的所有可用资源

azure - 使用 Java Spring 应用程序连接到 Azure 服务总线 - 超时

azure - 使用 Java SDK 生成 Azure Blob 存储的签名 URL

video - Azure 媒体服务 - 如何获取视频分辨率?

Azure 服务计划 - Web 应用程序在时间更改后无法运行

c# - Microsoft Azure 应用服务存储