From d8308d7c987f7fb547146dcae8b587b79c2f7ecd Mon Sep 17 00:00:00 2001 From: Samuel Anudeep Date: Fri, 20 Oct 2017 18:26:31 +0530 Subject: [PATCH] Currently the Get-AzureRmStorageAccount function returns an object even if the storage account is not present. There's no way to check if a storage account is present or not. By adding this null check, the function would return $null if a storage account is not available. Otherwise, it would return $account as it used to return previously. --- .../AzureRM.Storage.ps1 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/AzureRM.Storage.ps1 b/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/AzureRM.Storage.ps1 index e19bbd05a6e4..a171ba02d465 100644 --- a/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/AzureRM.Storage.ps1 +++ b/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/AzureRM.Storage.ps1 @@ -21,9 +21,13 @@ function Get-AzureRmStorageAccount $getTask = $client.StorageAccounts.GetPropertiesAsync($ResourceGroupName, $name, [System.Threading.CancellationToken]::None) } $sa = $getTask.Result - $id = "/subscriptions/" + $context.Subscription.Id + "/resourceGroups/"+ $ResourceGroupName + "/providers/Microsoft.Storage/storageAccounts/" + $Name - $account = Get-StorageAccount $ResourceGroupName $Name $id - Write-Output $account + + if($sa -ne $null) + { + $id = "/subscriptions/" + $context.Subscription.Id + "/resourceGroups/"+ $ResourceGroupName + "/providers/Microsoft.Storage/storageAccounts/" + $Name + $account = Get-StorageAccount $ResourceGroupName $Name $id + Write-Output $account + } } END {}