Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 104 lines (86 sloc) 5.291 kb
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
1 param(
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
2 $subscriptionId = $env:NUGET_GALLERY_AZURE_SUBSCRIPTION_ID,
3 $serviceName = $env:NUGET_GALLERY_AZURE_SERVICE_NAME,
4 $storageServiceName = $env:NUGET_GALLERY_AZURE_STORAGE_ACCOUNT_NAME,
5 $certificateThumbprint = $env:NUGET_GALLERY_AZURE_MANAGEMENT_CERTIFICATE_THUMBPRINT,
6 $commitRevision,
66ffc51 @osbornm Pulling out commitSha and commitBranch so it can be passed in by team…
osbornm authored
7 $commitBranch
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
8 )
9
10 $ScriptRoot = (Split-Path -parent $MyInvocation.MyCommand.Definition)
11 . $ScriptRoot\_Common.ps1
12
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
13 require-param -value $subscriptionId -paramName "subscriptionId"
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
14 require-param -value $serviceName -paramName "serviceName"
15 require-param -value $storageServiceName -paramName "storageServiceName"
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
16 require-param -value $certificateThumbprint -paramName "certificateThumbprint"
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
17
18 require-module -name "WAPPSCmdlets"
19
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
20 function await-operation($operationId)
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
21 {
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
22 $status = Get-OperationStatus -SubscriptionId $subscriptionId -Certificate $certificate -OperationId $operationId
23 while ([string]::Equals($status, "InProgress"))
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
24 {
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
25 sleep -Seconds 1
26 $status = Get-OperationStatus -SubscriptionId $subscriptionId -Certificate $certificate -OperationId $operationId
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
27 }
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
28 return $status
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
29 }
30
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
31 function await-status($status)
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
32 {
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
33 $deployment = Get-Deployment -ServiceName $serviceName -Slot Staging -Certificate $certificate -SubscriptionId $subscriptionId
34 while (-not([string]::Equals($deployment.status, $status)))
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
35 {
36 sleep -Seconds 1
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
37 $deployment = Get-Deployment -ServiceName $serviceName -Slot Staging -Certificate $certificate -SubscriptionId $subscriptionId
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
38 }
39 }
40
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
41 function await-start()
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
42 {
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
43 $deployment = Get-Deployment -ServiceName $serviceName -Slot Staging -Certificate $certificate -SubscriptionId $subscriptionId
44 $roleInstances = Get-RoleInstanceStatus -ServiceName $serviceName -RoleInstanceList $deployment.RoleInstanceList -Certificate $certificate -SubscriptionId $subscriptionId
45 $roleInstancesThatAreNotReady = $roleInstances.RoleInstances | where-object { $_.InstanceStatus -ne "Ready" }
46 while ($roleInstancesThatAreNotReady.Count -gt 0)
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
47 {
48 sleep -Seconds 1
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
49 $deployment = Get-Deployment -ServiceName $serviceName -Slot Staging -Certificate $certificate -SubscriptionId $subscriptionId
50 $roleInstances = Get-RoleInstanceStatus -ServiceName $serviceName -RoleInstanceList $deployment.RoleInstanceList -Certificate $certificate -SubscriptionId $subscriptionId
51 $roleInstancesThatAreNotReady = $roleInstances.RoleInstances | where-object { $_.InstanceStatus -ne "Ready" }
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
52 }
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
53
54 $deployment = Get-Deployment -ServiceName $serviceName -Slot Staging -Certificate $certificate -SubscriptionId $subscriptionId
55 while (-not([string]::Equals($deployment.status, "Running")))
56 {
57 sleep -Seconds 1
58 $deployment = Get-Deployment -ServiceName $serviceName -Slot Staging -Certificate $certificate -SubscriptionId $subscriptionId
59 }
60 }
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
61
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
62 "Locating Git"
63 $gitCommand = get-command git;
64 if ($gitCommand -eq $null) { write-error "Cound not locate path to Git with 'Get-Command git'"; exit 1 }
65 $gitPath = $gitCommand.Definition
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
66
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
67 "Getting commit revision and branch (via '$gitPath')"
68 if ($commitRevision -eq $null) { $commitRevision = (& "$gitPath" rev-parse --short HEAD) }
69 if ($commitBranch -eq $null) { $commitBranch = (& "$gitPath" name-rev --name-only HEAD) }
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
70
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
71 "Getting Azure management certificate $certificateThumbprint"
72 $certificate = (get-item cert:\CurrentUser\MY\$certificateThumbprint)
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
73
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
74 "Building deployment name from date and revision"
75 $deploymentLabel = "$((get-date).ToString("MMM dd @ HHmm")) ($commitRevision on $commitBranch; auto-deployed)"
76 $deploymentName = "$((get-date).ToString("yyyyMMddHHmmss"))-$commitRevision-$commitBranch-auto"
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
77
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
78 "Locating Azure package and configuration"
79 $packageLocation = join-path (resolve-path(join-path $ScriptRoot "..")) "_AzurePackage"
80 $cspkgFile = join-path $packageLocation "NuGetGallery.cspkg"
81 $cscfgFile = join-path $packageLocation "NuGetGallery.cscfg"
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
82
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
83 "Checking for existing staging deployment on $serviceName"
84 $deployment = Get-Deployment -ServiceName $serviceName -Slot Staging -Certificate $certificate -SubscriptionId $subscriptionId
85 if ($deployment -ne $null) {
86 "Deleting existing staging deployment $deployment.Name on $serviceName"
87 $operationId = (remove-deployment -subscriptionId $subscriptionId -certificate $certificate -slot Staging -serviceName $serviceName ).operationId
88 await-operation($operationId)
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
89 }
90
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
91 "Creating new staging deployment $deploymentName on $serviceName"
92 $operationId = (new-deployment -subscriptionId $subscriptionId -certificate $certificate -ServiceName $serviceName -storageServiceName $storageServiceName -slot Staging -Package $cspkgFile -Configuration $cscfgFile -Name $deploymentName -Label $deploymentLabel).operationId
93 await-operation($operationId)
94 await-status("Suspended")
1182929 @osbornm Converting PS1 files to UTF8
osbornm authored
95
6f0442b @half-ogre changed the deploy script to use the staging slot and not take down t…
half-ogre authored
96 "Starting staging deployment $deploymentName on $serviceName"
97 $operationId = (set-deploymentstatus -subscriptionId $subscriptionId -serviceName $serviceName -slot Staging -status Running -certificate $certificate).operationId
98 await-operation($operationId)
06f64f1 @half-ogre added command to swap staging for production to deploy script
half-ogre authored
99 await-start
100
101 "Moving staging deployment $deploymentName to productionon on $serviceName"
102 move-deployment -subscriptionId $subscriptionId -serviceName $serviceName -certificate $certificate -name $deploymentName
103
Something went wrong with that request. Please try again.