简体   繁体   English

Azure blob 存储部署:错误:请将“az 帐户集”运行到 select 活动帐户

[英]Azure blob storage deployment: ERROR: Please run 'az account set' to select active account

Trying to deploy new commit to blob storage, and this suddenly happened even the changes in the commit are minor (some styling stuff).. anyone idea how to solve it?尝试将新的提交部署到 blob 存储,这突然发生了,即使提交中的更改很小(一些样式的东西)..有人知道如何解决它吗?

Run azure/CLI@v1
  with:
    azcliversion: 2.0.72
    inlineScript: az storage blob upload-batch --source ./build --destination '$web' --account-name "xxxxx"
  
  env:
    NODE_VERSION: 10.x
    STORAGE_ACCOUNT: "xxxxx"
    AZURE_HTTP_USER_AGENT: 
    AZUREPS_HOST_ENVIRONMENT: 
Starting script execution via docker image mcr.microsoft.com/azure-cli:2.0.72
ERROR: Please run 'az account set' to select active account.
Error: Error: az cli script failed.
cleaning up container...
MICROSOFT_AZURE_CLI_1637163117325_CONTAINER

(node:1734) UnhandledPromiseRejectionWarning: Error: az cli script failed.
    at /home/runner/work/_actions/azure/CLI/v1/dist/index.js:1:23964
    at Generator.throw (<anonymous>)
    at rejected (/home/runner/work/_actions/azure/CLI/v1/dist/index.js:1:20436)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:1734) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1734) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

This is the reponse of command az account list, I have only one account这是命令 az account list 的响应,我只有一个帐号在此处输入图像描述

Here is the code of fiel main.yml which is used for automatic deployments on github.这是用于在 github 上自动部署的字段 main.yml 的代码。

name: CI

on:
    push:
        branches: [ master ]
    pull_request:
        branches: [ master ]

env:
  NODE_VERSION: '10.x'
  STORAGE_ACCOUNT: 'xxxx'
  SUBSCRIPTIONID: 'yyyyyyy'

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ env.NODE_VERSION }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ env.NODE_VERSION }}
    - name: npm install and build
      run: |
        npm install
        npm run build --if-present

    - uses: azure/login@v1
      with:
          creds: ${{ secrets.AZURE_CREDENTIALS }}
    - name: Upload to the storage account
      uses: azure/CLI@v1
      with:
        azcliversion: 2.0.72
        inlineScript: |
            az storage blob upload-batch --source ./build --destination '$web' --account-name ${{ env.STORAGE_ACCOUNT }} --subscription ${{ env.SUBSCRIPTIONID}}
    - name: logout
      run: |
            az logout

az cli cannot find a resource in you current default subscription az cli 在您当前的默认订阅中找不到资源

Maybe your Storage Account name is wrong, or this resource was removed可能您的存储帐户名称错误,或者此资源已被删除

If there is another subscriptions or your container does not have any reference to az cli profile ( ~/.azure ), you have 2 options to resolve it:如果有其他订阅或您的容器没有对az cli配置文件 ( ~/.azure ) 的任何引用,您有 2 个选项来解决它:

  1. Each script run set the default subscription每个脚本运行设置默认订阅
az account set --subscription <subscription-id>
  1. Add --subscription parameter to each az cli command, if you are working with different subscriptions如果您使用不同的订阅,请向每个az cli命令添加--subscription参数
az storage blob upload-batch --source ./build --destination '$web' --account-name "xxxxx" --subscription <subscription-id>

As Ivan Ignatiev suggested, you can use latest Azure CLI version (2.30.0) to fix the issue正如 Ivan Ignatiev 建议的那样,您可以使用最新的 Azure CLI 版本 (2.30.0) 来解决此问题

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM