Created
November 1, 2011 05:33
-
-
Save Romiko/1329995 to your computer and use it in GitHub Desktop.
Deploy CSX Package to Local Development Fabric
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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