“New-AzPortalDashboard” 这个术语在 Azure 管道中未被识别为名称。

huangapple go评论58阅读模式
英文:

The term New-AzPortalDashboard is not recognized as a name in a azure pipeline

问题

In summary I am ask to add an Azure Dashboard via an ansible playbook.
I always get the error "The term New-AzPortalDashboard is not recognized as a name."

There is a pipeline file that

In the playbook it's basically doing stuff with an api and "include_tasks" an yml file.
This yml file call a ps1 file to create stuff.

In that ps1 file I added a function to get the format of an Azure dashboard, do some updates, and call the New-AzPortalDashboard function.

function Add-Dashboard {
param ([String]$subscriptionID,[String]$resourceGroup,[String]$apiManagementName,[String]$dashboardTitle,[String]$location)

$file = New-TemporaryFile

$Content = Get-Content ./templates/api-management-dashboard.json  
$Content = $Content -replace '<subscriptionID>', $subscriptionID
$Content = $Content -replace '<ressourceGroupName>', $resourceGroup
$Content = $Content -replace '<apiManagementName>', $apiManagementName
$Content = $Content -replace '<dashboardTitle>', $dashboardTitle
$Content = $Content -replace '<location>', $location
$Content | Set-Content $file

$DashboardParams = @{
  DashboardPath = $file
  ResourceGroupName = $resourceGroup
  DashboardName = $dashboardTitle
}
New-AzPortalDashboard @DashboardParams

Remove-Item -Path $file
}

I tried to Install-Module for "Az," "Az.Portal," and "Az.Resource" in the pipeline and the ps1, but it did not work.

英文:

In summary I am ask to add an Azure Dashboard via an ansible playbook.
I always get the error "The term New-AzPortalDashboard is not recognized as a name"

There is a pipeline file that

In the playbook it's basically doing stuff with an api and "include_tasks" an yml file.
This yml file call a ps1 file to create stuff.

In that ps1 file I added a function to get the format of a azure dashboard do some update and call the New-AzPortalDashboard.

function Add-Dashboard {
param ([String]$subscriptionID,[String]$resourceGroup,[String]$apiManagementName,[String]$dashboardTitle,[String]$location)

$file = New-TemporaryFile

$Content = Get-Content ./templates/api-management-dashboard.json  
$Content = $Content -replace &#39;&lt;subscriptionID&gt;&#39;, $subscriptionID
$Content = $Content -replace &#39;&lt;ressourceGroupName&gt;&#39;, $resourceGroup
$Content = $Content -replace &#39;&lt;apiManagementName&gt;&#39;, $apiManagementName
$Content = $Content -replace &#39;&lt;dashboardTitle&gt;&#39;, $dashboardTitle
$Content = $Content -replace &#39;&lt;location&gt;&#39;, $location
$Content | Set-Content $file

$DashboardParams = @{
  DashboardPath = $file
  ResourceGroupName = $resourceGroup
  DashboardName = $dashboardTitle
}
New-AzPortalDashboard @DashboardParams

Remove-Item -Path $file
}

I try to Install-Module for "Az", "Az.Portal" and "Az.Ressource" in the pipeline and the ps1 but it did not work.

答案1

得分: 1

Did you check the solution here: Azure DevOps CI/CD missing command: New-AzPortalDashboard

Additionally, verify you are using pwsh core on your build agent:

for classic:

“New-AzPortalDashboard” 这个术语在 Azure 管道中未被识别为名称。

for yaml:

  • task: PowerShell@2
    inputs:
    targetType: filePath
    filePath: .....
    pwsh: true
英文:

Did you check the solution here: Azure DevOps CI/CD missing command: New-AzPortalDashboard

Additionally, verify you are using pwsh core on your build agent:

for classic:

“New-AzPortalDashboard” 这个术语在 Azure 管道中未被识别为名称。

for yaml:

- task: PowerShell@2
  inputs:
    targetType: filePath
    filePath: .....
    pwsh: true

huangapple
  • 本文由 发表于 2023年2月7日 04:56:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/75366504.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定