azure - 使用 Azure Pipeline 时如何将文件复制到 Azure Blob
问题描述
我已经尝试了很多次,但仍然出现如下错误:
“管道无效。作业作业:步骤 AzureFileCopy 输入 ConnectedServiceNameARM 引用服务连接 xxxxx-xxx-xx-xxxx-xxxxxxxx 无法找到。服务连接不存在或未被授权使用。授权详情,请参阅https://aka.ms/yamlauthz。”
在右侧,有一个“授权资源”按钮。但是无论我如何单击它,它都会显示“自动授权资源时发生错误”
这是我的 yaml 文件的一部分:
task: AzureFileCopy@3
inputs:
sourcePath:'AddFunction/bin/Debug/AddFunction.exe'
azureSubscription:'xxxxxx-xxxx-xxxx-xxxx-xxxxxxx'
destination: AzureBlob
storage:'1234'
containerName: 'test'
我还连接了 Azure Pipeline 上的服务连接,并为我的资源类型选择了“Azure 资源管理器”。
任何想法或指针将不胜感激。
解决方案
如果要将文件上传到 Azure Blob,可以通过 Azure Cli 在 Powershell 脚本中执行完全相同的操作,并通过 Azure Pipeline 中的 Powershell 任务触发它。
# PowerShell
# Run a PowerShell script on Linux, macOS, or Windows
- task: PowerShell@2
inputs:
#targetType: 'filePath' # Optional. Options: filePath, inline
#filePath: # Required when targetType
Powershell 脚本就像
#First, You have to login with a service principal.
az login --service-principal -u $AZ_NAME -p $AZ_PWD --tenant $AZ_TENANT
#upload your file by az storage blob
az storage blob upload --container-name $container_name --file $file_to_upload --name $blob_name
这可能不是完美的答案,但我希望它可以帮助您并挽救您的一天。
推荐阅读
- azure - 使用资源所有者密码凭据流的 AD B2C 非交互式/无头身份验证
- c# - 如何从列表中获取重复的项目子字符串?C#
- sql - 如何在 SQL 中连接 3 个表
- internet-explorer - 在 IE 中为样式元素编辑为 HTML
- windows - 一起使用 InkCanvas、Inktoolbar 和地图
- html - 是否所有浏览器都会忽略 html 中的空行
- php - PHP foreach if isset
- c# - ASP.NET MVC 中的自定义路由绕过主控制器/索引
- jquery - 我想在jquery中获取数据
- jenkins - 将 groovy 字符串变量传递给 jenkins 作业 dsl 授权