Skip to content

Instantly share code, notes, and snippets.

@johndowns
Created November 6, 2018 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johndowns/cc9f1330f535f1521f0a382db58448b5 to your computer and use it in GitHub Desktop.
Save johndowns/cc9f1330f535f1521f0a382db58448b5 to your computer and use it in GitHub Desktop.
$sourceAlias = '<your source alias name goes here>'
$resourceGroupName = '<your resource group name goes here>'
# Upload blob
$containerName = 'packages'
$guid = [guid]::NewGuid()
$blobName = "$env:Build_DefinitionName/$env:Build_BuildNumber-$guid.zip"
$storageContext = New-AzureStorageContext -StorageAccountName $env:StorageAccountName -StorageAccountKey $env:StorageAccountKey
$appPackagePath = [IO.Path]::Combine($env:Agent_ReleaseDirectory, $sourceAlias, 'app', 'EmptyApp.zip')
Set-AzureStorageBlobContent -File $appPackagePath -Container $containerName -Blob $blobName -Context $storageContext
# Generate SAS URL
$expiry = (Get-Date).AddYears(100)
$blobSasUrl = New-AzureStorageBlobSASToken -Container $containerName -Context $storageContext -Blob $blobName -ExpiryTime $expiry -Permission r -FullUri
# Deploy ARM template
$armTemplatePath = [IO.Path]::Combine($env:Agent_ReleaseDirectory, $sourceAlias, 'deploy', 'template-app.json')
$armDeploymentParameters = @{}
$armDeploymentParameters.Add('packageUrl', $blobSasUrl)
New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile $armTemplatePath -TemplateParameterObject $armDeploymentParameters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment