You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure函数应用部署Workflow报错:PowerShell不完整字符串令牌

Azure GitHub Action 部署资源组失败问题

错误信息

ParserError: D:\a_temp\2ef5a91f-aee0-4906-9e6e-ab5e5233530f.ps1:3
Line |
3 | … -Name "az-xxx-xxx-rg-businessfuncappxayb" -Location "North Europe" `
| ~
| Incomplete string token.

关联YAML脚本

name: Resource Group Creation
  uses: azure/powershell@v1
  with:
      azPSVersion: latest
      inlineScript:
        Select-AzSubscription -Subscription ${{ github.event.inputs.businessSubscriptionId }}| `

        New-AzResourceGroup -Name "az-dna-113-rg-businessfuncappxayb" -Location "North Europe" `
      failOnStandardError: $true

问题根源

  1. 行续符使用错误:PowerShell的行续符()后不能有任何字符(包括空格、空行),且最后一行命令不需要续符。你在New-AzResourceGroup`行末尾多了续符,导致PowerShell认为命令未完成,触发"Incomplete string token"错误。
  2. 管道符与续符混用冗余:Select-AzSubscription与New-AzResourceGroup是独立命令,不需要管道符连接,额外的| 加续符反而增加语法风险。

修复后的脚本

推荐使用块字符串语法(|)管理多行脚本,彻底避免续符问题:

name: Resource Group Creation
  uses: azure/powershell@v1
  with:
      azPSVersion: latest
      inlineScript: |
        Select-AzSubscription -Subscription ${{ github.event.inputs.businessSubscriptionId }}
        New-AzResourceGroup -Name "az-dna-113-rg-businessfuncappxayb" -Location "North Europe"
      failOnStandardError: $true

如果坚持使用续符,需保证续符后无任何字符,且最后一行不加续符:

name: Resource Group Creation
  uses: azure/powershell@v1
  with:
      azPSVersion: latest
      inlineScript:
        Select-AzSubscription -Subscription ${{ github.event.inputs.businessSubscriptionId }} `
        New-AzResourceGroup -Name "az-dna-113-rg-businessfuncappxayb" -Location "North Europe"
      failOnStandardError: $true

核心注意点

  • PowerShell行续符`必须紧跟换行,不能附带任何空格或其他字符
  • 最后一行命令禁止添加续符,否则会被判定为未完成的字符串
  • 使用块字符串语法(|)能大幅降低多行脚本的语法错误概率

内容的提问来源于stack exchange,提问作者Nolan1513

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 09:24:59