Where is the “tableClient.CreateTableIfNotExist” in AzureStorage library v2?

你离开我真会死。 提交于 2019-12-12 08:26:48

问题


In Windows Azure Storage, we used to do this to create a table :

var tableClient = account.CreateCloudTableClient();
tableClient.CreateTableIfNotExist(TableName);

I just downloaded the last version of the azure storage library (v2), and my previous code doesn't work anymore :

'Microsoft.WindowsAzure.Storage.Table.CloudTableClient' does not contain a definition for 'CreateTableIfNotExist' and no extension method 'CreateTableIfNotExist' accepting a first argument of type 'Microsoft.WindowsAzure.Storage.Table.CloudTableClient' could be found.

What is the good code in v2 ?


回答1:


In v2 there's some breaking changes. Here's the new code :

    var tableClient = account.CreateCloudTableClient();
    // Create the table if it doesn't exist.
    var cloudTable = tableClient.GetTableReference(TableName);
    cloudTable.CreateIfNotExists();

Some good inputs :

  • How to use the Table Storage Service : in v1.7 and in v2.
  • Windows Azure Storage Client Library 2.0 Breaking Changes & Migration Guide from the Azure Storage Team


来源:https://stackoverflow.com/questions/13647479/where-is-the-tableclient-createtableifnotexist-in-azurestorage-library-v2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!