Skip to content

Commit ecea8a1

Browse files
committed
Adding checks for null values of subscription ID and storage account name
1 parent 6b5309b commit ecea8a1

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/Commands.RecoveryServices.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@
7171
<SpecificVersion>False</SpecificVersion>
7272
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Common.1.4.0\lib\net45\Microsoft.WindowsAzure.Common.NetFramework.dll</HintPath>
7373
</Reference>
74-
<Reference Include="Microsoft.WindowsAzure.Management.Storage">
75-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Storage.3.1.0\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
74+
<Reference Include="Microsoft.WindowsAzure.Management.Storage, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
75+
<SpecificVersion>False</SpecificVersion>
76+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Storage.3.0.0\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
7677
</Reference>
7778
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
7879
<SpecificVersion>False</SpecificVersion>

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/PSRecoveryServicesClient/PSRecoveryServicesClientHelper.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ public class PSRecoveryServicesClientHelper
3333
/// <param name="azureSubscriptionId">Azure Subscription ID</param>
3434
public static void ValidateSubscriptionAccountAssociation(string azureSubscriptionId)
3535
{
36+
if (string.IsNullOrEmpty(azureSubscriptionId))
37+
{
38+
throw new InvalidOperationException(
39+
string.Format(
40+
Properties.Resources.SubscriptionIdIsNotValid));
41+
}
42+
3643
bool associatedSubscription = false;
3744
ProfileClient pc = new ProfileClient();
3845
List<AzureSubscription> subscriptions =
@@ -62,6 +69,13 @@ public static void ValidateSubscriptionAccountAssociation(string azureSubscripti
6269
/// <param name="azureStorageAccount">Storage Account details</param>
6370
public static void ValidateStorageAccountAssociation(string azureStorageAccount)
6471
{
72+
if (string.IsNullOrEmpty(azureStorageAccount))
73+
{
74+
throw new InvalidOperationException(
75+
string.Format(
76+
Properties.Resources.StorageAccountNameIsNotValid));
77+
}
78+
6579
bool associatedAccount = false;
6680

6781
SubscriptionCloudCredentials creds

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/Properties/Resources.Designer.cs

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

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/Properties/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,4 +212,10 @@ ClientRequestId: {3}</value>
212212
<data name="ReplicationStartTimeInvalid" xml:space="preserve">
213213
<value>Replication Start Time span value cannot be greater then 24 hours.</value>
214214
</data>
215+
<data name="StorageAccountNameIsNotValid" xml:space="preserve">
216+
<value>Please enter the storage account name details in the protection profile.</value>
217+
</data>
218+
<data name="SubscriptionIdIsNotValid" xml:space="preserve">
219+
<value>Please enter the subscription ID details.</value>
220+
</data>
215221
</root>

0 commit comments

Comments
 (0)