markpirvine
markpirvine

Reputation: 1592

VSTS Copy File To Azure Blob

I'm using VSTS to build my Xamarin Forms App for iOS - I've got it building and publishing the artifacts.

At the moment I use an Azure Blob to host the ipa - I would like to add a step to the build process to copy to the blob. So far I've tried:

However nothing has worked. Has anyone got this working?

Upvotes: 0

Views: 1423

Answers (1)

Luca Cappa
Luca Cappa

Reputation: 1999

Use the VSTS Shell Task to run a script on the Macos that upload the .ipa file to the Blob container. A sample script here below.

Please note that:

  • all the capital letter variables' values in the script should be passed by the task to the script as arguments (so you need to fix this sample script);
  • you need to install python3 on the Macos machine: homebrew install python3
  • you need to install the Azure SDK for Python, in particular: sudo pip3 install azure-storage and sudo pip3 install table

Sample script:

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)

Upvotes: 1

Related Questions