简体   繁体   English

Azure 管道 AzurePowerShell@5 失败

[英]Azure Pipeline AzurePowerShell@5 fails

I'm having trouble running the AzurePowerShell@5 task in my Azure pipeline.我在 Azure 管道中运行AzurePowerShell@5任务时遇到问题。

I have boiled it down to this simple script:我把它归结为这个简单的脚本:

pool:
  vmImage: windows-latest
steps:
- task: AzurePowerShell@5
  inputs:
    azureSubscription: my-azure-sub
    inline: Write-Host "Hello World"
    azurePowerShellVersion: latestVersion
    pwsh: true

... which fails with this somewhat cryptic message: ...失败并显示这条有点神秘的消息:

Starting: AzurePowerShell
==============================================================================
Task         : Azure PowerShell
Description  : Run a PowerShell script within an Azure environment
Version      : 5.185.0
Author       : Microsoft Corporation
Help         : https://aka.ms/azurepowershelltroubleshooting
==============================================================================
Generating script.
========================== Starting Command Output ===========================
"C:\Program Files\PowerShell\7\pwsh.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a\_temp\adf280e2-5ea5-4fe4-a5b0-5b25afb31371.ps1'"
Added TLS 1.2 in session.
Import-Module -Name C:\Modules\az_6.4.0\Az.Accounts\2.5.3\Az.Accounts.psd1 -Global
WARNING: Both Az and AzureRM modules were detected on this machine. Az and AzureRM modules cannot be imported in the same session or used in the same script or runbook. If you are running PowerShell in an environment you control you can use the 'Uninstall-AzureRm' cmdlet to remove all AzureRm modules from your machine. If you are running in Azure Automation, take care that none of your runbooks import both Az and AzureRM modules. More information can be found here: https://aka.ms/azps-migration-guide
Clear-AzContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue
Clear-AzContext -Scope Process
Connect-AzAccount -ServicePrincipal -Tenant *** -Credential System.Management.Automation.PSCredential -Environment AzureCloud @processScope
 Set-AzContext -SubscriptionId 7c995cd6-1740-4a31-ae74-d74e61f675e1 -TenantId ***
##[error]The term 'D:\a\1\s' 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.
##[error]PowerShell exited with code '1'.
Finishing: AzurePowerShell

Not sure what I'm doing wrong here?不确定我在这里做错了什么?

You are missing ScriptType: 'InlineScript'您缺少ScriptType: 'InlineScript'

steps:
- task: AzurePowerShell@5
  inputs:
    azureSubscription: ''
    ScriptType: 'InlineScript'
    Inline: 'Write-Host "Hello World"'
    azurePowerShellVersion: 'LatestVersion'
    pwsh: true
Starting: AzurePowerShell
==============================================================================
Task         : Azure PowerShell
Description  : Run a PowerShell script within an Azure environment
Version      : 5.185.0
Author       : Microsoft Corporation
Help         : https://aka.ms/azurepowershelltroubleshooting
==============================================================================
Generating script.
========================== Starting Command Output ===========================
"C:\Program Files\PowerShell\7\pwsh.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a\_temp\000bd73f-ac18-49ee-b670-f1e9fda8d6e5.ps1'"
Added TLS 1.2 in session.
Import-Module -Name C:\Modules\az_6.4.0\Az.Accounts\2.5.3\Az.Accounts.psd1 -Global
WARNING: Both Az and AzureRM modules were detected on this machine. Az and AzureRM modules cannot be imported in the same session or used in the same script or runbook. If you are running PowerShell in an environment you control you can use the 'Uninstall-AzureRm' cmdlet to remove all AzureRm modules from your machine. If you are running in Azure Automation, take care that none of your runbooks import both Az and AzureRM modules. More information can be found here: https://aka.ms/azps-migration-guide
Clear-AzContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue
Clear-AzContext -Scope Process
Connect-AzAccount -ServicePrincipal -Tenant *** -Credential System.Management.Automation.PSCredential -Environment AzureCloud @processScope
 Set-AzContext -SubscriptionId 26f3dfe8-09e6-475f-b019-06857f15af9f -TenantId ***
Hello World
Finishing: AzurePowerShell

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果管道失败,如何停止触发器 Azure Datafactory - How to stop trigger if pipeline fails Azure Datafactory Azure 管道运行失败时数据工厂上传数据到数据库 - Azure Data Factory uploads data to database when pipeline run fails Azure 通过开发操作管道的云服务扩展部署失败 - Azure Cloud Service Extended deployment via dev ops pipeline fails Azure 管道发布管道:ARM 模板部署:资源组 scope 失败,错误代码:部署失败” - Azure pipeline Release pipeline: ARM Template deployment: Resource Group scope fails with ,,Error code: DeploymentFailed" Telerik Nuget package 在 Azure 中恢复构建管道失败 - Telerik Nuget package restore in Azure build pipeline fails pip 在 azure 管道中安装 azure-functions 失败,执行 pip 身份验证任务 - pip install azure-functions in azure pipeline fails with pip authenticate task Azure ML 管道因 ImportError 失败:无法导入名称“time_ns”错误 - Azure ML pipeline fails with ImportError: cannot import name 'time_ns' error Azure 管道 maven 发布:执行失败并显示“git-clone 命令失败”。 - Azure Pipeline maven release:perform fails with "The git-clone command failed." Azure 构建管道和发布管道nodejs - Azure build pipeline and release pipeline nodejs 触发 azure 数据工厂管道 - trigger azure data factory pipeline
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM