Skip to content

Commit e695bf8

Browse files
author
Maddie Clayton
authored
Merge pull request #6760 from maddieclayton/getlocation
Fix issue with Get-Location
2 parents 36346ee + ba2fecf commit e695bf8

File tree

4 files changed

+2011
-4711
lines changed

4 files changed

+2011
-4711
lines changed

src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Common.ps1

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,24 @@ function Get-Location
584584
{
585585
param([string]$providerNamespace, [string]$resourceType, [string]$preferredLocation)
586586
$provider = Get-AzureRmResourceProvider -ProviderNamespace $providerNamespace
587-
$resourceTypes = $provider.ResourceTypes | Where-Object { $_.Name -eq $resourceType}
587+
$resourceTypes = $null
588+
if ( ( $provider.ResourceTypes -ne $null ) -and ( $provider.ResourceTypes.Count -gt 0 ) )
589+
{
590+
$nameFound = $provider.ResourceTypes[0]| Get-Member | Where-Object { $_.Name -eq "Name" }
591+
$resourceTypeNameFound = $provider.ResourceTypes[0]| Get-Member | Where-Object { $_.Name -eq "ResourceTypeName" }
592+
if ( $nameFound -ne $null )
593+
{
594+
$resourceTypes = $provider.ResourceTypes | Where-Object { $_.Name -eq $resourceType }
595+
}
596+
elseif ( $resourceTypeNameFound -ne $null )
597+
{
598+
$resourceTypes = $provider.ResourceTypes | Where-Object { $_.ResourceTypeName -eq $resourceType }
599+
}
600+
else
601+
{
602+
$resourceTypes = $provider.ResourceTypes | Where-Object { $_.ResourceType -eq $resourceType }
603+
}
604+
}
588605
$location = $resourceTypes.Locations | Where-Object { $_ -eq $preferredLocation }
589606
if ($location -eq $null)
590607
{

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/DatabaseReplicationTests.ps1

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ function Test-CreateVcoreDatabaseCopy()
121121
function Test-CreateSecondaryDatabase()
122122
{
123123
# Setup
124-
# https://github.com/Azure/azure-powershell/issues/6382
125-
#$location = Get-Location "Microsoft.Sql" "operations" "Southeast Asia"
126-
$location = 'Southeast Asia'
124+
$location = Get-Location "Microsoft.Sql" "operations" "Southeast Asia"
127125
$rg = Create-ResourceGroupForTest $location
128126
$server = Create-ServerForTest $rg $location
129127
$database = Create-DatabaseForTest $rg $server
@@ -164,9 +162,7 @@ function Test-CreateSecondaryDatabase()
164162
function Test-GetReplicationLink()
165163
{
166164
# Setup
167-
# https://github.com/Azure/azure-powershell/issues/6382
168-
#$location = Get-Location "Microsoft.Sql" "operations" "Southeast Asia"
169-
$location = 'Southeast Asia'
165+
$location = Get-Location "Microsoft.Sql" "operations" "Southeast Asia"
170166
$rg = Create-ResourceGroupForTest $location
171167
$server = Create-ServerForTest $rg $location
172168
$database = Create-DatabaseForTest $rg $server

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseReplicationTests/TestCreateSecondaryDatabase.json

Lines changed: 938 additions & 3967 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseReplicationTests/TestGetReplicationLink.json

Lines changed: 1053 additions & 737 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)