The below script is provided to start the Webjobs in the azure.But I am including the Json file into the Powershell script and running the Webjobs.Its good for only one environment.But I want the same script to be used for multiple environments with different Webjob names.So how can I modify this script so that I can stop and start the Webjobs in VSTS at release definition,Currently,I have 4 Webjobs for Dev Environment and I have 8 Webjobs for Int Environment with different azure subscriptions.So how can I use the below script for different environments.Kindly help me on this.I can't use the below script for all the environments because I am importing the only one json file.So it will only accept the particular json parameters.But in my case the json parameters would be different for different environments.So how can I import different json file contents into the below script? Is there is any possibility to include multiple json files and script can only accept particular Json script based on the environment which I run at the release definition in VSTS and can run accordingly.
Parameter.json:
{
"userName": "user1",
"password": "password1",
"webAppName": "webapp1",
"resourceGroup": "resourceGroup1",
"webJobs": [
{
"name": "abc",
"typeName": "continuous"
},
{
"name": "def",
"typeName": "continuous"
}
]
}
Script:
[object]$paramObj=Get-Content "PowerShellModuleProject1\parameter2.json"|ConvertFrom-Json
$userName =$paramObj.userName
$password =$paramObj.password
$webAppName =$paramObj.webAppName
$resourceGroup=$paramObj.resourceGroup
[object[]]$webJobs=$paramObj.webJobs
foreach($wj in $webjobs){
if($wj.typeName -eq "continuous")
{
Invoke-AzureRmResourceAction -ResourceGroupName $resourceGroup -ResourceType Microsoft.Web/sites/ContinuousWebJobs -ResourceName "$webAppName/$($wj.name)" -Action start -ApiVersion 2015-08-01 -Force
Write-Host "continuous"
Write-Host $wj.name
}
else{
Invoke-AzureRmResourceAction -ResourceGroupName $resourceGroup -ResourceType Microsoft.Web/sites/TriggeredWebJobs -ResourceName "$webAppName/$($wj.name)" -Action run -ApiVersion 2015-08-01 -force
Write-Host "triggered"
Write-Host $wj.name
}
}