Azure DevOps Connect-AzAccount 在证书存储中未找到证书
Azure DevOps Connect-AzAccount no certificate was found in the certificate store
我正在尝试通过 Azure DevOps 管道连接到多个租户,这是为了将所有租户的信息检索到中央存储以进行分析所必需的。为了实现这一点,Azure PowerShell 任务避免使用密码,我想改为使用证书指纹进行身份验证。
在我的机器上我可以毫无问题地完成它,因为我已经在我的个人证书存储中安装了证书,但是在 Azure DevOps 上我不能这样做,当我尝试 Connect-AzAccount 时,显示以下错误
Connect-AzAccount -ServicePrincipal -Tenant "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -ApplicationId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -CertificateThumbprint xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Connect-AzAccount : No certificate was found in the certificate store with thumbprint xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
At line:1 char:1
+ Connect-AzAccount -ServicePrincipal -Tenant "xxxxxxxx-xxxx-xxxx-xxxx- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Connect-AzAccount], ArgumentException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand
我也在使用 Connect-AzureAd,因为需要使用此连接的其他 cmdlet,但我遇到了同样的错误。你知道是否有办法实现我正在寻找的东西吗?
No certificate was found in the certificate store with thumbprint
根据您的描述,您使用的似乎是微软托管的代理。
所以默认情况下 Personal Store
中没有安装证书。
要解决此问题,您可以尝试以下步骤:
在本地计算机上导出证书。
将证书上传到 Azure Devops -> Pipelines -> Library ->Secure files
。
- 在 Pipeline 中,您需要下载安全文件并将证书安装到
Personal Store
。
这是一个例子:
steps:
- task: DownloadSecureFile@1
displayName: 'Download secure file'
inputs:
secureFile: 'filename'
- script: 'CERTUTIL -addstore -user -f "My" "$(Agent.TempDirectory)\test.cer"'
displayName: 'Command Line Script'
- task: AzurePowerShell@5
xxxx
注意:DownloadSecureFile
任务会将 cer 文件下载到代理临时文件夹。
我正在尝试通过 Azure DevOps 管道连接到多个租户,这是为了将所有租户的信息检索到中央存储以进行分析所必需的。为了实现这一点,Azure PowerShell 任务避免使用密码,我想改为使用证书指纹进行身份验证。 在我的机器上我可以毫无问题地完成它,因为我已经在我的个人证书存储中安装了证书,但是在 Azure DevOps 上我不能这样做,当我尝试 Connect-AzAccount 时,显示以下错误
Connect-AzAccount -ServicePrincipal -Tenant "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -ApplicationId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -CertificateThumbprint xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Connect-AzAccount : No certificate was found in the certificate store with thumbprint xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
At line:1 char:1
+ Connect-AzAccount -ServicePrincipal -Tenant "xxxxxxxx-xxxx-xxxx-xxxx- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Connect-AzAccount], ArgumentException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand
我也在使用 Connect-AzureAd,因为需要使用此连接的其他 cmdlet,但我遇到了同样的错误。你知道是否有办法实现我正在寻找的东西吗?
No certificate was found in the certificate store with thumbprint
根据您的描述,您使用的似乎是微软托管的代理。
所以默认情况下 Personal Store
中没有安装证书。
要解决此问题,您可以尝试以下步骤:
在本地计算机上导出证书。
将证书上传到
Azure Devops -> Pipelines -> Library ->Secure files
。
- 在 Pipeline 中,您需要下载安全文件并将证书安装到
Personal Store
。
这是一个例子:
steps:
- task: DownloadSecureFile@1
displayName: 'Download secure file'
inputs:
secureFile: 'filename'
- script: 'CERTUTIL -addstore -user -f "My" "$(Agent.TempDirectory)\test.cer"'
displayName: 'Command Line Script'
- task: AzurePowerShell@5
xxxx
注意:DownloadSecureFile
任务会将 cer 文件下载到代理临时文件夹。