-
-
Save ellismg/5362960c75ef6cadb0093ce93962dd8d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module github.com/ellismg/scratch/list-locations | |
go 1.21.0 | |
require ( | |
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.2 | |
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions v1.3.0 | |
) | |
require ( | |
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 // indirect | |
github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0 // indirect | |
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect | |
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect | |
github.com/google/uuid v1.6.0 // indirect | |
github.com/kylelemons/godebug v1.1.0 // indirect | |
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect | |
golang.org/x/crypto v0.22.0 // indirect | |
golang.org/x/net v0.24.0 // indirect | |
golang.org/x/sys v0.19.0 // indirect | |
golang.org/x/text v0.14.0 // indirect | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"github.com/Azure/azure-sdk-for-go/sdk/azidentity" | |
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions" | |
) | |
func main() { | |
cred, err := azidentity.NewDefaultAzureCredential(nil) | |
if err != nil { | |
panic(err) | |
} | |
client, err := armsubscriptions.NewClient(cred, nil) | |
if err != nil { | |
panic(err) | |
} | |
pager := client.NewListLocationsPager("faa080af-c1d8-40ad-9cce-e1a450ca5b57", nil) | |
for pager.More() { | |
resp, err := pager.NextPage(context.Background()) | |
if err != nil { | |
panic(err) | |
} | |
for _, loc := range resp.Value { | |
if *loc.Metadata.RegionType != "Physical" { | |
fmt.Printf("Non Physical Region %s %s (%s)\n", *loc.Name, *loc.DisplayName, *loc.Metadata.RegionType) | |
} else if *loc.Metadata.RegionType == "Physical" && (loc.Metadata.PhysicalLocation == nil || *loc.Metadata.PhysicalLocation == "") { | |
fmt.Printf("Physical Region with No Location %s %s (%s)\n", *loc.Name, *loc.DisplayName, *loc.Metadata.RegionType) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment