diff --git a/build.json b/build.json
index a3273984..8081227a 100644
--- a/build.json
+++ b/build.json
@@ -18,6 +18,7 @@
"MainProjects": [
"Microsoft.SqlTools.ServiceLayer",
"Microsoft.SqlTools.Credentials",
- "Microsoft.Sqltools.Serialization"
+ "Microsoft.SqlTools.Serialization",
+ "Microsoft.SqlTools.ResourceProvider"
]
}
diff --git a/src/Microsoft.SqlTools.Credentials/Microsoft.SqlTools.Credentials.csproj b/src/Microsoft.SqlTools.Credentials/Microsoft.SqlTools.Credentials.csproj
index 961fecaa..5075a8a8 100644
--- a/src/Microsoft.SqlTools.Credentials/Microsoft.SqlTools.Credentials.csproj
+++ b/src/Microsoft.SqlTools.Credentials/Microsoft.SqlTools.Credentials.csproj
@@ -35,7 +35,4 @@
-
-
-
diff --git a/src/Microsoft.SqlTools.Hosting/Extensibility/ExtensionServiceProvider.cs b/src/Microsoft.SqlTools.Hosting/Extensibility/ExtensionServiceProvider.cs
index 94f60df7..d39f92cf 100644
--- a/src/Microsoft.SqlTools.Hosting/Extensibility/ExtensionServiceProvider.cs
+++ b/src/Microsoft.SqlTools.Hosting/Extensibility/ExtensionServiceProvider.cs
@@ -38,9 +38,19 @@ namespace Microsoft.SqlTools.Extensibility
"microsoftsqltoolsservicelayer.dll"
};
+ return CreateFromAssembliesInDirectory(inclusionList);
+ }
+
+ ///
+ /// Creates a service provider by loading a set of named assemblies, expected to be in the current working directory
+ ///
+ /// full DLL names, as a string enumerable
+ /// instance
+ public static ExtensionServiceProvider CreateFromAssembliesInDirectory(IEnumerable inclusionList)
+ {
string assemblyPath = typeof(ExtensionStore).GetTypeInfo().Assembly.Location;
string directory = Path.GetDirectoryName(assemblyPath);
-
+
AssemblyLoadContext context = new AssemblyLoader(directory);
var assemblyPaths = Directory.GetFiles(directory, "*.dll", SearchOption.TopDirectoryOnly);
@@ -49,20 +59,20 @@ namespace Microsoft.SqlTools.Extensibility
{
// skip DLL files not in inclusion list
bool isInList = false;
- foreach (var item in inclusionList)
+ foreach (var item in inclusionList)
{
- if (path.EndsWith(item, StringComparison.OrdinalIgnoreCase))
+ if (path.EndsWith(item, StringComparison.OrdinalIgnoreCase))
{
isInList = true;
break;
}
}
- if (!isInList)
+ if (!isInList)
{
continue;
- }
-
+ }
+
try
{
assemblies.Add(
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Utility/GeneralRequestDetails.cs b/src/Microsoft.SqlTools.Hosting/Utility/GeneralRequestDetails.cs
similarity index 69%
rename from src/Microsoft.SqlTools.ServiceLayer/Utility/GeneralRequestDetails.cs
rename to src/Microsoft.SqlTools.Hosting/Utility/GeneralRequestDetails.cs
index 4612976c..a407dc6e 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/Utility/GeneralRequestDetails.cs
+++ b/src/Microsoft.SqlTools.Hosting/Utility/GeneralRequestDetails.cs
@@ -6,9 +6,8 @@
using System;
using System.Collections.Generic;
using System.Globalization;
-using Microsoft.SqlTools.Utility;
-namespace Microsoft.SqlTools.ServiceLayer.Utility
+namespace Microsoft.SqlTools.Utility
{
public class GeneralRequestDetails
{
@@ -17,7 +16,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility
Options = new Dictionary();
}
- internal T GetOptionValue(string name)
+ public T GetOptionValue(string name)
{
T result = default(T);
if (Options != null && Options.ContainsKey(name))
@@ -37,7 +36,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility
return result;
}
- internal static T GetValueAs(object value)
+ public static T GetValueAs(object value)
{
T result = default(T);
@@ -54,7 +53,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility
else if (typeof(T).IsEnum)
{
object enumValue;
- if (Enum.TryParse(typeof(T), value.ToString(), out enumValue))
+ if (TryParseEnum(typeof(T), value.ToString(), out enumValue))
{
value = (T)enumValue;
}
@@ -63,7 +62,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility
else if (value != null && (typeof(T).IsEnum))
{
object enumValue;
- if (Enum.TryParse(typeof(T), value.ToString(), out enumValue))
+ if (TryParseEnum(typeof(T), value.ToString(), out enumValue))
{
value = enumValue;
}
@@ -73,6 +72,26 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility
return result;
}
+ ///
+ /// This method exists because in NetStandard the Enum.TryParse methods that accept in a type
+ /// are not present, and the generic TryParse method requires the type T to be non-nullable which
+ /// is hard to check. This is different to the NetCore definition for some reason.
+ /// It seems easier to implement our own than work around this.
+ ///
+ private static bool TryParseEnum(Type t, string value, out object enumValue)
+ {
+ try
+ {
+ enumValue = Enum.Parse(t, value);
+ return true;
+ }
+ catch(Exception)
+ {
+ enumValue = default(T);
+ return false;
+ }
+ }
+
protected void SetOptionValue(string name, T value)
{
Options = Options ?? new Dictionary();
diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/AccountOptionsHelper.cs b/src/Microsoft.SqlTools.ResourceProvider.Core/AccountOptionsHelper.cs
new file mode 100644
index 00000000..d355840e
--- /dev/null
+++ b/src/Microsoft.SqlTools.ResourceProvider.Core/AccountOptionsHelper.cs
@@ -0,0 +1,20 @@
+//
+// 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.ResourceProvider.Core
+{
+ internal class AccountOptionsHelper
+ {
+ ///
+ /// The name of the IsMsAccount option
+ ///
+ internal const string IsMsAccount = "IsMsAccount";
+ ///
+ /// The name of the Tenants option
+ ///
+ internal const string Tenants = "Tentants";
+ }
+}
diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/Authentication/AccountTokenWrapper.cs b/src/Microsoft.SqlTools.ResourceProvider.Core/Authentication/AccountTokenWrapper.cs
new file mode 100644
index 00000000..08f65a52
--- /dev/null
+++ b/src/Microsoft.SqlTools.ResourceProvider.Core/Authentication/AccountTokenWrapper.cs
@@ -0,0 +1,31 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+
+using System.Collections.Generic;
+using Microsoft.SqlTools.ResourceProvider.Core.Contracts;
+
+namespace Microsoft.SqlTools.ResourceProvider.Core.Authentication
+{
+ ///
+ /// Contains an account and related token information usable for login purposes
+ ///
+ public class AccountTokenWrapper
+ {
+ public AccountTokenWrapper(Account account, Dictionary securityTokenMappings)
+ {
+ Account = account;
+ SecurityTokenMappings = securityTokenMappings;
+ }
+ ///
+ /// Account defining a connected service login
+ ///
+ public Account Account { get; private set; }
+ ///
+ /// Token mappings from tentant ID to their access token
+ ///
+ public Dictionary SecurityTokenMappings { get; private set; }
+ }
+}
diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/Authentication/IAzureTenant.cs b/src/Microsoft.SqlTools.ResourceProvider.Core/Authentication/IAzureTenant.cs
new file mode 100644
index 00000000..917edcc7
--- /dev/null
+++ b/src/Microsoft.SqlTools.ResourceProvider.Core/Authentication/IAzureTenant.cs
@@ -0,0 +1,29 @@
+//
+// 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.ResourceProvider.Core.Authentication
+{
+ ///
+ /// User account authentication information to be used by
+ ///
+ public interface IAzureTenant
+ {
+ ///
+ /// The unique Id for the tenant
+ ///
+ string TenantId
+ {
+ get;
+ }
+
+ ///
+ /// Display ID
+ ///
+ string AccountDisplayableId
+ {
+ get;
+ }
+
+ }
+}
diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/Authentication/IAzureUserAccount.cs b/src/Microsoft.SqlTools.ResourceProvider.Core/Authentication/IAzureUserAccount.cs
index c02e049d..e82befa0 100644
--- a/src/Microsoft.SqlTools.ResourceProvider.Core/Authentication/IAzureUserAccount.cs
+++ b/src/Microsoft.SqlTools.ResourceProvider.Core/Authentication/IAzureUserAccount.cs
@@ -3,13 +3,14 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
+using System.Collections.Generic;
namespace Microsoft.SqlTools.ResourceProvider.Core.Authentication
{
///
/// Contains information about an Azure user account
///
- public interface IAzureUserAccount : IEquatable, IUserAccount
+ public interface IAzureUserAccount : IEquatable, IUserAccount
{
///
/// User Account Display Info
@@ -20,11 +21,19 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Authentication
}
///
- /// Tenant Id
+ /// Primary Tenant Id
///
string TenantId
{
get;
- }
+ }
+
+ ///
+ /// All tenant IDs
+ ///
+ IList AllTenants
+ {
+ get;
+ }
}
}
diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/AuthenticationService.cs b/src/Microsoft.SqlTools.ResourceProvider.Core/AuthenticationService.cs
new file mode 100644
index 00000000..9ed88d42
--- /dev/null
+++ b/src/Microsoft.SqlTools.ResourceProvider.Core/AuthenticationService.cs
@@ -0,0 +1,47 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Composition;
+using System.Threading.Tasks;
+using Microsoft.SqlTools.Extensibility;
+using Microsoft.SqlTools.Hosting;
+using Microsoft.SqlTools.Hosting.Protocol;
+using Microsoft.SqlTools.ResourceProvider.Core;
+using Microsoft.SqlTools.ResourceProvider.Core.Authentication;
+using Microsoft.SqlTools.ResourceProvider.Core.Contracts;
+using Microsoft.SqlTools.ResourceProvider.Core.Extensibility;
+using Microsoft.SqlTools.ResourceProvider.Core.Firewall;
+using Microsoft.SqlTools.Utility;
+
+namespace Microsoft.SqlTools.ResourceProvider.Core
+{
+
+ [Export(typeof(IHostedService))]
+ public class AuthenticationService : HostedService, IComposableService
+ {
+ ///
+ /// The default constructor is required for MEF-based composable services
+ ///
+ public AuthenticationService()
+ {
+ }
+
+ public override void InitializeService(IProtocolEndpoint serviceHost)
+ {
+ Logger.Write(LogLevel.Verbose, "AuthenticationService initialized");
+ }
+
+ public async Task SetCurrentAccountAsync(Account account, Dictionary securityTokenMappings)
+ {
+ var authManager = ServiceProvider.GetService();
+ // Ideally in the future, would have a factory to create the user account and tenant info without knowing
+ // which implementation is which. For expediency, will directly define these in this instance.
+ return await authManager.SetCurrentAccountAsync(new AccountTokenWrapper(account, securityTokenMappings));
+ }
+ }
+
+}
diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/Contracts/Account.cs b/src/Microsoft.SqlTools.ResourceProvider.Core/Contracts/Account.cs
new file mode 100644
index 00000000..6f85964d
--- /dev/null
+++ b/src/Microsoft.SqlTools.ResourceProvider.Core/Contracts/Account.cs
@@ -0,0 +1,119 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System.Collections.Generic;
+
+namespace Microsoft.SqlTools.ResourceProvider.Core.Contracts
+{
+ ///
+ /// An object, usable in s and other messages
+ ///
+ public class Account
+ {
+ ///
+ /// The key that identifies the account
+ ///
+ public AccountKey Key { get; set; }
+
+ ///
+ /// Display information for the account
+ ///
+ public AccountDisplayInfo DisplayInfo { get; set; }
+
+ ///
+ /// Customizable properties, which will include the access token or similar authentication support
+ ///
+ public AccountProperties Properties { get; set; }
+
+ ///
+ /// Indicates if the account needs refreshing
+ ///
+ public bool IsStale { get; set; }
+
+ }
+
+ ///
+ /// Azure-specific properties. Note that ideally with would reuse GeneralRequestDetails but
+ /// this isn't feasible right now as that is specific to having an Options property to hang it off
+ ///
+ public class AccountProperties
+ {
+
+ ///
+ /// Is this a Microsoft account, such as live.com, or not?
+ ///
+ internal bool IsMsAccount
+ {
+ get;
+ set;
+ }
+
+ ///
+ /// Tenants for each object
+ ///
+ public IEnumerable Tenants
+ {
+ get;
+ set;
+ }
+
+ }
+
+ ///
+ /// Represents a key that identifies an account.
+ ///
+ public class AccountKey
+ {
+ ///
+ /// Identifier of the provider
+ ///
+ public string ProviderId { get; set; }
+
+ // Note: ignoring ProviderArgs as it's not relevant
+
+ ///
+ /// Identifier for the account, unique to the provider
+ ///
+ public string AccountId { get; set; }
+ }
+
+ ///
+ /// Represents display information for an account.
+ ///
+ public class AccountDisplayInfo
+ {
+ ///
+ /// A display name that offers context for the account, such as "Contoso".
+ ///
+
+ public string ContextualDisplayName { get; set; }
+
+ // Note: ignoring ContextualLogo as it's not needed
+
+ ///
+ /// A display name that identifies the account, such as "user@contoso.com".
+ ///
+ /// Represents a tenant (an Azure Active Directory instance) to which a user has access
+ ///
+ public class Tenant
+ {
+ ///
+ /// Globally unique identifier of the tenant
+ ///
+ public string Id { get; set; }
+ ///
+ /// Display name of the tenant
+ ///
+ public string DisplayName { get; set; }
+ ///
+ /// Identifier of the user in the tenant
+ ///
+ public string UserId { get; set; }
+ }
+}
diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/Contracts/AccountSecurityToken.cs b/src/Microsoft.SqlTools.ResourceProvider.Core/Contracts/AccountSecurityToken.cs
new file mode 100644
index 00000000..25bfbd96
--- /dev/null
+++ b/src/Microsoft.SqlTools.ResourceProvider.Core/Contracts/AccountSecurityToken.cs
@@ -0,0 +1,35 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System.Collections.Generic;
+
+namespace Microsoft.SqlTools.ResourceProvider.Core.Contracts
+{
+ ///
+ /// Contains key information about a Token used to log in to a resource provider
+ ///
+ public class AccountSecurityToken
+ {
+ ///
+ /// Expiration time for the token
+ ///
+ public string ExpiresOn { get; set; }
+
+ ///
+ /// URI defining the root for resource lookup
+ ///
+ public string Resource { get; set; }
+
+ ///
+ /// The actual token
+ ///
+ public string Token { get; set; }
+
+ ///
+ /// The type of token being sent - for example "Bearer" for most resource queries
+ ///
+ public string TokenType { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/Contracts/FirewallRule.cs b/src/Microsoft.SqlTools.ResourceProvider.Core/Contracts/FirewallRule.cs
new file mode 100644
index 00000000..28de4b42
--- /dev/null
+++ b/src/Microsoft.SqlTools.ResourceProvider.Core/Contracts/FirewallRule.cs
@@ -0,0 +1,102 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System.Collections.Generic;
+using Microsoft.SqlTools.Hosting.Protocol.Contracts;
+
+namespace Microsoft.SqlTools.ResourceProvider.Core.Contracts
+{
+ ///
+ /// A request to open up a firewall rule
+ ///
+ public class CreateFirewallRuleRequest
+ {
+ public static readonly
+ RequestType Type =
+ RequestType.Create("resource/createFirewallRule");
+ }
+
+ ///
+ /// A FirewallRule object, usable in s and other messages
+ ///
+ public class CreateFirewallRuleParams
+ {
+ ///
+ /// Account information to use in connecting to Azure
+ ///
+ public Account Account { get; set; }
+ ///
+ /// Per-tenant token mappings. Ideally would be set independently of this call, but for
+ /// now this allows us to get the tokens necessary to find a server and open a firewall rule
+ ///
+ public Dictionary SecurityTokenMappings { get; set; }
+
+ ///
+ /// Fully qualified name of the server to create a new firewall rule on
+ ///
+ public string ServerName { get; set; }
+
+ ///
+ /// Start of the IP address range
+ ///
+ public string StartIpAddress { get; set; }
+
+ ///
+ /// End of the IP address range
+ ///
+ public string EndIpAddress { get; set; }
+
+ }
+
+ public class CreateFirewallRuleResponse
+ {
+ public bool Result { get; set; }
+ public string ErrorMessage { get; set; }
+ }
+
+ public class CanHandleFirewallRuleRequest
+ {
+ public static readonly
+ RequestType Type =
+ RequestType.Create("resource/handleFirewallRule");
+ }
+
+ public class HandleFirewallRuleParams
+ {
+ ///
+ /// The error code used to defined the error type
+ ///
+ public int ErrorCode { get; set; }
+ ///
+ /// The error message from which to parse the IP address
+ ///
+ public string ErrorMessage { get; set; }
+ ///
+ /// The connection type, for example MSSQL
+ ///
+ public string ConnectionTypeId { get; set; }
+ }
+ ///
+ /// Response to the check for Firewall rule support given an error message
+ ///
+ public class HandleFirewallRuleResponse
+ {
+ ///
+ /// Can this be handled?
+ ///
+ public bool Result { get; set; }
+ ///
+ /// If not, why?
+ ///
+ public string ErrorMessage { get; set; }
+ ///
+ /// If it can be handled, is there a default IP address to send back so users
+ /// can tell what their blocked IP is?
+ ///
+ public string IpAddress { get; set; }
+ }
+
+
+}
diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/Discovery/IAzureResourceManager.cs b/src/Microsoft.SqlTools.ResourceProvider.Core/Discovery/IAzureResourceManager.cs
index 507825fb..3940392e 100644
--- a/src/Microsoft.SqlTools.ResourceProvider.Core/Discovery/IAzureResourceManager.cs
+++ b/src/Microsoft.SqlTools.ResourceProvider.Core/Discovery/IAzureResourceManager.cs
@@ -5,7 +5,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.SqlTools.ResourceProvider.Core.Authentication;
-using Microsoft.SqlTools.ResourceProvider.Core.FirewallRule;
+using Microsoft.SqlTools.ResourceProvider.Core.Firewall;
using Microsoft.SqlTools.ResourceProvider.Core.Extensibility;
namespace Microsoft.SqlTools.ResourceProvider.Core
@@ -49,5 +49,13 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
);
Task CreateSessionAsync(IAzureUserAccountSubscriptionContext subscriptionContext);
+
+
+ ///
+ /// Gets all subscription contexts under a specific user account. Queries all tenants for the account and uses these to log in
+ /// and retrieve subscription information as needed
+ /// Account whose subscriptions should be queried
+ ///
+ Task> GetSubscriptionContextsAsync(IAzureUserAccount userAccount);
}
}
diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/FirewallRule/FirewallErrorParser.cs b/src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallErrorParser.cs
similarity index 98%
rename from src/Microsoft.SqlTools.ResourceProvider.Core/FirewallRule/FirewallErrorParser.cs
rename to src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallErrorParser.cs
index 44af4eae..cd2dfda1 100644
--- a/src/Microsoft.SqlTools.ResourceProvider.Core/FirewallRule/FirewallErrorParser.cs
+++ b/src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallErrorParser.cs
@@ -7,7 +7,7 @@ using System.Data.SqlClient;
using System.Net;
using System.Text.RegularExpressions;
-namespace Microsoft.SqlTools.ResourceProvider.Core.FirewallRule
+namespace Microsoft.SqlTools.ResourceProvider.Core.Firewall
{
internal interface IFirewallErrorParser
{
diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/FirewallRule/FirewallParserResponse.cs b/src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallParserResponse.cs
similarity index 94%
rename from src/Microsoft.SqlTools.ResourceProvider.Core/FirewallRule/FirewallParserResponse.cs
rename to src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallParserResponse.cs
index 724f7f39..de422ebe 100644
--- a/src/Microsoft.SqlTools.ResourceProvider.Core/FirewallRule/FirewallParserResponse.cs
+++ b/src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallParserResponse.cs
@@ -4,7 +4,7 @@
using System.Net;
-namespace Microsoft.SqlTools.ResourceProvider.Core.FirewallRule
+namespace Microsoft.SqlTools.ResourceProvider.Core.Firewall
{
///
/// The response that's created by firewall rule parser
diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/FirewallRule/FirewallRuleException.cs b/src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallRuleException.cs
similarity index 98%
rename from src/Microsoft.SqlTools.ResourceProvider.Core/FirewallRule/FirewallRuleException.cs
rename to src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallRuleException.cs
index 772854b5..420600b3 100644
--- a/src/Microsoft.SqlTools.ResourceProvider.Core/FirewallRule/FirewallRuleException.cs
+++ b/src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallRuleException.cs
@@ -6,7 +6,7 @@ using System;
using System.Net;
using System.Runtime.Serialization;
-namespace Microsoft.SqlTools.ResourceProvider.Core.FirewallRule
+namespace Microsoft.SqlTools.ResourceProvider.Core.Firewall
{
///
/// Exception used by firewall service to indicate when firewall rule operation fails
diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/FirewallRule/FirewallRuleRequest.cs b/src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallRuleRequest.cs
similarity index 94%
rename from src/Microsoft.SqlTools.ResourceProvider.Core/FirewallRule/FirewallRuleRequest.cs
rename to src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallRuleRequest.cs
index f0a46325..ee87e991 100644
--- a/src/Microsoft.SqlTools.ResourceProvider.Core/FirewallRule/FirewallRuleRequest.cs
+++ b/src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallRuleRequest.cs
@@ -6,7 +6,7 @@ using System;
using System.Globalization;
using System.Net;
-namespace Microsoft.SqlTools.ResourceProvider.Core.FirewallRule
+namespace Microsoft.SqlTools.ResourceProvider.Core.Firewall
{
///
/// Includes all the information needed to create a firewall rule
diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/FirewallRule/FirewallRuleResource.cs b/src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallRuleResource.cs
similarity index 93%
rename from src/Microsoft.SqlTools.ResourceProvider.Core/FirewallRule/FirewallRuleResource.cs
rename to src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallRuleResource.cs
index 6681385e..97daa029 100644
--- a/src/Microsoft.SqlTools.ResourceProvider.Core/FirewallRule/FirewallRuleResource.cs
+++ b/src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallRuleResource.cs
@@ -4,7 +4,7 @@
using Microsoft.SqlTools.ResourceProvider.Core.Authentication;
-namespace Microsoft.SqlTools.ResourceProvider.Core.FirewallRule
+namespace Microsoft.SqlTools.ResourceProvider.Core.Firewall
{
///
/// Includes azure resource and subscription needed to create firewall rule
diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/FirewallRule/FirewallRuleResponse.cs b/src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallRuleResponse.cs
similarity index 92%
rename from src/Microsoft.SqlTools.ResourceProvider.Core/FirewallRule/FirewallRuleResponse.cs
rename to src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallRuleResponse.cs
index c90a2461..f5922899 100644
--- a/src/Microsoft.SqlTools.ResourceProvider.Core/FirewallRule/FirewallRuleResponse.cs
+++ b/src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallRuleResponse.cs
@@ -2,7 +2,7 @@
// 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.ResourceProvider.Core.FirewallRule
+namespace Microsoft.SqlTools.ResourceProvider.Core.Firewall
{
///
/// The response that's created when the firewall rule creation request is complete
diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/FirewallRule/FirewallRuleService.cs b/src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallRuleService.cs
similarity index 96%
rename from src/Microsoft.SqlTools.ResourceProvider.Core/FirewallRule/FirewallRuleService.cs
rename to src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallRuleService.cs
index 9acf18a6..6d92cc75 100644
--- a/src/Microsoft.SqlTools.ResourceProvider.Core/FirewallRule/FirewallRuleService.cs
+++ b/src/Microsoft.SqlTools.ResourceProvider.Core/Firewall/FirewallRuleService.cs
@@ -9,7 +9,7 @@ using System.Net;
using System.Threading.Tasks;
using Microsoft.SqlTools.ResourceProvider.Core.Authentication;
-namespace Microsoft.SqlTools.ResourceProvider.Core.FirewallRule
+namespace Microsoft.SqlTools.ResourceProvider.Core.Firewall
{
public interface IFirewallRuleService
@@ -89,7 +89,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.FirewallRule
}
catch (Exception ex)
{
- throw new FirewallRuleException(SR.FirewallRuleCreationFailed, ex);
+ throw new FirewallRuleException(string.Format(CultureInfo.CurrentCulture, SR.FirewallRuleCreationFailedWithError, ex.Message), ex);
}
}
@@ -135,7 +135,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.FirewallRule
}
catch (Exception ex)
{
- throw new FirewallRuleException(SR.FirewallRuleCreationFailed, ex);
+ throw new FirewallRuleException(string.Format(CultureInfo.CurrentCulture, SR.FirewallRuleCreationFailedWithError, ex.Message), ex);
}
return new FirewallRuleResponse()
diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/Localization/sr.cs b/src/Microsoft.SqlTools.ResourceProvider.Core/Localization/sr.cs
old mode 100644
new mode 100755
index 1533eed7..0064be60
--- a/src/Microsoft.SqlTools.ResourceProvider.Core/Localization/sr.cs
+++ b/src/Microsoft.SqlTools.ResourceProvider.Core/Localization/sr.cs
@@ -1,104 +1,120 @@
-// WARNING:
-// This file was generated by the Microsoft DataWarehouse String Resource Tool 1.37.0.0
-// from information in sr.strings
-// DO NOT MODIFY THIS FILE'S CONTENTS, THEY WILL BE OVERWRITTEN
-//
-namespace Microsoft.SqlTools.ResourceProvider.Core
-{
- using System;
- using System.Reflection;
- using System.Resources;
- using System.Globalization;
+// WARNING:
+// This file was generated by the Microsoft DataWarehouse String Resource Tool 1.37.0.0
+// from information in sr.strings
+// DO NOT MODIFY THIS FILE'S CONTENTS, THEY WILL BE OVERWRITTEN
+//
+namespace Microsoft.SqlTools.ResourceProvider.Core
+{
+ using System;
+ using System.Reflection;
+ using System.Resources;
+ using System.Globalization;
+
+ [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class SR
+ {
+ protected SR()
+ { }
+
+ public static CultureInfo Culture
+ {
+ get
+ {
+ return Keys.Culture;
+ }
+ set
+ {
+ Keys.Culture = value;
+ }
+ }
- [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class SR
- {
- protected SR()
- { }
-
- public static CultureInfo Culture
- {
- get
- {
- return Keys.Culture;
- }
- set
- {
- Keys.Culture = value;
- }
+
+ public static string AzureServerNotFound
+ {
+ get
+ {
+ return Keys.GetString(Keys.AzureServerNotFound);
+ }
}
-
-
- public static string AzureServerNotFound
- {
- get
- {
- return Keys.GetString(Keys.AzureServerNotFound);
- }
+
+ public static string AzureSubscriptionFailedErrorMessage
+ {
+ get
+ {
+ return Keys.GetString(Keys.AzureSubscriptionFailedErrorMessage);
+ }
}
-
- public static string AzureSubscriptionFailedErrorMessage
- {
- get
- {
- return Keys.GetString(Keys.AzureSubscriptionFailedErrorMessage);
- }
+
+ public static string DatabaseDiscoveryFailedErrorMessage
+ {
+ get
+ {
+ return Keys.GetString(Keys.DatabaseDiscoveryFailedErrorMessage);
+ }
}
-
- public static string DatabaseDiscoveryFailedErrorMessage
- {
- get
- {
- return Keys.GetString(Keys.DatabaseDiscoveryFailedErrorMessage);
- }
+
+ public static string FirewallRuleAccessForbidden
+ {
+ get
+ {
+ return Keys.GetString(Keys.FirewallRuleAccessForbidden);
+ }
}
-
- public static string FirewallRuleAccessForbidden
- {
- get
- {
- return Keys.GetString(Keys.FirewallRuleAccessForbidden);
- }
+
+ public static string FirewallRuleCreationFailed
+ {
+ get
+ {
+ return Keys.GetString(Keys.FirewallRuleCreationFailed);
+ }
}
-
- public static string FirewallRuleCreationFailed
- {
- get
- {
- return Keys.GetString(Keys.FirewallRuleCreationFailed);
- }
+
+ public static string FirewallRuleCreationFailedWithError
+ {
+ get
+ {
+ return Keys.GetString(Keys.FirewallRuleCreationFailedWithError);
+ }
}
-
- public static string InvalidIpAddress
- {
- get
- {
- return Keys.GetString(Keys.InvalidIpAddress);
- }
+
+ public static string InvalidIpAddress
+ {
+ get
+ {
+ return Keys.GetString(Keys.InvalidIpAddress);
+ }
}
-
- public static string InvalidServerTypeErrorMessage
- {
- get
- {
- return Keys.GetString(Keys.InvalidServerTypeErrorMessage);
- }
+
+ public static string InvalidServerTypeErrorMessage
+ {
+ get
+ {
+ return Keys.GetString(Keys.InvalidServerTypeErrorMessage);
+ }
}
-
- public static string LoadingExportableFailedGeneralErrorMessage
- {
- get
- {
- return Keys.GetString(Keys.LoadingExportableFailedGeneralErrorMessage);
- }
+
+ public static string LoadingExportableFailedGeneralErrorMessage
+ {
+ get
+ {
+ return Keys.GetString(Keys.LoadingExportableFailedGeneralErrorMessage);
+ }
}
-
- [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- public class Keys
- {
- static ResourceManager resourceManager = new ResourceManager("Microsoft.SqlTools.ResourceProvider.Core.Localization.SR", typeof(SR).GetTypeInfo().Assembly);
-
- static CultureInfo _culture = null;
+
+ public static string FirewallRuleUnsupportedConnectionType
+ {
+ get
+ {
+ return Keys.GetString(Keys.FirewallRuleUnsupportedConnectionType);
+ }
+ }
+
+ [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ public class Keys
+ {
+ static ResourceManager resourceManager = new ResourceManager("Microsoft.SqlTools.ResourceProvider.Core.Localization.SR", typeof(SR).GetTypeInfo().Assembly);
+
+ static CultureInfo _culture = null;
public const string AzureServerNotFound = "AzureServerNotFound";
@@ -116,6 +132,9 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
public const string FirewallRuleCreationFailed = "FirewallRuleCreationFailed";
+ public const string FirewallRuleCreationFailedWithError = "FirewallRuleCreationFailedWithError";
+
+
public const string InvalidIpAddress = "InvalidIpAddress";
@@ -125,25 +144,28 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
public const string LoadingExportableFailedGeneralErrorMessage = "LoadingExportableFailedGeneralErrorMessage";
- private Keys()
- { }
+ public const string FirewallRuleUnsupportedConnectionType = "FirewallRuleUnsupportedConnectionType";
- public static CultureInfo Culture
- {
- get
- {
- return _culture;
- }
- set
- {
- _culture = value;
- }
- }
-
- public static string GetString(string key)
- {
- return resourceManager.GetString(key, _culture);
- }
+
+ private Keys()
+ { }
+
+ public static CultureInfo Culture
+ {
+ get
+ {
+ return _culture;
+ }
+ set
+ {
+ _culture = value;
+ }
+ }
+
+ public static string GetString(string key)
+ {
+ return resourceManager.GetString(key, _culture);
+ }
}
}
diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/Localization/sr.resx b/src/Microsoft.SqlTools.ResourceProvider.Core/Localization/sr.resx
old mode 100644
new mode 100755
index 865b7923..1f16faa4
--- a/src/Microsoft.SqlTools.ResourceProvider.Core/Localization/sr.resx
+++ b/src/Microsoft.SqlTools.ResourceProvider.Core/Localization/sr.resx
@@ -1,152 +1,160 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- The server you specified {0} does not exist in any subscription in {1}. Either you have signed in with an incorrect account or your server was removed from subscription(s) in this account. Please check your account and try again.
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ The server you specified {0} does not exist in any subscription in {1}. Either you have signed in with an incorrect account or your server was removed from subscription(s) in this account. Please check your account and try again.
+
-
- An error occurred while getting Azure subscriptions
-
+
+ An error occurred while getting Azure subscriptions
+
-
- An error occurred while getting databases from servers of type {0} from {1}
-
+
+ An error occurred while getting databases from servers of type {0} from {1}
+
-
- {0} does not have permission to change the server firewall rule. Try again with a different account that is an Owner or Contributor of the Azure subscription or the server.
-
+
+ {0} does not have permission to change the server firewall rule. Try again with a different account that is an Owner or Contributor of the Azure subscription or the server.
+
-
- An error occurred while creating a new firewall rule.
-
+
+ An error occurred while creating a new firewall rule.
+
-
- Invalid IP address
-
+
+ An error occurred while creating a new firewall rule: '{0}'
+
-
- Server Type is invalid.
-
+
+ Invalid IP address
+
-
- A required dll cannot be loaded. Please repair your application.
-
+
+ Server Type is invalid.
+
+
+
+ A required dll cannot be loaded. Please repair your application.
+
+
+
+ Cannot open a firewall rule for the specified connection type
+
diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/Localization/sr.strings b/src/Microsoft.SqlTools.ResourceProvider.Core/Localization/sr.strings
index ba1bed62..d0b41403 100644
--- a/src/Microsoft.SqlTools.ResourceProvider.Core/Localization/sr.strings
+++ b/src/Microsoft.SqlTools.ResourceProvider.Core/Localization/sr.strings
@@ -27,6 +27,8 @@ AzureSubscriptionFailedErrorMessage = An error occurred while getting Azure subs
DatabaseDiscoveryFailedErrorMessage = An error occurred while getting databases from servers of type {0} from {1}
FirewallRuleAccessForbidden = {0} does not have permission to change the server firewall rule. Try again with a different account that is an Owner or Contributor of the Azure subscription or the server.
FirewallRuleCreationFailed = An error occurred while creating a new firewall rule.
+FirewallRuleCreationFailedWithError = An error occurred while creating a new firewall rule: '{0}'
InvalidIpAddress = Invalid IP address
InvalidServerTypeErrorMessage = Server Type is invalid.
LoadingExportableFailedGeneralErrorMessage = A required dll cannot be loaded. Please repair your application.
+FirewallRuleUnsupportedConnectionType = Cannot open a firewall rule for the specified connection type
\ No newline at end of file
diff --git a/src/Microsoft.SqlTools.ResourceProvider.Core/Localization/sr.xlf b/src/Microsoft.SqlTools.ResourceProvider.Core/Localization/sr.xlf
index 3ab7cbb5..3e061f47 100644
--- a/src/Microsoft.SqlTools.ResourceProvider.Core/Localization/sr.xlf
+++ b/src/Microsoft.SqlTools.ResourceProvider.Core/Localization/sr.xlf
@@ -42,6 +42,16 @@
An error occurred while creating a new firewall rule.
+
+ Cannot open a firewall rule for the specified connection type
+ Cannot open a firewall rule for the specified connection type
+
+
+
+ An error occurred while creating a new firewall rule: '{0}'
+ An error occurred while creating a new firewall rule: '{0}'
+
+