I have an Azure AppService (Web-Site microservice) created from an ARM template. It contains a drupal app. I have configured it to read from a git server in bitbucket. When I create for first time it sucessfully pull the files from bitbucket (master branch). All good :-) The App Service is created from a PowerShell script that uses ARM templates launched from Jenkins project. The project is called ReCreateXXXAppService and executes a PowerShell that detects if AppService is there, delete it if that is the case, and deploy it again.
This is the summary of my code around New-AzureRmResourceGroupDeployment:
$repoUrl = "https://"+$AppServiceUsername+":"+$AppServicePassword+"@bitbucket.org/XXX/as-cms.git"
$params = @{siteName=$AppServiceName ; hostingPlanName="$($AppServiceName)-HP"; siteLocation=$AppServiceLocationName; repoUrl=$repoUrl; branch="master";}
$templateFile = Join-Path $scriptDir "templates\$TemplateName"
Write-Host "Using template file $TemplateFile"
New-AzureRmResourceGroupDeployment -Mode Complete -Force -TemplateParameterObject $params -Name "$($AppServiceName)-dn" -ResourceGroupName $azureResourceGroupName -TemplateFile $templateFile
When I change something in master branch I have two options:
- Automated: Execute RecreateXXXAppService again in Jenkins, wait around 1-2 mins (while App Service is detected, deleted and created) and I have the change deployed.
- Manually: Go to azure portal, select App Service, Continuous Deployment and click Sync. It takes 15-20 secs only. (Check screenshot)
My question is:
How can I automate from PowerShell the equivalent of clicking "Sync" button?
NOTE1: There is a similar question here, with no answer.
NOTE2: The template part for source control creation is this one:
{
"apiVersion": "2014-04-01",
"name": "web",
"type": "sourcecontrols",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', parameters('siteName'))]",
"[concat('Microsoft.Web/Sites/', parameters('siteName'), '/config/web')]"
],
"properties": {
"RepoUrl": "[parameters('repoUrl')]",
"branch": "[parameters('branch')]",
"IsManualIntegration": true
}
}
NOTE3: I tried @MichaelB answer with no luck. It seems working but doesn't update the files. Output is
Name : as-xxxx-dev01
ResourceId : /subscriptions/a303bbb8-8c07-wq10-8a6a-6c1eceef81bb/resourceGroups/as-rg-xxxx-EUN-DEV01/providers/Microsoft.Web/sites/as-cms-dev01/sourcecontrols/web
ResourceName : as-xxxx-dev01/web
ResourceType : Microsoft.Web/sites/sourcecontrols
ResourceGroupName : as-rg-xxxx-EUN-DEV01
Location : North Europe
SubscriptionId : a303ibb8-7i77-41d0-8a2s-6c1aaaaf81aa
Tags : {System.Collections.Hashtable}
Properties : @{RepoUrl=https://deployments:*******@bitbucket.org/project/as-xxxx.git; Branch=master; IsManualIntegration=False; DeploymentRollbackEnabled=False;
IsMercurial=False; ProvisioningState=Succeeded}