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

az storage entity insert forcing a string to int32 #30377

Open
JackBruceShell opened this issue Nov 18, 2024 · 4 comments
Open

az storage entity insert forcing a string to int32 #30377

JackBruceShell opened this issue Nov 18, 2024 · 4 comments
Assignees
Labels
ARM az resource/group/lock/tag/deployment/policy/managementapp/account management-group Auto-Assign Auto assign by bot Auto-Resolve Auto resolve 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. 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

@JackBruceShell
Copy link

Describe the bug

String is being sent as a "property" to be inserted into a property, when viewing in the portal the string "0152" has been converted to type int32 and shows "052"

Related command

    az storage entity insert --if-exists merge --entity PartitionKey=$partitionKey RowKey=$rowKey $property --table-name $tableName --account-name $storageAccountName --auth-mode login

Errors

No errors, just incorrect behaviour

Issue script & Debug output

Script:

az account set --subscription XXX
$path="./testFile.json"
$object = Get-Content $path | ConvertFrom-Json
$storageAccountName = "XXX"
$tableName = "XXX"
for ($i = 0; $i -lt $object.Count; $i++) {
$obj = $object[$i]
$partitionKey = $obj.PartitionKey
$rowKey = $obj.RowKey
$obj.PSObject.Properties.Remove('PartitionKey')
$obj.PSObject.Properties.Remove('RowKey')
Write-Host "PartitionKey: $partitionKey"
Write-Host "RowKey: $rowKey"
Write-Host "Modified Object:"
$obj | ConvertTo-Json -Depth 5
$ht2 = @{}
$obj.psobject.properties | Foreach { $ht2[$.Name] = $.Value }
Write-Host "ht2: $ht2"
Write-Host "Object: $obj"

foreach ($entry in $ht2.GetEnumerator()) {
    $key = $entry.Key
    $value = $entry.Value
    $valueType = $value.GetType()
    ## Check value of the property
    Write-Host "Value type: $value"
    Write-Host $value.GetType()

    $property = $entry.Key + "=" + $entry.Value
    Write-Host "Property: $property"
    # Write-Host $property
    az storage entity insert --if-exists merge --entity PartitionKey=$partitionKey RowKey=$rowKey $property --table-name $tableName --account-name $storageAccountName --auth-mode login
}

}

Output:
PartitionKey: C2S_CROSS_GSAP_OU_MAP
RowKey: DEC-0154
Modified Object:
{
"CROSS_OUCode": "DEC",
"CROSS_TPPCode": "0154",
"CROSS_SSN": "",
"GSAP_OUCode": "DE01"
}
ht2: System.Collections.Hashtable
Object: @{CROSS_OUCode=DEC; CROSS_TPPCode=0154; CROSS_SSN=; GSAP_OUCode=DE01}
Value type: 0154
System.String
Property: CROSS_TPPCode=0154
{
"date": "2024-11-18T16:20:12+00:00",
"etag": "W/"datetime'2024-11-18T16%3A20%3A12.3183423Z'"",
"version": "2019-02-02"
}
Value type: DEC
System.String
Property: CROSS_OUCode=DEC
{
"date": "2024-11-18T16:20:13+00:00",
"etag": "W/"datetime'2024-11-18T16%3A20%3A13.7894865Z'"",
"version": "2019-02-02"
}
Value type:
System.String
Property: CROSS_SSN=
{
"date": "2024-11-18T16:20:14+00:00",
"etag": "W/"datetime'2024-11-18T16%3A20%3A15.148696Z'"",
"version": "2019-02-02"
}
Value type: DE01
System.String
Property: GSAP_OUCode=DE01
{
"date": "2024-11-18T16:20:16+00:00",
"etag": "W/"datetime'2024-11-18T16%3A20%3A17.0475922Z'"",
"version": "2019-02-02"
}
PartitionKey: C2S_CROSS_GSAP_OU_MAP
RowKey: DEF-0154
Modified Object:
{
"CROSS_OUCode": "DEF",
"CROSS_TPPCode": "0154",
"CROSS_SSN": "",
"GSAP_OUCode": "DE01"
}
ht2: System.Collections.Hashtable
Object: @{CROSS_OUCode=DEF; CROSS_TPPCode=0154; CROSS_SSN=; GSAP_OUCode=DE01}
Value type: 0154
System.String
Property: CROSS_TPPCode=0154
{
"date": "2024-11-18T16:20:18+00:00",
"etag": "W/"datetime'2024-11-18T16%3A20%3A18.8605368Z'"",
"version": "2019-02-02"
}
Value type: DEF
System.String
Property: CROSS_OUCode=DEF
{
"date": "2024-11-18T16:20:19+00:00",
"etag": "W/"datetime'2024-11-18T16%3A20%3A20.0078691Z'"",
"version": "2019-02-02"
}
Value type:
System.String
Property: CROSS_SSN=
{
"date": "2024-11-18T16:20:20+00:00",
"etag": "W/"datetime'2024-11-18T16%3A20%3A21.5189903Z'"",
"version": "2019-02-02"
}
Value type: DE01
System.String
Property: GSAP_OUCode=DE01
{
"date": "2024-11-18T16:20:22+00:00",
"etag": "W/"datetime'2024-11-18T16%3A20%3A22.9781421Z'"",
"version": "2019-02-02"
}

File input:
[
{
"PartitionKey": "C2S_CROSS_GSAP_OU_MAP",
"RowKey": "DEC-0154",
"CROSS_OUCode": "DEC",
"CROSS_TPPCode": "0154",
"CROSS_SSN": "",
"GSAP_OUCode": "DE01"
},
{
"PartitionKey": "C2S_CROSS_GSAP_OU_MAP",
"RowKey": "DEF-0154",
"CROSS_OUCode": "DEF",
"CROSS_TPPCode": "0154",
"CROSS_SSN": "",
"GSAP_OUCode": "DE01"
}
]

The field in question that is failing is "CROSS_TPPCode".

Expected behavior

String is entered as property, not int32

Environment Summary

azure-cli 2.63.0 *

core 2.63.0 *
telemetry 1.1.0

Dependencies:
msal 1.30.0
azure-mgmt-resource 23.1.1

Additional context

No response

@JackBruceShell JackBruceShell added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Nov 18, 2024
Copy link

Hi @JackBruceShell,

2.63.0 is not the latest Azure CLI(2.66.0).

If you haven't already attempted to do so, please upgrade to the latest Azure CLI version by following https://learn.microsoft.com/en-us/cli/azure/update-azure-cli.

@azure-client-tools-bot-prd azure-client-tools-bot-prd bot added the Auto-Resolve Auto resolve by bot label Nov 18, 2024
@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 Nov 18, 2024
@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 ARM az resource/group/lock/tag/deployment/policy/managementapp/account management-group labels Nov 18, 2024
@yonzhan
Copy link
Collaborator

yonzhan commented Nov 18, 2024

storage

@yonzhan yonzhan removed the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Nov 18, 2024
@yonzhan yonzhan added this to the Backlog milestone Nov 18, 2024
@calvinhzy
Copy link
Member

Hi @JackBruceShell Seems like it is auto resolving the value type, can you try adding quotes around this string?

@vishalholla27
Copy link

Adding quotes would store data with quotes '0123', Cant we just store 0123

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ARM az resource/group/lock/tag/deployment/policy/managementapp/account management-group Auto-Assign Auto assign by bot Auto-Resolve Auto resolve 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. 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

6 participants