Get Azure SQL Database Information From Web App With PowerShell [ENG]

By | 15 January 2019

Hi Again,

I am going to talk about web apps in this article. Sometimes you need to understand web apps and azure SQL database relationship. It is easy to find out with Azure portal.

But if you need this relationship when you write PowerShell script you need to figure it out how can you get this relational resource information from a resource.

So In this article I am gonna show you how can you use relationships to get necessary information via PowerShell for azure app service plan, azure web app and azure sql database .

 

First of all, every web app need App Service Plan to work. Because App service Plan has all component to host web apps.

So we can start to work with app service plan to get some information via PowerShell.

For Azure login process, we can use the command below;

After the login process, we can start to get all app service plan  with the command below. (If you want to filter this process for getting spesific app service plan, you can use Name parameter)

$appServicePlan = Get-AzureRmAppServicePlan

To get each app service plan and their web apps, you need to use foreach loops two times. one for app service plan, other for web apps.  From the web apps you can easly learn which azure sql database use with this web app. You can find necessary information top of each command. So you can easly understand why I use this command.

As you can see, we get SQL Server database information with PowerShell from a web app. So you specify database information for a web app. Also you can easily draw a graph about this relational resources.

This is very important when you want to migrate resources between subscriptions. Because relational resources have to migrate another subscription together. Otherwise you get error during migration process.

I hope this help.

Regards

Firat

 

Leave a Reply