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

azure portal dashboard create uses "apiVersion": "2015-08-01-preview" and not "apiVersion": "2022-12-01-preview" #30198

Open
koosala opened this issue Oct 27, 2024 · 3 comments
Assignees
Labels
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. feature-request Portal az portal
Milestone

Comments

@koosala
Copy link

koosala commented Oct 27, 2024

Describe the bug

We have multiple azure environments with our software deployed and would like to use the following workflow to create a dashboard:

  1. Create a dashboard manually in azure portal
  2. Export the dashboard JSON
  3. Use this exported template as input to create dashboards for other environments using az cli.

Related command

az portal dashboard create --input-path ...

Errors

  File "C:\...\.azure\cliextensions\portal\azext_portal\vendored_sdks\portal\operations\_dashboard_operations.py", line 101, in create_or_update
    body_content = self._serialize.body(dashboard, 'Dashboard')
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msrest/serialization.py", line 624, in body
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msrest/exceptions.py", line 51, in raise_with_traceback
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msrest/serialization.py", line 622, in body
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msrest/serialization.py", line 1406, in _deserialize
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msrest/serialization.py", line 1415, in _deserialize
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msrest/serialization.py", line 1637, in deserialize_data
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msrest/exceptions.py", line 51, in raise_with_traceback
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msrest/serialization.py", line 1626, in deserialize_data
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msrest/serialization.py", line 1673, in deserialize_dict
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msrest/serialization.py", line 1673, in <dictcomp>
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msrest/serialization.py", line 1639, in deserialize_data
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msrest/serialization.py", line 1454, in _deserialize
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msrest/exceptions.py", line 51, in raise_with_traceback
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msrest/serialization.py", line 1450, in _deserialize
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msrest/serialization.py", line 1626, in deserialize_data
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msrest/serialization.py", line 1668, in deserialize_dict
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msrest/serialization.py", line 1668, in <dictcomp>
azure.core.exceptions.SerializationError: ('Unable to build a model: (\'Unable to deserialize response data. Data: {\\\'0\\\': {\\\'order\\\': 0, \\\'parts\\\': [{\\\'position\\\': {\\\'x\\\': 0, \\\'y\\\': 0, \\\'colSpan\\\': 4, \\\'rowSpan\\\': 3}, \\\'metadata\\\': {\\\'inputs\\\': [{\\\'name\\\': \\\'options\\\', \\\'value\\\': {\\\'chart\\\': {\\\'metrics\\\': [{\\\'resourceMetadata\\\': {\\\'id\\\': \\\'/subscriptions/103e905d-0efe-4e30-aa80-135c0b82faf4/reso

Issue script & Debug output

NA

Expected behavior

The dashboard export generates the file with apiVersion": "2022-12-01-preview" now.

The az cli though expects the imported file to be of the "apiVersion": "2015-08-01-preview"

The structure of data is different between the two versions:

"apiVersion": "2015-08-01-preview" has the following format.
Note1: the lenses item is a single element and not an array. Plus the items are elements with numbers "0", etc.
Note2: The parts element is similarly a single object and not an array and items inside them are elements with numbers "0" etc.

{
  "properties": {
    "lenses": {
      "0": {
        "order": 0,
        "parts": {
          "0": {}
        }
      }
    },
    "metadata": {
      "model": {
        "timeRange": {
          "value": {
            "relative": {
              "duration": 24,
              "timeUnit": 1
            }
          },
          "type": "MsPortalFx.Composition.Configuration.ValueTypes.TimeRange"
        }
      }
    }
  },
  "name": "...",
  "type": "Microsoft.Portal/dashboards",
  "location": "INSERT LOCATION",
  "apiVersion": "2015-08-01-preview"
}

apiVersion": "2022-12-01-preview" that azure portal now exports has the following format:
Note1: the lenses item is an array. Plus the items are just objects inside the array, no "0" named elements.
Note2: The parts element is similarly an array and items inside them are objects in the array, without "0" etc. named elements.

{
  "properties": {
    "lenses": [
      {
        "order": 0,
        "parts": [
           {}
        ]
      }
    ],
    "metadata": {
      "model": {
        "timeRange": {
          "value": {
            "relative": {
              "duration": 24,
              "timeUnit": 1
            }
          },
          "type": "MsPortalFx.Composition.Configuration.ValueTypes.TimeRange"
        }
      }
    }
  },
  "name": "...",
  "type": "Microsoft.Portal/dashboards",
  "location": "INSERT LOCATION",
  "apiVersion": "2022-12-01-preview"
}

The older api version can be imported by following this example: https://stackoverflow.com/a/65435018/987191

The portal exports for a later API version that cannot be used by azure cli to create the dashboard.

I understand the feature is in preview, but it doesn't align with the portal output.
Can the api be changed to import latest api version or allow to take api version as an input if multiple api versions and file formats need to be supported?

Environment Summary

azure-cli: 2.59.0

Additional context

No response

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

Hi @koosala,

2.59.0 is not the latest Azure CLI(2.65.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 Oct 27, 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. Portal az portal labels Oct 27, 2024
@yonzhan
Copy link
Collaborator

yonzhan commented Oct 27, 2024

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

@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 Oct 27, 2024
@yonzhan yonzhan removed the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Oct 27, 2024
@yonzhan yonzhan added this to the Backlog milestone Oct 27, 2024
@ReaNAiveD ReaNAiveD added feature-request and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Nov 1, 2024
@jingzhong-MS
Copy link

@jsntcy , May I ask why assign this to me? I have no context about this project.

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 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. feature-request Portal az portal
Projects
None yet
Development

No branches or pull requests

5 participants