So I have two questions here which I am trying to achieve using C# in Azure Functions:
I am suppose to copy blobs from one container to another in same storage account whenever a new blob or directory arrives in the source container. the new blob in destination should have a different name.
I started with my code in Visual Studio using Azure function SDK and I have come up till here:
namespace CopyBlobs
{
public static class CopyBlob
{
[FunctionName("Function1")]
public static void Run([BlobTrigger("SourceContainerName/{name}", Connection = "AzureWebJobsStorage")]CloudBlockBlob myBlob, IDictionary<string, string> metadata, string name, ILogger log)
{
log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n ContentMD5: {myBlob.Properties.ContentMD5} \n Size: {myBlob.Properties.Length}");
log.LogInformation($"metadata count {metadata.Count}");
{
var destinationContainer = myBlob.Container.ServiceClient.GetContainerReference(metadata["Destination"]);
destinationContainer.CreateIfNotExistsAsync();
CloudBlockBlob outputBlob = destinationContainer.GetBlockBlobReference(name);
outputBlob.StartCopyAsync(myBlob);
}
}
}
}
Q1) I get the error on line var destinationContainer = myBl... as Destination key is not defined. I would like to know where and what to define in the Destination key and if anyone can show me an example (I believe it should be my destination container name in localsetting.json file but I am struggling to define it correctly).
Q2) The destination blob which is copied should have a different name, it will be something like the original name manipulated to base64. How can I achieve that?
I am new to do this Azure function thing so i am going slow but hoping to get some quick help here.
Thanks