Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Reference feedback]: Insert Table Entity as Entity - Set Column Type #30974

Open
shanerowley-ds opened this issue Mar 7, 2025 · 4 comments
Open
Assignees
Labels
Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Storage az storage
Milestone

Comments

@shanerowley-ds
Copy link

shanerowley-ds commented Mar 7, 2025

Type of issue

Other (describe below)

Reference command name

So this works

$entity = @()
$entity += "PartitionKey=$partitionKey"
$entity += "RowKey=$rowKey"
$entity += "Content=$content"
az storage entity insert -t $tableName --account-name $storageAccount --auth-mode login -e @entity

Feedback

But how do I include the odata.type per column in the entity? e.g. "Content=$content Content@odata.type@odata.type=Edm.Int32"? I've tried a few different things but nothing seems to work.

Page URL

No response

Content source URL

#23932

Author

No response

Document Id

No response

@shanerowley-ds shanerowley-ds added the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Mar 7, 2025
@yonzhan
Copy link
Collaborator

yonzhan commented Mar 7, 2025

Thank you for opening this issue, we will look into it.

@microsoft-github-policy-service microsoft-github-policy-service bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. Storage az storage labels Mar 7, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Mar 7, 2025
@shanerowley-ds shanerowley-ds changed the title [Reference feedback]: https://github.com/Azure/azure-cli/issues/23932 [Reference feedback]: Insert Table Entity as Entity - Set Column Type Mar 7, 2025
@yonzhan yonzhan added this to the Backlog milestone Mar 7, 2025
@calvinhzy
Copy link
Member

Hi @shanerowley-ds , I have added instruction here https://github.com/Azure/azure-cli/pull/30534/files
Can you try this az storage entity insert --connection-string $connectionString --entity PartitionKey=AAA RowKey=BBB Content=0152 Content@odata.type=Edm.String --if-exists merge --table-name MyTable

@shanerowley-ds
Copy link
Author

How do I insert a column that is type "odata.type=Edm.Int32" but who's value is null?

For context, my script inserts entities from a CSV that was exported manually from a template table. But the 'Int32' columns for some rows have a null or empty string values in the CSV.

I need something that works along the lines of

$output = az storage entity insert `
    --connection-string $connectionString  `
    --table-name $tableName `
    --entity `
        PartitionKey=$apiConfig `
        RowKey=$apiConfigId `
        Content01=$Content01 Content01@odata.type=Edm.String `
        Content02=$Content02 Content02@odata.type=Edm.String `
        Content03=$Content03 Content03@odata.type=Edm.String `
        Content05=$Content05 Content05@odata.type=Edm.String `
        Content06=$Content06 Content06@odata.type=Edm.String `
        Content07=$Content07 Content07@odata.type=Edm.String `
        Content08=$Content08 Content08@odata.type=Edm.String `
        Content09=$Content09 Content09@odata.type=Edm.String `
        Content10=$Content10 Content10@odata.type=Edm.String `
        Content11=$Content11 Content11@odata.type=Edm.String `
        Content12=$Content12 Content12@odata.type=Edm.String `
        Content13=$Content13 Content13@odata.type=Edm.String `
        Content15=$Content15 Content15@odata.type=Edm.String `
        Content16=$Content16 Content16@odata.type=Edm.String `
        If (-not [string]::IsNullOrEmpty($Content20)) { `
            Content17=$Content17 Content20@odata.type=Edm.In32 `
        } `
        If (-not [string]::IsNullOrEmpty($Content20)) { `
            Content18=$Content18 Content20@odata.type=Edm.In32 `
        } `
        If (-not [string]::IsNullOrEmpty($Content20)) { `
            Content19=$Content19 Content20@odata.type=Edm.In32 `
        } `
        If (-not [string]::IsNullOrEmpty($Content20)) { `
            Content20=$Content20 Content20@odata.type=Edm.In32 `
        } `
    --if-exists replace

I did create a solution by using a Dynamic Script in PowerShell: Invoke-Expression $cmd

It works, but my script is pretty complicated in comparison.

@calvinhzy
Copy link
Member

Is there an issue with a mix match of multiple types? I think if an empty value is needed, you can use string as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Storage az storage
Projects
None yet
Development

No branches or pull requests

4 participants