Skip to content

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

@koosala

Description

@koosala

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

Metadata

Metadata

Assignees

Labels

Auto-AssignAuto assign by botAuto-ResolveAuto resolve by botPortalaz portalService AttentionThis issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.feature-request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions