Skip to content

Instantly share code, notes, and snippets.

@Romiko
Created November 1, 2011 05: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 Romiko/1329995 to your computer and use it in GitHub Desktop.
Save Romiko/1329995 to your computer and use it in GitHub Desktop.
Deploy CSX Package to Local Development Fabric
#requires -version 2.0
param (
[parameter(Mandatory=$true)] [string]$AzurePackagePath,
[parameter(Mandatory=$true)] [string]$AzureSdkRootPath,
[parameter(Mandatory=$true)] [int]$RetryCountForPolling
)
$ErrorActionPreference = "Stop"
$csrun="$AzureSdkRootPath\bin\csrun.exe"
#Azure DEV TEAM should wake up and smell the coffee, 1.5SDK is unencrypted cspkg, so why does csrun not support using cspkg and only csx!
$CSXFolder="$AzurePackagePath\MyStory.Azure.csx"
$serviceConfigurationFile = "$AzurePackagePath\ServiceConfiguration.cscfg"
Write-Verbose "CSX folder is $CSXFolder"
Write-Verbose "Service configuration is $serviceConfigurationFile"
function StartAzure{
"Starting Azure development fabric"
& $csrun /devFabric:start
& $csrun /devStore:start
}
function StopAzure{
"Shutting down development fabric"
& $csrun /devFabric:shutdown
& $csrun /devStore:shutdown
}
function DeployAzure{
"Deploying the package"
& $csrun $CSXFolder $serviceConfigurationFile
if (-not $?)
{
throw "The deployment process returned an error code."
}
}
function PollDeployment{
$waitInterval = [System.TimeSpan]::FromSeconds(60)
# Give it 60s to boot up neo4j
[System.Threading.Thread]::Sleep($waitInterval)
# Hit the homepage to make sure it's warmed up
$retryCount = 0
$maxRetry = $RetryCountForPolling
$url = "http://localhost:81/debug/neo4j-endpoint"
while ($retryCount -le $maxRetry)
{
try
{
(New-Object System.Net.WebClient).DownloadString("$url") | Out-Null
Write-Verbose "Site seems to be up and running at $url"
break;
}
catch
{
Write-Verbose "Could not connect to web deployment, retry count $retryCount/$maxRetry"
Write-Verbose "60 seconds until next retry"
}
if($retryCount -ge $maxRetry)
{
throw
}
$retryCount = $retryCount + 1
[System.Threading.Thread]::Sleep($waitInterval)
}
}
Write-Host "Beginning deploy and configuration at" (Get-Date)
StopAzure
StartAzure
DeployAzure
PollDeployment
Write-Host "Completed deploy and configuration at" (Get-Date)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment