I am trying to access container via oauth token in azure blob storage with tensorflow
The following python code works
from azure.storage.blob import BlobClient, ContainerClient
url = "https://{}.blob.core.windows.net".format(
"my_storage_name"
)
from azure.identity import ClientSecretCredential
token_credential = ClientSecretCredential(
"tenant_id,
"ad_application_id",
"ad_application_secret"
)
blob_client = ContainerClient(account_url=oauth_url, container_name="container_name", credential=token_credential)
bloblist = blob_client.list_blobs()
for x in bloblist:
print(x)
However when I tried to hack this in tensorflow io
std::string tenantId = "";
std::string activeDirectoryApplicationId = "";
std::string activeDirectoryApplicationSecret = "";
auto clientCertificateCredential
= std::make_shared<Azure::Identity::ClientSecretCredential>(tenantId, activeDirectoryApplicationId, activeDirectoryApplicationSecret);
std::string storageContainerUrl = "https://mystorage.blob.core.windows.net/mycontainer";
auto blobclient = std::make_shared<Azure::Storage::Blobs::BlobContainerClient>(storageContainerUrl, clientCertificateCredential);
for (auto blobPage = (*blobclient).ListBlobs();
blobPage.HasPage();
blobPage.MoveToNextPage())
{
for (auto& blob : blobPage.Blobs)
{
// Below is what you want to do with each blob
TF_VLog(3, "blob: %s\n", blob.Name);
}}
I run into
RuntimeError: Fail to get a new connection for: httpslogin.microsoftonline.com. Problem with the SSL CA cert (path? access rights?)
even after changing to http in url
os.environ['TF_AZURE_STORAGE_USE_HTTP'] = '1'
I tried locally with the c++ code as well without tensorflow io, and it works, is there special setting within tensorflow I need to change?
if you have set the TF_AZURE_STORAGE_USE_HTTP
to '1', then you are using local emulator ie azurite
To use the azure blob storage you will have to set it to the key which is available in portal.
Refer this tensorflow docs regarding blob storage.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.