0
votes

I have a function that is triggered from a queue and towards the end of the function it sends it to an Azure table. I am running this locally now and it has stopped working locally (was pointing to Azure env) and I don't know why. The error is generated before the function is entered and it is:

VehicleCatalog.Storage.AzureTable: Value cannot be null.
Parameter name: <TableName>.

I have a tableStorage section in local.settings

"tableStorage": {
    "connectionString": "",
    "<tableName>": ""
  },

and I have the table mentioned there created in the emulator. I have also moved that setting to the Values section but still no joy. I am not sure it is that table the process is falling over on.

Are there any other tables required to support this that I don't know about or does any one know of something I don't to make this run using the emulator.

2

2 Answers

0
votes

Download the Azure Storage Explorer and look for the table.

https://docs.microsoft.com/en-us/azure/vs-azure-tools-storage-manage-with-storage-explorer?tabs=windows

•Table names must be unique within an account.

•Table names may contain only alphanumeric characters.

•Table names cannot begin with a numeric character.

•Table names are case-insensitive.

•Table names must be from 3 to 63 characters long.

•Some table names are reserved, including "tables". Attempting to create a table with a reserved table name returns error code 404 (Bad Request).

0
votes

If it's a V2 azure function, you can try use below code and settings:

The code of my function.cs:

using System;
using System.Collections;
using System.Collections.Generic;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
using Microsoft.WindowsAzure.Storage.Table;

namespace FunctionApp18
{
    public static class Function1
    {
        [FunctionName("Function1")]
        public static void Run([QueueTrigger("myqueue-items", Connection = "AzureWebJobsStorage")]string myQueueItem, 
            [Table("test1")]ICollector<Test> outTable,
            ILogger log)
        {
            log.LogInformation($"C# Queue trigger function processed: {myQueueItem}");
            outTable.Add(new Test() {
                PartitionKey = "mypartition_key",
                RowKey = Guid.NewGuid().ToString(),
                QuoteText = myQueueItem
            });
        }
    }

    //define the table entity
    public class Test : TableEntity
    {
        public string QuoteText { get; set; }
    }   

}

Here is the local.settings.json:

{
    "IsEncrypted": false,
    "Values": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=true",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet"
    }
}

When testing, it works fine and write entity to table storage on emulator:

enter image description here