Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AzRecoveryServices.Backup] Adding null check for target storage account #13681

Merged
merged 3 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ public static T GetOperationStatus<T>(RestAzureNS.AzureOperationResponse respons
while (opStatusResponse.Body.Status ==
ServiceClientModel.OperationStatusValues.InProgress)
{
if (String.Compare(testMode, "Playback", StringComparison.OrdinalIgnoreCase) != 0 && !TestMockSupport.RunningMocked)
if (!TestMockSupport.RunningMocked)
{
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
}
if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0)
{
Thread.Sleep(5000);
}

opStatusResponse = getOpStatus(operationId);
}

Expand Down Expand Up @@ -79,7 +84,11 @@ public static T GetOperationStatus<T, S>(RestAzureNS.AzureOperationResponse<S> r
while (opStatusResponse.Body.Status ==
ServiceClientModel.OperationStatusValues.InProgress)
{
if (String.Compare(testMode, "Playback", StringComparison.OrdinalIgnoreCase) != 0 && !TestMockSupport.RunningMocked)
if (!TestMockSupport.RunningMocked)
{
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
}
if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0)
{
Thread.Sleep(5000);
}
Expand Down Expand Up @@ -109,10 +118,15 @@ public static RestAzureNS.AzureOperationResponse GetOperationResult(
string testMode = Environment.GetEnvironmentVariable("AZURE_TEST_MODE");
while (opStatusResponse.Response.StatusCode == SystemNet.HttpStatusCode.Accepted)
{
if (String.Compare(testMode, "Playback", StringComparison.OrdinalIgnoreCase) != 0 && !TestMockSupport.RunningMocked)
if (!TestMockSupport.RunningMocked)
{
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
}
if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0)
{
Thread.Sleep(5000);
}

opStatusResponse = getOpStatus(operationId);
}

Expand All @@ -139,10 +153,15 @@ public static RestAzureNS.AzureOperationResponse<T> GetOperationStatusDataMove<T
string testMode = Environment.GetEnvironmentVariable("AZURE_TEST_MODE");
while (opStatusResponse.Body.Status == "InProgress")
{
if (String.Compare(testMode, "Playback", StringComparison.OrdinalIgnoreCase) != 0 && !TestMockSupport.RunningMocked)
if (!TestMockSupport.RunningMocked)
{
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
}
if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0)
{
Thread.Sleep(5000);
}

opStatusResponse = getOpStatus(operationId);
}
opStatusResponse = getOpStatus(operationId);
Expand All @@ -168,10 +187,15 @@ public static RestAzureNS.AzureOperationResponse<T> GetOperationResult<T>(
string testMode = Environment.GetEnvironmentVariable("AZURE_TEST_MODE");
while (opStatusResponse.Response.StatusCode == SystemNet.HttpStatusCode.Accepted)
{
if (String.Compare(testMode, "Playback", StringComparison.OrdinalIgnoreCase) != 0 && !TestMockSupport.RunningMocked)
if (!TestMockSupport.RunningMocked)
{
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
}
if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0)
{
Thread.Sleep(5000);
}

opStatusResponse = getOpStatus(operationId);
}
opStatusResponse = getOpStatus(operationId);
Expand Down Expand Up @@ -212,10 +236,15 @@ public static RestAzureNS.AzureOperationResponse<T> GetOperationResult<T>(
string testMode = Environment.GetEnvironmentVariable("AZURE_TEST_MODE");
while (opStatusResponse.Response.StatusCode == SystemNet.HttpStatusCode.Accepted)
{
if (String.Compare(testMode, "Playback", StringComparison.OrdinalIgnoreCase) != 0 && !TestMockSupport.RunningMocked)
if (!TestMockSupport.RunningMocked)
{
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
}
if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0)
{
Thread.Sleep(5000);
}

opStatusResponse = getOpStatus(operationId);
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -613,4 +613,7 @@ Please contact Microsoft for further assistance.</value>
<data name="TargetResourcegroupNotSupported" xml:space="preserve">
<value>Target ResourceGroup is not applicable and restore will proceed as unmanaged disk restore since this is unmanaged VM</value>
</data>
<data name="InvalidTargetStorageAccount" xml:space="preserve">
<value>Please provide a vaild target storage account</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,14 @@ public RestAzureNS.AzureOperationResponse TriggerRestore()
GenericResource targetStorageAccountResource = null;
string targetStorageAccountLocation = null;
if (targetStorageAccountName != null)
{
{
targetStorageAccountResource = ServiceClientAdapter.GetStorageAccountResource(targetStorageAccountName);

if(targetStorageAccountResource == null)
{
throw new ArgumentException(string.Format(Resources.InvalidTargetStorageAccount));
}

targetStorageAccountLocation = targetStorageAccountResource.Location;
}

Expand All @@ -209,6 +215,7 @@ public RestAzureNS.AzureOperationResponse TriggerRestore()
RestoreFileSpecs restoreFileSpec = new RestoreFileSpecs();
AzureFileShareRestoreRequest restoreRequest = new AzureFileShareRestoreRequest();
restoreRequest.CopyOptions = copyOptions;

restoreRequest.SourceResourceId = storageAccountResource.Id;
if (sourceFilePath != null)
{
Expand Down
Loading