user152949
user152949

Reputation:

List Azure table storage table metadata having only table name

How can I get metadata - like the table's property names - about a Azure Table Storage's table when I only have the table name to begin with? This is what I have so far:

    /// <summary>
    /// List the tables in this storage account
    /// </summary>
    IEnumerable<string> ListAllTables()
    {
        var storageAccount = GetStorageAccount();

        // Create service client for credentialed access to the Table service.
        var tableClient = new CloudTableClient(storageAccount.TableEndpoint.ToString(),
            storageAccount.Credentials);

        return tableClient.ListTables();
    }

    IEnumerable<string> ListTableMetadata(tableName)
    {
        // Now, just how can I list all the table metadata?
    }

    void main()
    {
        foreach (var tableName in ListAllTables())
        {
            Console.WriteLine("Table: " + tableName);

            // List all the table metadata
            Console.WriteLine("Properties: " + ListTableMetadata(tableName));
        }
    }

Upvotes: 0

Views: 980

Answers (1)

Serdar Ozler
Serdar Ozler

Reputation: 3802

Azure Storage Table service does not enforce any schema for tables. So, two entities in the same table may have different sets of properties. If you would like to query all entities without knowing their properties beforehand, I would recommend looking at DynamicTableEntity, which returns all properties of an entity as key-value pairs.

Upvotes: 2

Related Questions