Skip to content

Commit e0e786f

Browse files
author
maddieclayton
authored
Merge pull request Azure#5047 from matthchr/feature/fix-resourcegroup-bug
Fix Batch account operations bug
2 parents d7f9d8f + be39304 commit e0e786f

File tree

5 files changed

+3638
-404
lines changed

5 files changed

+3638
-404
lines changed

src/ResourceManager/AzureBatch/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Fixed a bug where account operations without a resource group failed to auto-detect the resource group.
2122

2223
## Version 4.0.1
2324
* Fixed assembly loading issue that caused some cmdlets to fail when executing

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/BatchAccountTests.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ function Test-BatchAccountEndToEnd
6363
Assert-AreEqual 1 $updatedAccount.Tags.Count
6464
Assert-AreEqual $newTagValue $updatedAccount.Tags[$newTagName]
6565

66-
# Get the account keys
66+
# Get the account keys (without resource group)
67+
$accountWithKeys = Get-AzureRmBatchAccountKeys -Name $accountName
68+
Assert-NotNull $accountWithKeys.PrimaryAccountKey
69+
Assert-NotNull $accountWithKeys.SecondaryAccountKey
70+
71+
# Get the account keys (with resource group)
6772
$accountWithKeys = Get-AzureRmBatchAccountKeys -Name $accountName -ResourceGroupName $resourceGroup
6873
Assert-NotNull $accountWithKeys.PrimaryAccountKey
6974
Assert-NotNull $accountWithKeys.SecondaryAccountKey
@@ -80,8 +85,8 @@ function Test-BatchAccountEndToEnd
8085
{
8186
# Delete the account
8287
Remove-AzureRmBatchAccount -Name $accountName -ResourceGroupName $resourceGroup -Force
83-
$errorMessage = "The Resource 'Microsoft.Batch/batchAccounts/$accountName' under resource group '$resourceGroup' was not found."
84-
Assert-Throws { Get-AzureRmBatchAccount -Name $accountName -ResourceGroupName $resourceGroup } $errorMessage
88+
$errorMessage = "The specified account does not exist."
89+
Assert-ThrowsContains { Get-AzureRmBatchAccount -Name $accountName -ResourceGroupName $resourceGroup } $errorMessage
8590
}
8691
finally
8792
{

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/Common.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ function Get-BatchAccountProviderLocation($index)
5252
{
5353
$namespace = "Microsoft.Batch"
5454
$type = "batchAccounts"
55-
$r = Get-AzureRmResourceProvider -ProviderNamespace $namespace | where {$_.ResourceTypes[0].ResourceTypeName -eq $type}
55+
$r = Get-AzureRmResourceProvider -ProviderNamespace $namespace | where {$_.ResourceTypes[0].ResourceTypeName -eq $type}
5656
$location = $r.Locations
5757

58-
if ($location -eq $null)
58+
if ($location -eq $null)
5959
{
60-
return "westus"
60+
return "westus"
6161
}
6262
else
6363
{
@@ -67,7 +67,7 @@ function Get-BatchAccountProviderLocation($index)
6767
}
6868
else
6969
{
70-
return $location[$index]
70+
return $location[$index]
7171
}
7272
}
7373
}

0 commit comments

Comments
 (0)