user61307
user61307

Reputation: 325

Azure Powershell - How to do a Github Sync?

I'm new to Azure Powershell and could use some help. (I haven't had any luck to date with the documentation or Googling for answers.)

We have 3 slots for one of our Azure Websites: beta, staging and production. Beta is used for day-to-day development, staging is a warmed-up ready to go hot-swap for production. We have our Github repository linked to beta, so that commits to the master branch automatically get deployed to beta. Everything works. Cool.

OK, let's say we're ready to call a version on beta releasable.

What I want is a very simple, automated way to say "Push beta to staging, and swap into production, and make staging and production this current version of beta".

That is, a way to say "copy this deployment on the beta slot over to staging and/or production" via an Azure Powershell script. I bet there are multiple ways to do this - it could certainly take the form of a swap between beta and staging but then I want to programmatically re-issue a sync or deploy to keep beta "fresh". But right now, I'm doing it all via the UI, which is cumbersome and error-prone.

How do I do that? Is there an Azure Powershell command that is equivalent to the "sync with repository" that exists in the UX? Thanks.

Upvotes: 1

Views: 297

Answers (1)

Greg Levenhagen
Greg Levenhagen

Reputation: 924

Referencing the link https://azure.microsoft.com/en-us/documentation/articles/web-sites-staged-publishing/, near the bottom of the page it has some scenarios for Swapping, Creating and Deleting deployment slots using PowerShell and the Azure CLI.

Specifically, it looks like the following might help you.

Swap deployment slots

$ParametersObject = @{targetSlot = "[slot name – e.g. “production”]"} 
Invoke-AzureRmResourceAction 
-ResourceGroupName [resource group name]
-ResourceType Microsoft.Web/sites/slots 
-ResourceName [web app name]/[slot name] 
-Action slotsswap 
-Parameters $ParametersObject
-ApiVersion 2015-07-01

For additional reference on Invoke-AzureRmResourceAction, here is a link to MSDN https://msdn.microsoft.com/en-us/library/azure/mt652481.aspx.

Upvotes: 1

Related Questions