我试图通过脚本创建Azure API管理的上下文。脚本我有我能够执行在Azure门户的内置powershell终端。但我正试图通过我的管道运行这些脚本。当前管道在ubuntu下运行,这是yaml任务。我试过启用核心,以及没有它。
steps:
- task: AzurePowerShell@5
displayName: 'Azure PowerShell script: InlineScript'
inputs:
azureSubscription: '<sc>'
ScriptType: InlineScript
Inline: |
Set-AzContext -SubscriptionId $(subId)
$apimContext = New-AzureRmApiManagementContext -ResourceGroupName "$(rgName)" -ServiceName "$(serviceName)"
管道抛出标准错误-
The term 'New-AzureRmApiManagementContext' is not recognized
| as a name of a cmdlet, function, script file, or executable
| program. Check the spelling of the name, or if a path was
| included, verify that the path is correct and try again.
是否有我需要导入的东西,而运行这个?
解决方案,我可以看到在powershell上发生了迁移https://learn.microsoft.com/en-us/powershell/azure/migrate-from-azurerm-to-az?view=azps-6.5.0。
所以如果我在管道中将New-AzureRmApiManagementContext更改为New-AzApiManagementContext,它就可以工作了