Tuesday, July 13, 2021

Upgrade app service plan and restart webjobs using Azure AZ

# Variables

$ResourceGroupName  = "efgh001"

$WebAppName = "abcd001"

$WebAppServicePlanName = "wxyz001"

$tier = "PremiumV2"

$workerSize = "Large"


# Display current webapp service plan size

$myAppServicePlan = Get-AzAppServicePlan -Name $WebAppServicePlanName -ResourceGroupName $ResourceGroupName

Write-Host "Current AppServicePlan Size is"  $myAppServicePlan.Sku.Size


#Stoping webjobs by setting WEBJOBS_STOPPED to 1 

$myWebApp = Get-AzWebApp -ResourceGroupName $ResourceGroupName -Name $WebAppName

$appsettingsCurrent =  $myWebApp.SiteConfig.AppSettings

$appSettingsNew = @{}

foreach ($kvp in $appsettingsCurrent) {

$appSettingsNew[$kvp.Name] = $kvp.Value

}

$appSettingsNew["WEBJOBS_STOPPED"] = "1"

Set-AzWebApp -ResourceGroupName $ResourceGroupName -Name $WebAppName -AppSettings $appSettingsNew  


#Upgrade AppServicePlan size

Set-AzAppServicePlan -Name $WebAppServicePlanName -ResourceGroupName $ResourceGroupName -Tier $tier  -WorkerSize $workerSize


# Display updated webapp service plan size

$myAppServicePlan = Get-AzAppServicePlan -Name $WebAppServicePlanName -ResourceGroupName $ResourceGroupName

Write-Host "Updated AppServicePlan Size is"  $myAppServicePlan.Sku.Size


#Starting webjobs by setting WEBJOBS_STOPPED to 0 

$myWebApp = Get-AzWebApp -ResourceGroupName $ResourceGroupName -Name $WebAppName

$appsettingsCurrent =  $myWebApp.SiteConfig.AppSettings

$appSettingsNew = @{}

foreach ($kvp in $appsettingsCurrent) {

$appSettingsNew[$kvp.Name] = $kvp.Value

}

$appSettingsNew["WEBJOBS_STOPPED"] = "0"

Set-AzWebApp -ResourceGroupName $ResourceGroupName -Name $WebAppName -AppSettings $appSettingsNew

Wednesday, November 23, 2016

First matching record using XPATH query

In order to select first matching record found using XPATH query I used

(//div[@class='container']//h1[@class='page-header'])[1]   instead of //div[@class='container']//h1[@class='page-header'][1]

Thursday, November 10, 2016

Web Request using PowerShell and Parse JSON response as PowerShell object

To send web request and read JSON response using PowerShell I used following commands

$response = Invoke-WebRequest -Uri "http://myserver.com" -Method Get -Headers @{"apikey"="toekn"}
$responseAsPSObject = $response.Content | ConvertFrom-Json
$myValue = $responseAsPSObject.Value."mykey"
Write-Host "$myValue"


Monday, June 27, 2016

Stop IIS Apppool only when it is Started using appcmd

In order to stop IIS apppool using appcmd only when apppool is started I used following command

%windir%\system32\inetsrv\appcmd list apppool /name:MyAppPoolName /state:Started /xml | %windir%\system32\inetsrv\appcmd stop apppool /in


Wednesday, June 22, 2016

Robocopy exit code 0

In order Robocopy to exit code 0, I used following

(robocopy C:\Source D:\Destionation /e /move /np /njh /njs) ^& IF %ERRORLEVEL% LEQ 4 exit /B 0

Tuesday, June 21, 2016

Get text from the textbox using Selenium 2.0

In order to get text from the textbox using Selenium 2.0 I used following

String myText = driver.FindElement(By.XPath("//input[@id='myTextBox']")).GetAttribute("value");

Wednesday, June 08, 2016

Get parameter and enviornment variable in Jenkins 2.0 pipeline job's Groovy script

In order to get Pipeline job parameter (defined by user) in the Groovy script I used following

${ENV:environment}

while to get enviornment variables to the Pipeline job I used following

$env.BUILD_NUMBER