英文:
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
- install python
- "pip install ansible"
- "pip install -r https://raw.githubusercontent.com/ansible-collections/azure/dev/requirements-azure.txt"
- "ansible-galaxy collection install azure.azcollection"
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
- install python
- "pip install ansible"
- "pip install -r https://raw.githubusercontent.com/ansible-collections/azure/dev/requirements-azure.txt"
- "ansible-galaxy collection install azure.azcollection"
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 '<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 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:
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:
for yaml:
- task: PowerShell@2
inputs:
targetType: filePath
filePath: .....
pwsh: true
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论