AzureBlobStorage Connector - CreateFile/DeleteFile - Id, relationship with Azure Storage Blobs client library for .NET

廉价感情. 提交于 2021-01-29 09:27:03

问题


I have a powerapp using the AzureBlobStorage Connector(the connector) . However, this app has to interact with data that is being bulk uploaded using the Azure Storage Blobs client library for .NET (the api).

When you create a blob using the connector you get and Id which can then be used to Delete the blob.

However, when creating blobs with the api I cannot see how I can get that ID (you just use the blobid which is the filename). Hence data that is being bulk created cannot be deleted in the Power App.

The connector returns a BlobMetadata object when calling CreateFile.

The api returns a BlobContentInfo when calling UploadBlob. This metadata object does not contain an Id or anything matching the format of the BlobMetadata.ID.

Does anyone know how I can get this Id from the API?


回答1:


You could get Blob metadata from BlobProperties.Metadata. This is the document about setting and retrieving metadata using .Net.

// Get a reference to a container named "sample-container" and then create it
BlobContainerClient container = new BlobContainerClient(connectionString, containerName);

// Get a reference to a blob named "sample-file" in a container named "sample-container"
BlobClient blob = container.GetBlobClient(blobName);
await ReadBlobMetadataAsync(blob);

// Retrieve metadata
public static async Task ReadBlobMetadataAsync(BlobClient blob)
{
    try
    {
        // Get the blob's properties and metadata.
        BlobProperties properties = await blob.GetPropertiesAsync();

        Console.WriteLine(properties.BlobType);
        Console.WriteLine("Blob metadata:");
        

        // Enumerate the blob's metadata.
        foreach (var metadataItem in properties.Metadata)
        {
            Console.WriteLine($"\tKey: {metadataItem.Key}");
            Console.WriteLine($"\tValue: {metadataItem.Value}");
        }
    }
    catch (RequestFailedException e)
    {
        Console.WriteLine($"HTTP error code {e.Status}: {e.ErrorCode}");
        Console.WriteLine(e.Message);
        Console.ReadLine();
    }
}

You could also get metadata using Azure-CLI, see here.



来源:https://stackoverflow.com/questions/63984830/azureblobstorage-connector-createfile-deletefile-id-relationship-with-azure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!