en-us/Publishing_Pipeworks_To_Azure.walkthru.help.txt

<#
 
Azure can be really amazing. Azure compute instances are Microsoft's own version of Windows Server, and they've got a very valuable deployment system.
 
 
Azure Web Roles can be configured to host many sites with many different host headers onto a single deployment. While these types of deployments are usually hard to create, Pipeworks can pop them right out.
 
 
This means that anyone can make a massively multitenant Azure deployment with Pipeworks. The Pipeworks deployment presently has around 60 different apps, running over 150 different domains, and running at 11% memory / 2% CPU on a single Azure instance.
 
 
It's easy to drop in many deployments by simply using the DomainSchematics section of the Pipeworks manifest. This shows the domain schematics section for Pipeworks.
 
#>
(Get-Module Pipeworks).Path |
    Split-Path |
    Join-Path -ChildPath "Pipeworks.Pipeworks.psd1" |
    Get-Content -Path { $_ } |
    Select-String DomainSchematics -Context 5
 
 
<#
 
The DomainSchematics section is used to help a command called Publish-AzureService make multitenant deployments easy.
 
Assuming you have the Azure SDK installed, this simple pipeline will make a deployment package from all loaded modules that have a Pipeworks manifest.
 
#>
Get-Module |
    Get-PipeworksManifest |
    Where-Object {
        $_.DomainSchematics
    } |
    Publish-AzureService -DeploymentName AllLoadedModules -VMSize Medium
 
 
 
<#
 
The Azure team is nice enough to make a nifty PowerShell module of their own. With it, it's simple to upload a package to the staging environment.
 
This easily adaptable snippet will take your package and automatically upload it to Azure.
 
#>
 
 # Import Azure
Import-Module Azure
 
 # Obviously, change these to fit your own deployment.
$myServiceName = 'myService'
$MyServiceLabels = 'Sites1', 'Sites2'
$MyDeploymentName ='MyDeployment'
 
 # Get your current deployment
$currentDeployment = Get-AzureDeployment -ServiceName $myServiceName
 
 # Pick a label for the new deployment
$newlabel = if ($currentDeployment.label -ne $myServiceLabels[0]) {
    $myServiceLabels[1]
} else {
    $myServiceLabels[0]
}
 
 # Remove the old deployment
Remove-AzureDeployment -ServiceName $myServiceName -Slot Staging -Force -ErrorAction SilentlyContinue
 
$deploymentParameters = @{
    Package= "$home\Documents\$MyDeploymentName\$MyDeploymentName.cspkg"
    Configuration = "$home\Documents\$MyDeploymentName\$MyDeploymentName.cscfg"
    Label = $newLabel
}
 
 # Put the deployment in the staging slot
New-AzureDeployment @deploymentParameters -ServiceName $mySeriveName -Slot Staging