admin管理员组文章数量:1221994
I am using azure sdk for cpp, and I am trying to connect to private endpoint.
I have ADLS gen2 storage account, with app registration with secret, so I am able to connect to the ADLS with OAuth.
How to edit this example so it is able to connect to the private endpoint?
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include <azure/identity/client_secret_credential.hpp>
#include <azure/service/client.hpp>
#include <iostream>
// The following environment variables must be set before running the sample.
// * AZURE_TENANT_ID: Tenant ID for the Azure account.
// * AZURE_CLIENT_ID: The Client ID to authenticate the request.
// * AZURE_CLIENT_SECRET: The client secret.
std::string GetTenantId() { return std::getenv("AZURE_TENANT_ID"); }
std::string GetClientId() { return std::getenv("AZURE_CLIENT_ID"); }
std::string GetClientSecret() { return std::getenv("AZURE_CLIENT_SECRET"); }
int main()
{
try
{
// Step 1: Initialize Client Secret Credential.
auto clientSecretCredential = std::make_shared<Azure::Identity::ClientSecretCredential>(
GetTenantId(), GetClientId(), GetClientSecret());
// Step 2: Pass the credential to an Azure Service Client.
Azure::Service::Client azureServiceClient("serviceUrl", clientSecretCredential);
// Step 3: Start using the Azure Service Client.
azureServiceClient.DoSomething();
std::cout << "Success!" << std::endl;
}
catch (const Azure::Core::Credentials::AuthenticationException& exception)
{
// Step 4: Handle authentication errors, if needed
// (invalid credential parameters, insufficient permissions).
std::cout << "Authentication error: " << exception.what() << std::endl;
return 1;
}
return 0;
}
本文标签: Azure SDK connection to private endpointStack Overflow
版权声明:本文标题:Azure SDK connection to private endpoint - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1739290166a2156655.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论