I am a java microservices person - not much into .NET.
With the help from StackOverflow community .. I was able to get a working code for my problem.
The code is w
If you want to use c# as script, you must remove the namespace (as the error describes) and also add a Run method:
//PS: review which package will you use
#r "Microsoft.WindowsAzure.Storage"
#r "Azure.Storage.Blobs"
#r "Microsoft.Azure.Storage.Blob"
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Models;
using Microsoft.Azure.Storage.Blob;
using Microsoft.Extensions.Logging;
using Microsoft.WindowsAzure.Storage;
using System;
public static void Run(CloudQueueMessage myQueueItem, ILogger log)
{
log.LogInformation($"C# Queue trigger function processed: {myQueueItem.AsString}");
await CopyBlob();
}
static async Task CopyBlob()
{
BlobServiceClient blobServiceClient = new BlobServiceClient(storageconnstring);
BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(containerName);
BlobClient blobClient = containerClient.GetBlobClient(filename);
var blobUri = blobClient.Uri;
BlobContainerClient targetContainerClient = blobServiceClient.GetBlobContainerClient("demo-copy");//This is the container where we want to copy the blob
BlobClient targetBlobClient = targetContainerClient.GetBlobClient(filename);
await targetBlobClient.StartCopyFromUriAsync(blobUri);
}
if you want to keep with your local development experience, you'd better use Azure Functions template in your visual studio. More info:
https://docs.microsoft.com/en-us/azure/azure-functions/functions-develop-vs
https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-csharp
https://docs.microsoft.com/en-us/azure/azure-functions/functions-dotnet-class-library