Skip to content

Unable to enter insert string into Azure Table storage which contains a space via the Azure CLI, even when quoted #27654

Closed
@anwtn

Description

@anwtn

Describe the bug

I'm using the Azure CLI (azure-cli 2.53.0) to insert an entity into an Azure Storage table. The following (ZSH) command works and the entity is inserted.

entity=$(cat <<-END
PartitionKey=${job_number} \
RowKey=available \
author="Aaron+Newton" \
xyz="abc"
END
)

az storage entity insert \
  --account-name "$STORAGE_ACCOUNT" \
  --table-name "$TABLE_NAME" \
  --entity $entity \
  --auth-mode login \
  --if-exists merge

However, if I remove the + and replace it with a space on the author key-value pair, the command fails:

entity=$(cat <<-END
PartitionKey=${job_number} \
RowKey=available \
author="Aaron Newton" \
xyz="abc"
END
)

az storage entity insert \
  --account-name "$STORAGE_ACCOUNT" \
  --table-name "$TABLE_NAME" \
  --entity $entity \
  --auth-mode login \
  --if-exists merge

It seems that any space is treated as a delimited for the command itself, even when the string is quoted. When I review the output of the first command, I can see that it stored the literal "Aaron+Newton" against the author property in the table.

There seems to be some workaround using Powershell and the REST API directly (or I can just write a simple program), but has anyone managed to solve this using the Azure CLI?

Related command

az storage entity insert

Errors

The first two lines are some debug from my script.

c7506390696f:~/source/myorg/aaron-infra-sandbox# ./scripts/myapph_seed_event_table.sh 
<entity> -> PartitionKey=WPDBUTZ RowKey=available author="Aaron Newton" xyz="abc"

The error is:

dictionary update sequence element #3 has length 1; 2 is required

Issue script & Debug output

Note: you'll need to set the variables STORAGE_ACCOUNT and TABLE_NAME.

entity=$(cat <<-END
PartitionKey=WPDBUTZ \
RowKey=available \
author="Aaron Newton" \
xyz="abc"
END
)

az storage entity insert \
  --account-name "$STORAGE_ACCOUNT" \
  --table-name "$TABLE_NAME" \
  --entity $entity \
  --auth-mode login \
  --if-exists merge

Expected behavior

A quoted string should be allowed to include spaces, or there needs to be some documentation on how to do this. I would be shocked if "that's unsupported" was the answer here given that this is a common use case.

Environment Summary

azure-cli: 2.53.0

Additional context

The documentation is very sparse on entity examples, so if this is supported, it might be a case of improving the docs.
https://learn.microsoft.com/en-us/cli/azure/storage/entity?view=azure-cli-latest

Metadata

Metadata

Labels

Auto-AssignAuto assign by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamStorageaz storagecustomer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions