Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

Microsoft Azure – Testing in Production Sites Feature using PowerShell

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

In this article, we will learn how to add logic to your testing and production sites with PowerShell. Now, if you wanted to do this programmatically via a PowerShell script follow the below-given steps.


Follow the below steps to add logic to testing production sites with PowerShell:

Step 1: Head over to the Azure CLI website and we can install the PowerShell modules that allow us to programmatically manage our resources inside of the cloud. 

Step 2: Now, as we already have it installed. We are going to open a local PowerShell instance in our machine and using the script we are going to set our staging slot to receive 90% of the traffic instead of 50%.

$ruleList=New-Object-TypeName System.Collections.Generic.List[Microsoft.WindowsAzure.Commands.Utilities.Web
$rule=New-Object-TypeName Microsoft.WindowsAzure>Commands.Utilities.Websites.Services.WebEntities.RampUpRule
Set-AzureWebsite-RoutingRules $ruleList -Name $siteName -slot production

Now that’s complete, we will go back over to the Azure Portal. What we need to do is just refresh this page.

Step 3: When we head back over to the testing and production section we shall see how our values have changed to 90% to staging and 10% to production. 

Step 4:Now, if we want to have more fine-grained control over how these changes happen. We will head over to a second PowerShell tab and have a second script there. What it does is that every 60 minutes it’ll increase the amount of traffic that goes over to our staging slot by 5%. So, let us go ahead and run this. 

$rule1=New-Object Microsoft.WindowsAzure.Commands.Utilities.Websites.Services.WebEntities.RampUpRule
Set-AzureWebsite $siteName -Slot Production -RoutingRules $rule1

That script is complete and just like before, we are going to refresh this page quickly. Now that we’ve run that script every 60 seconds we’ll slowly see more and more traffic heading over to our staging slot.

And that’s how we can control the azure app servers routing rules for our staging slots using PowerShell.

My Personal Notes arrow_drop_up
Last Updated : 03 Apr, 2023
Like Article
Save Article
Similar Reads
Related Tutorials