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 account or-policy update not working with -p @policy.json #28356

Closed
letmaik opened this issue Feb 12, 2024 · 1 comment · Fixed by #28391
Closed

az storage account or-policy update not working with -p @policy.json #28356

letmaik opened this issue Feb 12, 2024 · 1 comment · Fixed by #28391
Assignees
Labels
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 Storage az storage
Milestone

Comments

@letmaik
Copy link

letmaik commented Feb 12, 2024

Describe the bug

Updating an object replication policy with az storage account or-policy update --account-name <name> -g <rg> -p @policy.json --policy-id <id> fails with an error.

Related command

az storage account or-policy update

Errors

The command failed with an unexpected error. Here is the traceback:
'str' object has no attribute 'keys'
Traceback (most recent call last):
  File "/opt/az/lib/python3.11/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 664, in execute
    raise ex
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 729, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 698, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 334, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/command_operation.py", line 240, in handler
    result = cached_put(self.cmd, setter, **setterargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 453, in cached_put
    return _put_operation()
           ^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 447, in _put_operation
    result = operation(**kwargs)
             ^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/storage/operations/account.py", line 980, in update_or_policy
    if "policyId" in properties.keys() and properties["policyId"]:
                     ^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'keys'

I added a print statement for properties in the code and this prints out a str of the file content. The JSON parsing of the file is missing.

Issue script & Debug output

N/A

Expected behavior

It should work and parse the JSON.

Environment Summary

azure-cli 2.57.0

core 2.57.0
telemetry 1.1.0

Extensions:
bastion 0.3.0
ssh 2.0.2

Dependencies:
msal 1.26.0
azure-mgmt-resource 23.1.0b2

Python location '/opt/az/bin/python3'
Extensions directory '/home/.../.azure/cliextensions'

Python (Linux) 3.11.7 (main, Jan 31 2024, 05:30:12) [GCC 9.4.0]

Additional context

No response

@letmaik letmaik added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Feb 12, 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 labels Feb 12, 2024
@yonzhan
Copy link
Collaborator

yonzhan commented Feb 12, 2024

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

@yonzhan yonzhan removed the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Feb 13, 2024
@yonzhan yonzhan added this to the Backlog milestone Feb 13, 2024
calvinhzy added a commit that referenced this issue Feb 20, 2024
…@policy.json` to allow passing in json files (#28391)

* verify policy json files for update

* don't change arg group
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 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
4 participants