Search code examples
azureazure-functionssnapshotazure-blob-storageazure-storage-account

How to use an Azure blob-only storage account with Azure Functions - Trying to create blob snapshot


I'm trying to set up a function to take a snapshot of a blob container every time a change is pushed to it. There is some pretty simple functionality in Azure Functions to do this, but it only works for general purpose storage accounts. I'm trying to do this with a blob only storage account. I'm very new to Azure so I may be approaching this all wrong, but I haven't been able to find much helpful information. Is there any way to do this?


Solution

  • As @joy-wang mentioned, the Azure Functions Runtime requires a general purpose storage account.

    A general purpose storage account is required to configure the AzureWebJobsStorage and the AzureWebJobsDashboard settings (local.settings.json or Appsettings Blade in the Azure portal):

    {
      "IsEncrypted": false,
      "Values": {
        "AzureWebJobsStorage": "my general purpose storage account connection string",
        "AzureWebJobsDashboard": "my general purpose storage account connection string",
        "MyOtherStorageAccountConnectionstring": "my blob only storage connection string"
      }
    }
    

    If you want to create a BlobTrigger Function, you can specify another connection string and create a snapshot everytime a blob is created/updated:

    [FunctionName("Function1")]
    public static async Task Run([BlobTrigger("test-container/{name}",
            Connection = "MyOtherStorageAccountConnectionstring")]CloudBlockBlob myBlob,
            string name, TraceWriter log)
    {
        log.Info($"C# Blob trigger function Processed blob\n Name:{name}");
        await myBlob.CreateSnapshotAsync();
    }