Skip to content

[Feature]: Add an example to work around the issue of dashboard creationΒ #28427

@isra-fel

Description

@isra-fel

Description of the new feature

When creating a dashboard using New-AzPortalDashboard command, there is an issue report regarding the command succeeds but the dashboard fails to render with an error "Dashboard not found".

This is an issue with the underlying REST API (tracked seperately). There's a workaround using Invoke-AzRestMethod and we want it to be documented as an example in the reference doc of New-AzPortalDashboard.

$SubscriptionId = (Get-AzContext).Subscription.Id
$ResourceGroupName = '******'
$DashboardName = '******'
$DashboardPath = "******.json"
$Location = "******"
$ApiVersion = "2022-12-01-preview"
$Dashboard = Get-Content -Path $DashboardPath -Raw | ConvertFrom-Json
$Payload = @{
    properties = $Dashboard.properties
    location = $Location
} | ConvertTo-Json -Depth 10
Invoke-AzRestMethod -SubscriptionId $SubscriptionId -ResourceGroupName $ResourceGroupName`
    -ResourceProviderName "Microsoft.Portal" -ResourceType "dashboards" `
    -Name $DashboardName -ApiVersion $ApiVersion -Method PUT -Payload $Payload

Proposed implementation details (optional)

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions