Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure 如何从DevOps管道安全地登录Az CLI_Azure_Azure Devops_Azure Cli - Fatal编程技术网

Azure 如何从DevOps管道安全地登录Az CLI

Azure 如何从DevOps管道安全地登录Az CLI,azure,azure-devops,azure-cli,Azure,Azure Devops,Azure Cli,我想从我的Azure DevOps管道执行AZ cli命令。在我的YAML文件中,我有以下内容: trigger: - master pool: vmImage: 'ubuntu-latest' variables: buildConfiguration: 'Release' steps: - task: UsePythonVersion@0 inputs: versionSpec: '3.x' architecture: 'x64' # Updating p

我想从我的Azure DevOps管道执行AZ cli命令。在我的YAML文件中,我有以下内容:

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

variables:
  buildConfiguration: 'Release'

steps:
- task: UsePythonVersion@0
  inputs:
    versionSpec: '3.x'
    architecture: 'x64'

# Updating pip to latest
- script: python -m pip install --upgrade pip
  displayName: 'Upgrade pip'

# Updating to latest Azure CLI version.
- script: pip install --pre azure-cli --extra-index-url https://azurecliprod.blob.core.windows.net/edge
  displayName: 'upgrade azure cli'

- script: az --version
  displayName: 'Show Azure CLI version'

- script: az extension add -n azure-devops
  displayName: 'Install Azure DevOps Extension'

- script: echo ${AZURE_DEVOPS_CLI_PAT} | az devops login
  env:
    AZURE_DEVOPS_CLI_PAT: $(System.AccessToken)
  displayName: 'Login Azure DevOps Extension'

- script: az aks show --name census-k8s  --resource-group Census
  displayName: 'Show AKS'

echo${AZURE_DEVOPS_CLI_PAT}az DEVOPS登录步骤已完成(显然已成功),并显示一条警告消息

Failed to store PAT using keyring; falling back to file storage.
You can clear the stored credential by running az devops logout.
Refer https://aka.ms/azure-devops-cli-auth to know more on sign in with PAT.
az aks显示步骤失败:

Please run 'az login' to setup account.

我有点迷路了。az devops login命令应该启用be以使用az cli,对吗?如果不是,我应该使用az登录而不是az devops登录吗?如果我应该使用az登录,我如何在Azure DevOps管道中的执行代理中以安全的方式传递凭据?

不,您不需要
az DevOps登录
。您需要的是:

-任务:AzureCLI@2
显示名称:Azure CLI
投入:
azureSubscription:
脚本类型:ps
scriptLocation:inlineScript
inlineScript:|
az——版本
az帐户显示

但是你不需要做任何登录。请致电此处查看您的
az aks show--name census-k8s--resource group census

补充Krzysztof的答案(以及评论中的jeromerg问题):在Azure CLI步骤中,您还可以使用其他工具,然后
az
,这些工具需要使用AzureCLI登录:

-任务:AzureCLI@2
displayName:发布功能
投入:
azureSubscription:
脚本类型:ps
scriptLocation:inlineScript
inlineScript:|
func azure发布

如果您的scriptLocation是scriptPath,请使用以下示例

  - task: AzureCLI@2
    displayName: 'update function appsettings'
    inputs:
    azureSubscription: 'MY-AzureSubscriptionName'
    scriptType: ps
    scriptLocation: 'scriptPath'
    scriptPath: '$(System.DefaultWorkingDirectory)/Scripts/updateSettings.ps1'
    arguments:
        -ResourceGroupName 'MY-ResourceGroupName' `
        -FunctionAppName 'MY-FunctionAppName'
updateSettings.ps1

param (
    [string]$ResourceGroupName,
    [string]$FunctionAppName)
)
.
. script body here
.

但您无法登录以启用azure功能核心工具。。。