Skip to content

Commit 2bc0081

Browse files
committed
Merge branch 'dev1' of https://github.com/MabOneSdk/azure-powershell into dev1
2 parents 74df7ca + 4b5d909 commit 2bc0081

File tree

5 files changed

+32
-21
lines changed

5 files changed

+32
-21
lines changed

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Container/GetAzureBackupContainer.cs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public override void ExecuteCmdlet()
5454
base.ExecuteCmdlet();
5555

5656
List<AzureBackupContainer> containers = new List<AzureBackupContainer>();
57-
bool uniqueContainer = false;
5857

5958
switch (Type)
6059
{
@@ -63,18 +62,15 @@ public override void ExecuteCmdlet()
6362
containers.AddRange(GetMachineContainers());
6463
break;
6564
case AzureBackupContainerType.AzureVM:
66-
uniqueContainer = GetManagedContainers(containers);
65+
containers.AddRange(GetManagedContainers());
6766
break;
6867
default:
6968
break;
7069
}
7170

72-
if (uniqueContainer)
71+
if (containers.Count == 1)
7372
{
74-
if (containers.Any())
75-
{
76-
WriteObject(containers.First());
77-
}
73+
WriteObject(containers.First());
7874
}
7975
else
8076
{
@@ -86,6 +82,17 @@ public override void ExecuteCmdlet()
8682
private List<AzureBackupContainer> GetMachineContainers()
8783
{
8884
List<MarsContainerResponse> marsContainerResponses = new List<MarsContainerResponse>();
85+
86+
// Machine containers are always registered.
87+
// So if requested Status is not Registered, return an empty list.
88+
// Machine containers don't have a resource group.
89+
// So, if a resource group is passed, return an empty list.
90+
if (Status != AzureBackupContainerRegistrationStatus.Registered ||
91+
!string.IsNullOrEmpty(ManagedResourceGroupName))
92+
{
93+
return new List<AzureBackupContainer>();
94+
}
95+
8996
if (string.IsNullOrEmpty(Name))
9097
{
9198
marsContainerResponses.AddRange(AzureBackupClient.ListMachineContainers());
@@ -101,8 +108,10 @@ private List<AzureBackupContainer> GetMachineContainers()
101108
}).Where(container => container.ContainerType == Type.ToString()).ToList();
102109
}
103110

104-
private bool GetManagedContainers(List<AzureBackupContainer> managedContainers)
111+
private List<AzureBackupContainer> GetManagedContainers()
105112
{
113+
List<AzureBackupContainer> managedContainers = new List<AzureBackupContainer>();
114+
106115
ContainerQueryParameters parameters = new ContainerQueryParameters();
107116
parameters.ContainerType = ManagedContainerType.IaasVM.ToString();
108117
parameters.FriendlyName = Name;
@@ -134,9 +143,7 @@ private bool GetManagedContainers(List<AzureBackupContainer> managedContainers)
134143
return new AzureBackupContainer(Vault, container);
135144
}));
136145

137-
// When container resource name and container resource group name are specified, this parameter set
138-
// identifies a container uniquely. Thus, we return just one container instead of a list.
139-
return !string.IsNullOrEmpty(Name) & !string.IsNullOrEmpty(ManagedResourceGroupName);
146+
return managedContainers;
140147
}
141148
}
142149
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/VaultCredentials/GetAzureBackupVaultCredentials.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,7 @@ public override void ExecuteCmdlet()
8888

8989
// prepare for download
9090
string fileName = string.Format("{0}_{1}.VaultCredentials", displayName, DateTime.UtcNow.ToString("yyyy-dd-M--HH-mm-ss"));
91-
string directoryPath = Path.GetDirectoryName(TargetLocation);
92-
if (directoryPath == null)
93-
{
94-
// TargetLocation is a root path
95-
directoryPath = TargetLocation;
96-
}
97-
string filePath = Path.Combine(directoryPath, fileName);
91+
string filePath = Path.Combine(TargetLocation, fileName);
9892
WriteDebug(string.Format("Saving Vault Credentials to file : {0}", filePath));
9993

10094
File.WriteAllBytes(filePath, Encoding.UTF8.GetBytes(vaultCredsFileContent));

src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/Resources.Designer.cs

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/Resources.resx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,12 @@
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120120
<data name="AzureVMNotFound" xml:space="preserve">
121-
<value>The specified Azure Virtual Machine Not Found.</value>
121+
<value>The specified Azure Virtual Machine Not Found. Possible causes are
122+
1. VM does not exist
123+
2. VM is Azure IaaS v2 VM
124+
3. The VM name or the Service name needs to be case sensitive
125+
126+
Please contact Microsoft for further assistant.</value>
122127
</data>
123128
<data name="ResourceNotFoundMessage" xml:space="preserve">
124129
<value>The specified resource does not exist.</value>

0 commit comments

Comments
 (0)