azure-sdk-for-cpp/sdk/tables/azure-data-tables/samples/tables_getting_started.cpp
gearama e6eaee7244
Tables cleanup work (#6181)
* conn and names key out

* all work except get set acl

* samples

* dqwd

* extra space

* record transactions, because test proxy

* tty

* clang and samples working , assets json

* fds

* samples , and remove APIs

* dsds

* acct name

* dsfds

* oopsie

* dasdas

* fdsfsd

* clangs

* account key for sas

* kjhdsakjhdkjashdjkwash

* dssfsd

* ggd

* Update sdk/tables/azure-data-tables/samples/CMakeLists.txt

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

* put back unused env in CI

* Update sdk/tables/azure-data-tables/src/table_clients.cpp

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

* Update sdk/tables/azure-data-tables/src/table_clients.cpp

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

* fdg

* fds

* update samples and readme

* sdjkfhsdkj

* Update sdk/tables/azure-data-tables/README.md

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

* Update sdk/tables/azure-data-tables/test/ut/table_client_test.hpp

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

* Update sdk/tables/azure-data-tables/test/ut/table_client_test.hpp

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

* update remove namespaces

---------

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>
2024-11-13 12:55:59 -08:00

41 lines
1.1 KiB
C++

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include <azure/data/tables.hpp>
#include <azure/identity.hpp>
#include <cstdio>
#include <iostream>
#include <stdexcept>
#include <thread>
const std::string TableName = "sample1";
// The following environment variables must be set before running the sample.
// * ACCOUNT_NAME: The name of the storage account.
std::string GetAccountName() { return std::getenv("ACCOUNT_NAME"); }
std::string const GetServiceUrl()
{
return std::string{"https://" + GetAccountName() + ".table.core.windows.net/"};
}
int main()
{
auto credential = std::make_shared<Azure::Identity::DefaultAzureCredential>();
auto tableServiceClient = Azure::Data::Tables::TableServiceClient(GetServiceUrl(), credential);
// 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;
}