1

I am using Azure Queue Trigger for my Function. But the Infrastructure (e.g., Queue, Blob storage) for that Function is not in place. So, the Azure storage connection string will also be empty. But while running the Function App, it is expecting the connection string and throwing an exception at runtime. Even though I disabled the Function using the [Disable("MY_TIMER_DISABLED")] attribute.

Exception

System.ArgumentNullException: Value cannot be null. (Parameter 'connectionString')

The reason I found is that while running the Function App, the Startup is invoking all the Functions, and then it is reading the properties associated with those Functions. So, at the initial invoke, it is expecting the Queue, Connection String, etc., even though the function is Disabled.

public class UserDataRetryFunction()
{
   [FunctionName(UserDataRetryFunction)]
   [Disable("AzureWebJobs.UserDataRetryFunction.Disabled")]
   public async Task RetryData([QueueTrigger("%RetryQueueName%", Connection = "%ConnectionStrings:StorageConnectionString%")])
   {
      // Process the Queue Message 
   }
}

appsetings.json

{
  "IsEncrypted": false,
  "RetryQueueName" : "retry-response-queue",
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true", 
    "AzureWebJobs.UserDataRetryFunction.Disabled": "true"
  },
  "ConnectionStrings": {
   "StorageConnectionString" : "",
  }
}

I have tried many documents and sites, but could not able to find the solution.

Some of the links I’ve evaluated are stated below.

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
ahamed
  • 11
  • 3
  • Your AppSettings file looks like a mangled local.settings.json file. Remove the `Values` property and keep the subproperties, though you might have to convert it to nested sections, ie `“AzureWebJobs“: { "UserDataRetryFunction": { "Disabled": true } } ` – pinkfloydx33 Jun 06 '21 at 18:50

1 Answers1

0

The behaviour you're setting is expected. In Azure disabling a function only means disabling the trigger as you have done and as detailed in the link you referenced. This disables the trigger but doesn't stop the entire function.

If you wish to stop the entire function you can do so in the Azure Portal.

You can also use the AZ CLI as follows:

az functionapp stop --name MyFunctionApp --resource-group MyResourceGroup

With PowerShell you can stop a function with the following command:

Stop-AzFunctionApp -Name MyAppName -ResourceGroupName MyResourceGroupName

Mark
  • 21,067
  • 14
  • 53
  • 71