Skip to content

Commit a26ab38

Browse files
Copilotisra-fel
andauthored
Add workaround example for New-AzPortalDashboard using Invoke-AzRestMethod (#28428)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: isra-fel <[email protected]>
1 parent 529eba2 commit a26ab38

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

src/Portal/Portal.Autorest/docs/New-AzPortalDashboard.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,30 @@ eastasia my-dashboard03 Microsoft.Portal/dashboards
6161

6262
Create a new dashboard using the provided dashboard template file.
6363

64+
### Example 2: Workaround for dashboard creation issues using Invoke-AzRestMethod
65+
```powershell
66+
$SubscriptionId = (Get-AzContext).Subscription.Id
67+
$ResourceGroupName = 'mydash-rg'
68+
$DashboardName = 'my-dashboard03'
69+
$DashboardPath = ".\resources\dash1.json"
70+
$Location = "East US"
71+
$ApiVersion = "2022-12-01-preview"
72+
$Dashboard = Get-Content -Path $DashboardPath -Raw | ConvertFrom-Json
73+
$Payload = @{
74+
properties = $Dashboard.properties
75+
location = $Location
76+
} | ConvertTo-Json -Depth 10
77+
Invoke-AzRestMethod -SubscriptionId $SubscriptionId -ResourceGroupName $ResourceGroupName -ResourceProviderName "Microsoft.Portal" -ResourceType "dashboards" -Name $DashboardName -ApiVersion $ApiVersion -Method PUT -Payload $Payload
78+
```
79+
80+
```output
81+
StatusCode : 200
82+
Content : {"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mydash-rg/providers/Microsoft.Portal/dashboards/my-dashboard03","name":"my-dashboard03","type":"Microsoft.Portal/dashboards","location":"East US","properties":{...}}
83+
Headers : {[Content-Length, 1234], [Content-Type, application/json; charset=utf-8], [Date, Wed, 01 Jan 2025 00:00:00 GMT]}
84+
```
85+
86+
Use this workaround when `New-AzPortalDashboard` succeeds but the dashboard fails to render with "Dashboard not found" error. This issue is with the underlying REST API and this method provides a reliable alternative.
87+
6488
## PARAMETERS
6589

6690
### -DashboardPath

src/Portal/Portal.Autorest/examples/New-AzPortalDashboard.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,32 @@ New-AzPortalDashboard -DashboardPath .\resources\dash1.json -ResourceGroupName m
77
Location Name Type
88
-------- ---- ----
99
eastasia my-dashboard03 Microsoft.Portal/dashboards
10-
`````
10+
```
1111

1212
Create a new dashboard using the provided dashboard template file.
1313

14+
### Example 2: Workaround for dashboard creation issues using Invoke-AzRestMethod
15+
```powershell
16+
$SubscriptionId = (Get-AzContext).Subscription.Id
17+
$ResourceGroupName = 'mydash-rg'
18+
$DashboardName = 'my-dashboard03'
19+
$DashboardPath = ".\resources\dash1.json"
20+
$Location = "East US"
21+
$ApiVersion = "2022-12-01-preview"
22+
$Dashboard = Get-Content -Path $DashboardPath -Raw | ConvertFrom-Json
23+
$Payload = @{
24+
properties = $Dashboard.properties
25+
location = $Location
26+
} | ConvertTo-Json -Depth 10
27+
Invoke-AzRestMethod -SubscriptionId $SubscriptionId -ResourceGroupName $ResourceGroupName -ResourceProviderName "Microsoft.Portal" -ResourceType "dashboards" -Name $DashboardName -ApiVersion $ApiVersion -Method PUT -Payload $Payload
28+
```
29+
30+
```output
31+
StatusCode : 200
32+
Content : {"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mydash-rg/providers/Microsoft.Portal/dashboards/my-dashboard03","name":"my-dashboard03","type":"Microsoft.Portal/dashboards","location":"East US","properties":{...}}
33+
Headers : {[Content-Length, 1234], [Content-Type, application/json; charset=utf-8], [Date, Wed, 01 Jan 2025 00:00:00 GMT]}
34+
```
35+
36+
Use this workaround when `New-AzPortalDashboard` succeeds but the dashboard fails to render with "Dashboard not found" error. This issue is with the underlying REST API and this method provides a reliable alternative.
37+
1438

src/Portal/Portal/help/New-AzPortalDashboard.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,30 @@ eastasia my-dashboard03 Microsoft.Portal/dashboards
6565

6666
Create a new dashboard using the provided dashboard template file.
6767

68+
### Example 2: Workaround for dashboard creation issues using Invoke-AzRestMethod
69+
```powershell
70+
$SubscriptionId = (Get-AzContext).Subscription.Id
71+
$ResourceGroupName = 'mydash-rg'
72+
$DashboardName = 'my-dashboard03'
73+
$DashboardPath = ".\resources\dash1.json"
74+
$Location = "East US"
75+
$ApiVersion = "2022-12-01-preview"
76+
$Dashboard = Get-Content -Path $DashboardPath -Raw | ConvertFrom-Json
77+
$Payload = @{
78+
properties = $Dashboard.properties
79+
location = $Location
80+
} | ConvertTo-Json -Depth 10
81+
Invoke-AzRestMethod -SubscriptionId $SubscriptionId -ResourceGroupName $ResourceGroupName -ResourceProviderName "Microsoft.Portal" -ResourceType "dashboards" -Name $DashboardName -ApiVersion $ApiVersion -Method PUT -Payload $Payload
82+
```
83+
84+
```output
85+
StatusCode : 200
86+
Content : {"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mydash-rg/providers/Microsoft.Portal/dashboards/my-dashboard03","name":"my-dashboard03","type":"Microsoft.Portal/dashboards","location":"East US","properties":{...}}
87+
Headers : {[Content-Length, 1234], [Content-Type, application/json; charset=utf-8], [Date, Wed, 01 Jan 2025 00:00:00 GMT]}
88+
```
89+
90+
Use this workaround when `New-AzPortalDashboard` succeeds but the dashboard fails to render with "Dashboard not found" error. This issue is with the underlying REST API and this method provides a reliable alternative.
91+
6892
## PARAMETERS
6993

7094
### -DashboardPath

0 commit comments

Comments
 (0)