Error while trying to write in Azure Tables ('' is not a valid value for a partition key or row key)

Question:

I am a beginner in Azure. I’m trying to add a row in Azure Tables storage using Python.
I followed the simple example of Microsoft documentation :

https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-table-output?tabs=in-process%2Cstorage-extension&pivots=programming-language-python#example

However, I get this error : Microsoft.Azure.WebJobs.Extensions.Tables: ” is not a valid value
for a partition key or row key
and I don’t see the table created in my MicrosoftAzure Storage Explorer.

I already have a functional azure function with a queueTrigger as an input binding. So, I added an ouptut binding Table in the configuration file "function.json":

{
    "scriptFile": "__init__.py",
    "bindings": [
     {
      "name": "dataSetId",
      "type": "queueTrigger",
      "direction": "in",
      "queueName": "local-toprep",
      "connection": "AzureWebJobsStorage"
     },
     {
      "type": "table",
      "direction": "out",
      "name": "message",
      "tableName": "messages",
      "partitionKey": "message",
      "connection": "AzureWebJobsStorage"
     }
   ]
}

And in my main function ,I added my table "message" in the arguments and I added those lines :

rowKey = str(uuid.uuid4())
data = {
         "Name": "Output binding message",
         "PartitionKey": "message",
         "RowKey": rowKey
        }
message.set(json.dumps(data))

Thank you in advance for your help 🙂

Asked By: Sarah

||

Answers:

So, my problem was in host.js file.
Azure table works only in version 2.

{
  "version": "2.0",
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[2.*, 3.0.0)"
  }
}
Answered By: Vladimir Mironov