VSTS 将文件复制到 Azure Blob
VSTS Copy File To Azure Blob
我正在使用 VSTS 为 iOS 构建我的 Xamarin Forms 应用程序 - 我已经构建并发布了工件。
目前我使用 Azure Blob 来托管 ipa - 我想在构建过程中添加一个步骤以复制到 blob。到目前为止我已经尝试过:
- Azure 文件复制
- cURL
- 复制文件(Azure 文件共享)
但是没有任何效果。有没有人得到这个工作?
在 Mac 上使用 VSTS Shell Task 到 运行 脚本将 .ipa 文件上传到 Blob 容器。下面是示例脚本。
请注意:
- 脚本中所有大写字母变量的值都应由任务作为参数传递给脚本(因此您需要修复此示例脚本);
- 您需要在 Macos 机器上安装 python3:
homebrew install python3
- 您需要为 Python 安装 Azure SDK,特别是:
sudo pip3 install azure-storage
和 sudo pip3 install table
示例脚本:
from azure.storage.blob import BlockBlobService
import tables
import os
import sys
from azure.storage.blob import PublicAccess
from azure.storage.blob import ContentSettings
output_blob_service=BlockBlobService(account_name=STORAGEACCOUNTNAME,account_key=STORAGEACCOUNTKEY)
localfileprocessed = os.path.join(os.getcwd(),LOCALFILENAME) #assuming file is in current working directory
try:
output_blob_service.create_container(CONTAINERNAME, public_access=PublicAccess.Container)
output_blob_service.create_blob_from_path(CONTAINERNAME,BLOBNAME, localfileprocessed,
content_settings=ContentSettings(content_type='application/octet-stream'))
except:
print ("Something went wrong with uploading to the blob:"+ BLOBNAME)
我正在使用 VSTS 为 iOS 构建我的 Xamarin Forms 应用程序 - 我已经构建并发布了工件。
目前我使用 Azure Blob 来托管 ipa - 我想在构建过程中添加一个步骤以复制到 blob。到目前为止我已经尝试过:
- Azure 文件复制
- cURL
- 复制文件(Azure 文件共享)
但是没有任何效果。有没有人得到这个工作?
在 Mac 上使用 VSTS Shell Task 到 运行 脚本将 .ipa 文件上传到 Blob 容器。下面是示例脚本。
请注意:
- 脚本中所有大写字母变量的值都应由任务作为参数传递给脚本(因此您需要修复此示例脚本);
- 您需要在 Macos 机器上安装 python3:
homebrew install python3
- 您需要为 Python 安装 Azure SDK,特别是:
sudo pip3 install azure-storage
和sudo pip3 install table
示例脚本:
from azure.storage.blob import BlockBlobService
import tables
import os
import sys
from azure.storage.blob import PublicAccess
from azure.storage.blob import ContentSettings
output_blob_service=BlockBlobService(account_name=STORAGEACCOUNTNAME,account_key=STORAGEACCOUNTKEY)
localfileprocessed = os.path.join(os.getcwd(),LOCALFILENAME) #assuming file is in current working directory
try:
output_blob_service.create_container(CONTAINERNAME, public_access=PublicAccess.Container)
output_blob_service.create_blob_from_path(CONTAINERNAME,BLOBNAME, localfileprocessed,
content_settings=ContentSettings(content_type='application/octet-stream'))
except:
print ("Something went wrong with uploading to the blob:"+ BLOBNAME)