5

Is it possible to configure a source control repository to deploy code to an Azure Web App slot via Powershell. (or even just the primary site)

Ideally for v2 / ARM but I'm willing to consider anything at the moment!

I have looked through the commands available in AzureRM.Websites module and there doesn't appear to be anything.

P.S. I know this is possible via template, I am currently looking for pure Powershell commands.

Michael B
  • 11,887
  • 6
  • 38
  • 74

2 Answers2

4

You can do it using the 'low level' ARM CmdLets. e.g. for the main site:

$props = @{
    RepoUrl = $repoUrl
    Branch = "master"
}

New-AzureRmResource -ResourceGroupName $ResourceGroupName -ResourceType Microsoft.Web/sites/SourceControls -Name $SiteName/Web -PropertyObject $props -ApiVersion 2015-08-01 -Force

And for a slot (using same $props):

New-AzureRmResource -ResourceGroupName $ResourceGroupName -ResourceType Microsoft.Web/sites/slots/sourcecontrols -Name $SiteName/$SlotName/Web -PropertyObject $props -ApiVersion 2015-08-01 -Force

See also sample helper method here. That one sets IsManualIntegration = true, which is for repos you don't own, and requires a manual sync. For continuous deployment, leave IsManualIntegration out.

David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • This is exactly what I was looking for (well, this and @ŁukaszKałużny 's answer) but since you answered first - albeit by a few minutes! – Michael B Jan 03 '16 at 17:04
2

You need to use New-AzureRmResource command.

$webappname = "name of your webapp"
$RepoUrl = "https://github.com/davidebbo-test/Mvc52Application.git"
$branch = "master"
$location = "location of your webapp "
$resourceGroupName = "name of resource group with your webapp"
New-AzureRmResource -Location $location -Properties @{"RepoUrl"="$RepoUrl";"branch"="$branch";"IsManualIntegration"="true"} -ResourceName $webappname -ResourceType Microsoft.Web/sites/sourcecontrols/web -ResourceGroupName $resourceGroupName -ApiVersion 2015-08-01-preview