Skip to content

Instantly share code, notes, and snippets.

@takekazuomi
Created September 2, 2018 04:33
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 takekazuomi/4c3f238449c06dfee0b9644aacb63c74 to your computer and use it in GitHub Desktop.
Save takekazuomi/4c3f238449c06dfee0b9644aacb63c74 to your computer and use it in GitHub Desktop.
Task Deploy -depends Archive -description "Deploy functions" -requiredVariables $name {
$container = "content"
$webapp = Get-AzureRmWebApp -Name $name | % {$_}
$h = @{}
$webapp.SiteConfig.AppSettings | % { $h[$_.Name] = $_.Value}
$zip = (Get-ChildItem "$buildDir/*.zip" | Select-Object -Last 1).FullName
$ctx = New-AzureStorageContext -ConnectionString $h["AzureWebJobsStorage"]
New-AzureStorageContainer -Name $container -Permission Off -Context $ctx -ErrorAction SilentlyContinue | Out-Null
$blob = Set-AzureStorageBlobContent -Container $container -BlobType Block -File $zip -Context $ctx -Force
$now = Get-Date
$sas = New-AzureStorageBlobSASToken -CloudBlob $blob.ICloudBlob -Context $ctx -FullUri -Permission r -ExpiryTime $now.AddYears(99) -StartTime $now.AddHours(-1)
$h["WEBSITE_USE_ZIP"] = "$sas"
$h["WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT"] = "1"
$webapp | Set-AzureRmWebApp -AppSettings $h -ResourceGroupName $webapp.ResourceGroup
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment