Share via

How do I export azure app services with virtual IP address in one go?

Abhinav 0 Reputation points
2023-06-15T13:49:24.6833333+00:00

I'm trying to export all Azure app service name with Virtual IP Address using below script but somehow it's not happening. Can someone help me identify /correctify me where am I getting it wrong?

If there's any direct way to do the same. Thanks in advance!!!

$a = Get-AzSubscription

foreach ($b in $a.Name){Set-AzContext -Subscription $b

Import-Csv C:\Users\DA400351\Downloads\Azureresources.csv| ForEach-Object {

$IP = Get-AzWebApp -ResourceGroupName $.r -Name $.n -ErrorAction SilentlyContinue | select DefaultHostName

foreach ($m in $IP) {Resolve-DnsName $IP.DefaultHostName | select -Property Name,IP4Address}

Export-Csv C:\Users\s-pandeyab\Downloads\sites.csv

}}

Azure App Service
Azure App Service

Azure App Service is a service used to create and deploy scalable, mission-critical web apps.


1 answer

Sort by: Most helpful
  1. Anonymous
    2023-06-15T14:12:01.8833333+00:00

    Hi thanks for the question

    The inbound IP for a regular app service is fixed (see here) although there are cases it can change (see here)

    So a simple nslookup as per the link above for the default name for your web app (e.g. [myapp].azurewebsites.net) should be enough

    If you want a static ip you can add an IPSSL binding (see here)

    So you need a script that iterates subscriptions
    for each subscription then the resources
    for the resource which is type web app then you can use the cmd almost as you noted, for example

    Get-AzWebApp -ResourceGroupName "demo" -Name "demo-webapp" | select EnabledHostNames

    As a default (without custom names) that would return the default host name and the default kudu (SCM) host name, both these default names should have the same VIP

    You could add a filter to grab just the "azurewebsites.net" name to test

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.