hlu*_*osa 3 azure azure-cli azure-devops azure-pipelines
我想从我的 Azure DevOps Pipeline 执行 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'
Run Code Online (Sandbox Code Playgroud)
该回声$ {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.
Run Code Online (Sandbox Code Playgroud)
该AZ AKS显示步骤失败:
Please run 'az login' to setup account.
Run Code Online (Sandbox Code Playgroud)
我有点失落。该AZ DEVOPS登录命令应该使我用AZ CLI,对不对?如果没有,我应该使用az login而不是az devops login吗?如果我应该使用az login,我如何以安全的方式传递我的凭据?
不,你不需要az devops login。你需要的是Azure CLI 任务:
- task: AzureCLI@2
displayName: Azure CLI
inputs:
azureSubscription: <Name of the Azure Resource Manager service connection>
scriptType: ps
scriptLocation: inlineScript
inlineScript: |
az --version
az account show
Run Code Online (Sandbox Code Playgroud)
但是您不必进行任何登录。请打电话给你az aks show --name census-k8s --resource-group Census
| 归档时间: |
|
| 查看次数: |
4669 次 |
| 最近记录: |