English 中文(简体)
Azure queue trigger failing on deployment, strange connection string requirement
原标题:

On deployment, a function app with a new queue trigger is firing an error that looks like this:

The  MyQueueTrigger  function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method  MyQueueTrigger . Microsoft.Azure.WebJobs.Extensions.Storage.Queues: Storage account connection string  AzureWebJobsAzureStorageConnectionString  does not exist. Make sure that it is a defined App Setting.

In code (C#), this trigger looks like this:

       [FunctionName("MyQueueTrigger")]
        public async Task Run(
                [QueueTrigger(
                    StorageConstants.MyQueue,
                    Connection = StorageConstants.AzureStorageConnectionString
                )]
                string myQueueItem,
                ILogger log)
        {
         ...
        }

The constants described here are literally: "%MyQueue%" and "AzureStorageConnectionString", respectively

Post-deployment, navigating in the Azure portal to this function -> Code + Test shows the following:

{
  "generatedBy": "Microsoft.NET.Sdk.Functions.Generator-4.1.1",
  "configurationSource": "attributes",
  "bindings": [
    {
      "type": "queueTrigger",
      "connection": "AzureStorageConnectionString",
      "queueName": "%MyQueue%",
      "name": "myQueueItem"
    }
  ],
  "disabled": false,
  "scriptFile": "../bin/MyNamespace.Functions.dll",
  "entryPoint": "Redacted"
}

This function gets disabled on deployment/startup after the error above. The phrase "AzureWebJobsAzureStorageConnectionString" does not appear anywhere in my function app, although AzureWebJobsStorage and AzureStorageConnectionString are both required default settings. Where could I look for this concatenated string looking thing?

Adding a configuration with this Name does resolve the issue, but I don t want to commit to doing this ongoing.

Also, this queue trigger works as expected when running locally. local.settings.json looks like this:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "AzureStorageConnectionString": "DefaultEndpointsProtocol=https;AccountName=redacted;AccountKey=redacted==;EndpointSuffix=core.windows.net",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "fooBlobContainer": "foo-blob-container",
    "myQueue":  "my-queue"
  },
  "AppSettings": {
    "KeyVaultSecrets": {
      "KeyVaultName": "https://redacted.vault.azure.net",
      "DataWarehouseConnection": "DataWarehouseConnection",
      "LoggingDBConnectionString": "LoggingDBConnectionString",
      "ClientId": "redacted"
    },
    "myServiceAPI": {
      "BaseURL": "redacted.azurewebsites.net/"
    }
  }
}
问题回答

Whenever you create an azure function app, the function runtime requires a storage account to run from. This storage account will be used by your function app to manage all your triggers and other BAU files. As you ve not set this value for your function app, it fails. Just point your existing storage account to this configuration and it should work.

The AzureStorageConnectionString your are referring to is just the config you use for the storage account your queue resides it. You can either use the same storage account for the AzureWebJobsAzureStorageConnectionString config to hold the func app files there, or use a separate storage account for the func app.

Bottom line is : your func app requires a storage account in order to run/work. :)

See : https://learn.microsoft.com/en-us/azure/azure-functions/functions-app-settings#azurewebjobsstorage enter image description here





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签