Skip to content
Related Articles

Related Articles

Improve Article

Microsoft Azure – Azure App Servers Routing using PowerShell

  • Last Updated : 09 Jul, 2021

In this article, we will look into how to add logic to your testing and production sites with PowerShell.  I Azure, you could split the traffic that goes between your staging slot on your production slot by defining routing rules inside the Azure portal. Now, what if you wanted to do this programmatically via maybe a PowerShell script. 

One of the things that we could do is head over to the Azure CLI website, and we can install the PowerShell modules that allow us to programmatically manage our resources inside the cloud. 

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



Now that’s complete we’ll go back over to the Azure Portal. Here we’ll need to just refresh the page real quick. When we head back over to the testing and production section you should see now our values have changed to 90% to staging and 10% to production. 

Now, what if we want to have more fine-grained control over how these changes happen. We’ll head over to a second PowerShell tab and we 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%. Let’s go ahead and run this. 

That script is complete and just like before we are going to refresh the 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 you can control the azure app servers routing rules for your staging slots using PowerShell.

My Personal Notes arrow_drop_up
Recommended Articles
Page :