azure-sdk-for-cpp/sdk/tables/azure-data-tables/samples/tables_getting_started.cpp
George Arama 84e4a81947
Api view comments (#5408)
* mroe quotes

* dssf

* listTables -> queryTables

* move create/delete to the tableservice

* one more batch

* small refactor, added default data types

* oops

* clangs

* table sas builder

* sas test

* cspell

* add more test

* cspell

* hjhjh

* clang

* rename table-> tables

* clang

* partition and row key

* clang why?

* constructors, update tests

* IT WORKSSSSS

* PR comments

* wqe

* ewr

* enum operator

* clang

* dsaada

* sada

* assets.json

* clang

* Update sdk/tables/azure-data-tables/inc/azure/data/tables/enum_operators.hpp

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

* Update sdk/core/azure-core/test/ut/string_test.cpp

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

* the = enums

* assert and remove empty

* compact string tests

* clangs

* complement

* azureSasCredentials

* PR cpmments

* some extra

* clang 11

---------

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>
2024-03-15 14:30:45 -07:00

50 lines
1.2 KiB
C++

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include <azure/data/tables.hpp>
#include <cstdio>
#include <iostream>
#include <stdexcept>
#include <thread>
std::string GetConnectionString()
{
const static std::string ConnectionString = "";
if (!ConnectionString.empty())
{
return ConnectionString;
}
const static std::string envConnectionString = std::getenv("STANDARD_STORAGE_CONNECTION_STRING");
if (!envConnectionString.empty())
{
return envConnectionString;
}
throw std::runtime_error("Cannot find connection string.");
}
using namespace Azure::Data::Tables;
const std::string TableName = "sample1";
int main()
{
auto tableServiceClient = TableServiceClient::CreateFromConnectionString(GetConnectionString());
auto tableClient = TableClient::CreateFromConnectionString(GetConnectionString(), TableName);
// create new table
tableServiceClient.CreateTable(TableName);
// query tables
auto tables = tableServiceClient.QueryTables();
// print table names
for (auto table : tables.Tables)
{
std::cout << table.TableName << std::endl;
}
// delete existing table
tableServiceClient.DeleteTable(TableName);
return 0;
}