From 73f9bfecdb3766b2ba04b8b3f8bcc8c01f448180 Mon Sep 17 00:00:00 2001 From: Cephas Lin Date: Tue, 28 Feb 2017 20:16:05 +0100 Subject: [PATCH] added script --- .../deploy-deployment-slot.ps1 | 14 ++++---- app-service/deploy-ftp/deploy-ftp.ps1 | 8 ++--- .../deploy-github-continuous.ps1 | 32 +++++++++++++++++++ .../deploy-local-git/deploy-local-git.ps1 | 10 +++--- 4 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 app-service/deploy-github-continuous/deploy-github-continuous.ps1 diff --git a/app-service/deploy-deployment-slot/deploy-deployment-slot.ps1 b/app-service/deploy-deployment-slot/deploy-deployment-slot.ps1 index b4843ca9..552782ea 100644 --- a/app-service/deploy-deployment-slot/deploy-deployment-slot.ps1 +++ b/app-service/deploy-deployment-slot/deploy-deployment-slot.ps1 @@ -3,22 +3,22 @@ $webappname="mywebapp$(Get-Random)" $location="West Europe" # Create a resource group. -New-AzureRmResourceGroup -Name $webappname -Location $location +New-AzureRmResourceGroup -Name myResourceGroup -Location $location # Create an App Service plan in Free tier. New-AzureRmAppServicePlan -Name $webappname -Location $location ` --ResourceGroupName $webappname -Tier Free +-ResourceGroupName myResourceGroup -Tier Free # Create a web app. New-AzureRmWebApp -Name $webappname -Location $location ` --AppServicePlan $webappname -ResourceGroupName $webappname +-AppServicePlan $webappname -ResourceGroupName myResourceGroup # Upgrade App Service plan to Standard tier (minimum required by deployment slots) -Set-AzureRmAppServicePlan -Name $webappname -ResourceGroupName $webappname ` +Set-AzureRmAppServicePlan -Name $webappname -ResourceGroupName myResourceGroup ` -Tier Standard #Create a deployment slot with the name "staging". -New-AzureRmWebAppSlot -Name $webappname -ResourceGroupName $webappname ` +New-AzureRmWebAppSlot -Name $webappname -ResourceGroupName myResourceGroup ` -Slot staging # Configure GitHub deployment to the staging slot from your GitHub repo and deploy once. @@ -26,10 +26,10 @@ $PropertiesObject = @{ repoUrl = "$gitrepo"; branch = "master"; } -Set-AzureRmResource -PropertyObject $PropertiesObject -ResourceGroupName $webappname ` +Set-AzureRmResource -PropertyObject $PropertiesObject -ResourceGroupName myResourceGroup ` -ResourceType Microsoft.Web/sites/slots/sourcecontrols ` -ResourceName $webappname/staging/web -ApiVersion 2015-08-01 -Force # Swap the verified/warmed up staging slot into production. -Swap-AzureRmWebAppSlot -Name $webappname -ResourceGroupName $webappname ` +Swap-AzureRmWebAppSlot -Name $webappname -ResourceGroupName myResourceGroup ` -SourceSlotName staging -DestinationSlotName production \ No newline at end of file diff --git a/app-service/deploy-ftp/deploy-ftp.ps1 b/app-service/deploy-ftp/deploy-ftp.ps1 index c56fa475..6e687dc2 100644 --- a/app-service/deploy-ftp/deploy-ftp.ps1 +++ b/app-service/deploy-ftp/deploy-ftp.ps1 @@ -3,19 +3,19 @@ $webappname="mywebapp$(Get-Random)" $location="West Europe" # Create a resource group. -New-AzureRmResourceGroup -Name $webappname -Location $location +New-AzureRmResourceGroup -Name myResourceGroup -Location $location # Create an App Service plan in `Free` tier. New-AzureRmAppServicePlan -Name $webappname -Location $location ` --ResourceGroupName $webappname -Tier Free +-ResourceGroupName myResourceGroup -Tier Free # Create a web app. New-AzureRmWebApp -Name $webappname -Location $location -AppServicePlan $webappname ` --ResourceGroupName $webappname +-ResourceGroupName myResourceGroup # Get publishing profile for the web app $xml = (Get-AzureRmWebAppPublishingProfile -Name $webappname ` --ResourceGroupName $webappname ` +-ResourceGroupName myResourceGroup ` -OutputFile null) # Extract connection information from publishing profile diff --git a/app-service/deploy-github-continuous/deploy-github-continuous.ps1 b/app-service/deploy-github-continuous/deploy-github-continuous.ps1 new file mode 100644 index 00000000..4d1a4c72 --- /dev/null +++ b/app-service/deploy-github-continuous/deploy-github-continuous.ps1 @@ -0,0 +1,32 @@ +$gitrepo="" +$gittoken="" +$webappname="mywebapp$(Get-Random)" +$location="West Europe" + +# Create a resource group. +New-AzureRmResourceGroup -Name myResourceGroup -Location $location + +# Create an App Service plan in Free tier. +New-AzureRmAppServicePlan -Name $webappname -Location $location ` +-ResourceGroupName myResourceGroup -Tier Free + +# Create a web app. +New-AzureRmWebApp -Name $webappname -Location $location -AppServicePlan $webappname ` +-ResourceGroupName myResourceGroup + +# SET GitHub +$PropertiesObject = @{ + #Property = $token; +} +Set-AzureRmResource -PropertyObject $PropertiesObject ` +-ResourceId /providers/Microsoft.Web/sourcecontrols/GitHub -ApiVersion 2015-08-01 -Force + +# Configure GitHub deployment from your GitHub repo and deploy once. +$PropertiesObject = @{ + repoUrl = "$gitrepo"; + branch = "master"; +} +Set-AzureRmResource -PropertyObject $PropertiesObject -ResourceGroupName myResourceGroup ` +-ResourceType Microsoft.Web/sites/sourcecontrols -ResourceName $webappname/web ` +-ApiVersion 2015-08-01 -Force + diff --git a/app-service/deploy-local-git/deploy-local-git.ps1 b/app-service/deploy-local-git/deploy-local-git.ps1 index 474a9f0c..4e767592 100644 --- a/app-service/deploy-local-git/deploy-local-git.ps1 +++ b/app-service/deploy-local-git/deploy-local-git.ps1 @@ -3,26 +3,26 @@ $webappname="mywebapp$(Get-Random)" $location="West Europe" # Create a resource group. -New-AzureRmResourceGroup -Name $webappname -Location $location +New-AzureRmResourceGroup -Name myResourceGroup -Location $location # Create an App Service plan in `Free` tier. New-AzureRmAppServicePlan -Name $webappname -Location $location ` --ResourceGroupName $webappname -Tier Free +-ResourceGroupName myResourceGroup -Tier Free # Create a web app. New-AzureRmWebApp -Name $webappname -Location $location -AppServicePlan $webappname ` --ResourceGroupName $webappname +-ResourceGroupName myResourceGroup # Configure GitHub deployment from your GitHub repo and deploy once. $PropertiesObject = @{ scmType = "LocalGit"; } -Set-AzureRmResource -PropertyObject $PropertiesObject -ResourceGroupName $webappname ` +Set-AzureRmResource -PropertyObject $PropertiesObject -ResourceGroupName myResourceGroup ` -ResourceType Microsoft.Web/sites/config -ResourceName $webappname/web ` -ApiVersion 2015-08-01 -Force # Get app-level deployment credentials -$xml = (Get-AzureRmWebAppPublishingProfile -Name $webappname -ResourceGroupName $webappname ` +$xml = (Get-AzureRmWebAppPublishingProfile -Name $webappname -ResourceGroupName myResourceGroup ` -OutputFile null) $username = $xml.SelectNodes("//publishProfile[@publishMethod=`"MSDeploy`"]/@userName").value $password = $xml.SelectNodes("//publishProfile[@publishMethod=`"MSDeploy`"]/@userPWD").value