mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
Backup/Restore Managed Instance (#1428)
* Enabled backup to and restore from URL * Created RPC, but when process tries to load Microsoft.Azure.Storage.Blob.dll, it crashes * Added create shared access token * Code refactor * Minor changes * Changed RPC path * Moved createSas RPC to the newly created BlobService, fixed PR comments * Added sas expiration date parameter to the RPC * Added copyright headers * Removed ConnectionInstance property from BlobService * Removed unhelpful comment * Removed unused using statements * Changed copy/paste comments * Disposable objects fix * Small formatting fix * Changed backup to/restore from url supported device types * Added backup to url integration test * Created restore integration test. Test are now getting azure blob params from env variables instead of file. * Culture invariant epiration date param, fixed comment, and typo * Updated headers * PR comments fix * Changed supported device type logic * string localization fix * String formatting fix * build failure fix * Typo * Updated supported restore device types
This commit is contained in:
committed by
GitHub
parent
35e1782a3f
commit
881c335cdf
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
{
|
||||
public class AzureBlobConnectionSetting
|
||||
{
|
||||
|
||||
public string BlobContainerUri { get; set; }
|
||||
|
||||
public string AccountKey { get; set; }
|
||||
|
||||
public string AccountName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,12 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
{
|
||||
public const string SqlConectionSettingsEnvironmentVariable = "SettingsFileName";
|
||||
|
||||
public const string AzureStorageAccountKey = "AzureStorageAccountKey";
|
||||
|
||||
public const string AzureStorageAccountName = "AzureStorageAccountName";
|
||||
|
||||
public const string AzureBlobContainerUri = "AzureBlobContainerUri";
|
||||
|
||||
/// <summary>
|
||||
/// Environment variable used to get the TSDATA source directory root.
|
||||
/// K2 is under it.
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Test.Common
|
||||
{
|
||||
public class TestAzureBlobConnectionService
|
||||
{
|
||||
private static Lazy<TestAzureBlobConnectionService> instance = new Lazy<TestAzureBlobConnectionService>(() => new TestAzureBlobConnectionService());
|
||||
private AzureBlobConnectionSetting settings;
|
||||
|
||||
private TestAzureBlobConnectionService()
|
||||
{
|
||||
LoadInstanceSettings();
|
||||
}
|
||||
|
||||
public static TestAzureBlobConnectionService Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return instance.Value;
|
||||
}
|
||||
}
|
||||
|
||||
public AzureBlobConnectionSetting Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
|
||||
internal void LoadInstanceSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.settings = TestAzureBlobConnectionService.InitAzureBlobConnectionSetting();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Fail to load the SQL connection instances.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
internal static AzureBlobConnectionSetting InitAzureBlobConnectionSetting()
|
||||
{
|
||||
try
|
||||
{
|
||||
AzureBlobConnectionSetting settings = new AzureBlobConnectionSetting();
|
||||
settings.AccountKey = Environment.GetEnvironmentVariable(Constants.AzureStorageAccountKey);
|
||||
settings.AccountName = Environment.GetEnvironmentVariable(Constants.AzureStorageAccountName);
|
||||
settings.BlobContainerUri = Environment.GetEnvironmentVariable(Constants.AzureBlobContainerUri);
|
||||
Console.WriteLine("Azure Blob Connection Settings loaded successfully");
|
||||
return settings;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Failed to load the azure blob connection settings.", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user