问题
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