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

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

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.

  1. function Add-Dashboard {
  2. param ([String]$subscriptionID,[String]$resourceGroup,[String]$apiManagementName,[String]$dashboardTitle,[String]$location)
  3. $file = New-TemporaryFile
  4. $Content = Get-Content ./templates/api-management-dashboard.json
  5. $Content = $Content -replace '<subscriptionID>', $subscriptionID
  6. $Content = $Content -replace '<ressourceGroupName>', $resourceGroup
  7. $Content = $Content -replace '<apiManagementName>', $apiManagementName
  8. $Content = $Content -replace '<dashboardTitle>', $dashboardTitle
  9. $Content = $Content -replace '<location>', $location
  10. $Content | Set-Content $file
  11. $DashboardParams = @{
  12. DashboardPath = $file
  13. ResourceGroupName = $resourceGroup
  14. DashboardName = $dashboardTitle
  15. }
  16. New-AzPortalDashboard @DashboardParams
  17. Remove-Item -Path $file
  18. }

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.

  1. function Add-Dashboard {
  2. param ([String]$subscriptionID,[String]$resourceGroup,[String]$apiManagementName,[String]$dashboardTitle,[String]$location)
  3. $file = New-TemporaryFile
  4. $Content = Get-Content ./templates/api-management-dashboard.json
  5. $Content = $Content -replace &#39;&lt;subscriptionID&gt;&#39;, $subscriptionID
  6. $Content = $Content -replace &#39;&lt;ressourceGroupName&gt;&#39;, $resourceGroup
  7. $Content = $Content -replace &#39;&lt;apiManagementName&gt;&#39;, $apiManagementName
  8. $Content = $Content -replace &#39;&lt;dashboardTitle&gt;&#39;, $dashboardTitle
  9. $Content = $Content -replace &#39;&lt;location&gt;&#39;, $location
  10. $Content | Set-Content $file
  11. $DashboardParams = @{
  12. DashboardPath = $file
  13. ResourceGroupName = $resourceGroup
  14. DashboardName = $dashboardTitle
  15. }
  16. New-AzPortalDashboard @DashboardParams
  17. Remove-Item -Path $file
  18. }

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:

  1. - task: PowerShell@2
  2. inputs:
  3. targetType: filePath
  4. filePath: .....
  5. 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:

确定