Skip to content

Instantly share code, notes, and snippets.

@johndowns johndowns/deploy.ps1 Secret
Created Nov 6, 2018

Embed
What would you like to do?
$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
You can’t perform that action at this time.