mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-15 17:23:32 -05:00
Create Firewall Rule support with a simple Resource Provider implementation
Implementation of the resource provider APIs in order to support Create Firewall Rule. Provides definition for a ResourceProvider and Authentication service. The ResourceProvider supports firewall rules for now, and since authentication is routed through that method it will call into the auth service to set up the current account to be used. Additional notes: - Fixed deserialization by adding an Accept header. This shouldn't be necessary, but for some reason the firewall rule defaults to XML without this - Use generic server list and parse the ID to get the resource group, avoiding a large number of extra calls for each RG - Errors now include error message from the API
This commit is contained in:
@@ -0,0 +1,316 @@
|
||||
//
|
||||
// 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.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
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.Utility;
|
||||
|
||||
namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Implementation for <see cref="IAzureAuthenticationManager" />.
|
||||
/// Provides functionality to authenticate to Azure and discover associated accounts and subscriptions
|
||||
/// </summary>
|
||||
[Exportable(
|
||||
ServerTypes.SqlServer,
|
||||
Categories.Azure,
|
||||
typeof(IAzureAuthenticationManager),
|
||||
"Microsoft.SqlTools.ResourceProvider.DefaultImpl.AzureAuthenticationManager",
|
||||
1)
|
||||
]
|
||||
class AzureAuthenticationManager : ExportableBase, IAzureAuthenticationManager
|
||||
{
|
||||
private Dictionary<string, AzureUserAccount> accountsMap;
|
||||
private string currentAccountId = null;
|
||||
private IEnumerable<IAzureUserAccountSubscriptionContext> _selectedSubscriptions = null;
|
||||
private readonly object _selectedSubscriptionsLockObject = new object();
|
||||
private readonly ConcurrentCache<IEnumerable<IAzureUserAccountSubscriptionContext>> _subscriptionCache =
|
||||
new ConcurrentCache<IEnumerable<IAzureUserAccountSubscriptionContext>>();
|
||||
|
||||
|
||||
public AzureAuthenticationManager()
|
||||
{
|
||||
Metadata = new ExportableMetadata(
|
||||
ServerTypes.SqlServer,
|
||||
Categories.Azure,
|
||||
"Microsoft.SqlTools.ResourceProvider.DefaultImpl.AzureAuthenticationManager",
|
||||
1);
|
||||
accountsMap = new Dictionary<string, AzureUserAccount>();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<IAzureUserAccount> UserAccounts
|
||||
{
|
||||
get { return accountsMap.Values; }
|
||||
}
|
||||
|
||||
public bool HasLoginDialog
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set current logged in user
|
||||
/// </summary>
|
||||
public async Task<IUserAccount> SetCurrentAccountAsync(object account)
|
||||
{
|
||||
CommonUtil.CheckForNull(account, nameof(account));
|
||||
AccountTokenWrapper accountTokenWrapper = account as AccountTokenWrapper;
|
||||
if (accountTokenWrapper != null)
|
||||
{
|
||||
AzureUserAccount userAccount = CreateUserAccount(accountTokenWrapper);
|
||||
accountsMap[userAccount.UniqueId] = userAccount;
|
||||
currentAccountId = userAccount.UniqueId;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ServiceFailedException(string.Format(CultureInfo.CurrentCulture, SR.UnsupportedAuthType, account.GetType().Name));
|
||||
}
|
||||
OnCurrentAccountChanged();
|
||||
return await GetCurrentAccountAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Public for testing purposes. Creates an Azure account with the correct set of mappings for tenants etc.
|
||||
/// </summary>
|
||||
/// <param name="accountTokenWrapper"></param>
|
||||
/// <returns></returns>
|
||||
public AzureUserAccount CreateUserAccount(AccountTokenWrapper accountTokenWrapper)
|
||||
{
|
||||
Account account = accountTokenWrapper.Account;
|
||||
CommonUtil.CheckForNull(accountTokenWrapper.Account, nameof(account));
|
||||
CommonUtil.CheckForNull(accountTokenWrapper.SecurityTokenMappings, nameof(account) + ".SecurityTokenMappings");
|
||||
AzureUserAccount userAccount = new AzureUserAccount();
|
||||
userAccount.UniqueId = account.Key.AccountId;
|
||||
userAccount.DisplayInfo = ToDisplayInfo(account);
|
||||
IList<IAzureTenant> tenants = new List<IAzureTenant>();
|
||||
foreach (Tenant tenant in account.Properties.Tenants)
|
||||
{
|
||||
AccountSecurityToken token;
|
||||
if (accountTokenWrapper.SecurityTokenMappings.TryGetValue(tenant.Id, out token))
|
||||
{
|
||||
AzureTenant azureTenant = new AzureTenant()
|
||||
{
|
||||
TenantId = tenant.Id,
|
||||
AccountDisplayableId = tenant.DisplayName,
|
||||
Resource = token.Resource,
|
||||
AccessToken = token.Token,
|
||||
TokenType = token.TokenType
|
||||
};
|
||||
tenants.Add(azureTenant);
|
||||
}
|
||||
// else ignore for now as we can't handle a request to get a tenant without an access key
|
||||
}
|
||||
userAccount.AllTenants = tenants;
|
||||
return userAccount;
|
||||
}
|
||||
|
||||
private AzureUserAccountDisplayInfo ToDisplayInfo(Account account)
|
||||
{
|
||||
return new AzureUserAccountDisplayInfo()
|
||||
{
|
||||
AccountDisplayName = account.DisplayInfo.DisplayName,
|
||||
ProviderDisplayName = account.Key.ProviderId
|
||||
};
|
||||
}
|
||||
|
||||
private void OnCurrentAccountChanged()
|
||||
{
|
||||
lock (_selectedSubscriptionsLockObject)
|
||||
{
|
||||
_selectedSubscriptions = null;
|
||||
}
|
||||
if (CurrentAccountChanged != null)
|
||||
{
|
||||
CurrentAccountChanged(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The event to be raised when the current account is changed
|
||||
/// </summary>
|
||||
public event EventHandler CurrentAccountChanged;
|
||||
|
||||
public Task<IUserAccount> AddUserAccountAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<IUserAccount> AuthenticateAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<IUserAccount> GetCurrentAccountAsync()
|
||||
{
|
||||
var account = await GetCurrentAccountInternalAsync();
|
||||
return account;
|
||||
}
|
||||
|
||||
private Task<AzureUserAccount> GetCurrentAccountInternalAsync()
|
||||
{
|
||||
|
||||
AzureUserAccount account = null;
|
||||
if (currentAccountId != null
|
||||
&& accountsMap.TryGetValue(currentAccountId, out account))
|
||||
{
|
||||
// TODO is there more needed here?
|
||||
}
|
||||
return Task.FromResult<AzureUserAccount>(account);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<IAzureUserAccountSubscriptionContext>> GetSelectedSubscriptionsAsync()
|
||||
{
|
||||
return _selectedSubscriptions ?? await GetSubscriptionsAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns user's subscriptions
|
||||
/// </summary>
|
||||
public async Task<IEnumerable<IAzureUserAccountSubscriptionContext>> GetSubscriptionsAsync()
|
||||
{
|
||||
var result = Enumerable.Empty<IAzureUserAccountSubscriptionContext>();
|
||||
bool userNeedsAuthentication = await GetUserNeedsReauthenticationAsync();
|
||||
if (!userNeedsAuthentication)
|
||||
{
|
||||
AzureUserAccount currentUser = await GetCurrentAccountInternalAsync();
|
||||
if (currentUser != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
result = await GetSubscriptionsFromCacheAsync(currentUser);
|
||||
}
|
||||
catch (ServiceExceptionBase)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ServiceFailedException(SR.AzureSubscriptionFailedErrorMessage, ex);
|
||||
}
|
||||
}
|
||||
result = result ?? Enumerable.Empty<IAzureUserAccountSubscriptionContext>();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<IAzureUserAccountSubscriptionContext>> GetSubscriptionsFromCacheAsync(AzureUserAccount user)
|
||||
{
|
||||
var result = Enumerable.Empty<IAzureUserAccountSubscriptionContext>();
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
result = _subscriptionCache.Get(user.UniqueId);
|
||||
if (result == null)
|
||||
{
|
||||
result = await GetSubscriptionFromServiceAsync(user);
|
||||
_subscriptionCache.UpdateCache(user.UniqueId, result);
|
||||
}
|
||||
}
|
||||
result = result ?? Enumerable.Empty<IAzureUserAccountSubscriptionContext>();
|
||||
return result;
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<IAzureUserAccountSubscriptionContext>> GetSubscriptionFromServiceAsync(AzureUserAccount userAccount)
|
||||
{
|
||||
List<IAzureUserAccountSubscriptionContext> subscriptionList = new List<IAzureUserAccountSubscriptionContext>();
|
||||
|
||||
try
|
||||
{
|
||||
if (userAccount != null && !userAccount.NeedsReauthentication)
|
||||
{
|
||||
IAzureResourceManager resourceManager = ServiceProvider.GetService<IAzureResourceManager>();
|
||||
IEnumerable<IAzureUserAccountSubscriptionContext> contexts = await resourceManager.GetSubscriptionContextsAsync(userAccount);
|
||||
subscriptionList = contexts.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new UserNeedsAuthenticationException(SR.AzureSubscriptionFailedErrorMessage);
|
||||
}
|
||||
}
|
||||
// TODO handle stale tokens
|
||||
//catch (MissingSecurityTokenException missingSecurityTokenException)
|
||||
//{
|
||||
// //User needs to reauthenticate
|
||||
// if (userAccount != null)
|
||||
// {
|
||||
// userAccount.NeedsReauthentication = true;
|
||||
// }
|
||||
// throw new UserNeedsAuthenticationException(SR.AzureSubscriptionFailedErrorMessage, missingSecurityTokenException);
|
||||
//}
|
||||
catch (ServiceExceptionBase)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ServiceFailedException(SR.AzureSubscriptionFailedErrorMessage, ex);
|
||||
}
|
||||
return subscriptionList;
|
||||
}
|
||||
|
||||
|
||||
public Task<bool> GetUserNeedsReauthenticationAsync()
|
||||
{
|
||||
// for now, we don't support handling stale auth objects
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores the selected subscriptions given the ids
|
||||
/// </summary>
|
||||
public async Task<bool> SetSelectedSubscriptionsAsync(IEnumerable<string> subscriptionIds)
|
||||
{
|
||||
IEnumerable<IAzureUserAccountSubscriptionContext> subscriptions = await GetSubscriptionsAsync();
|
||||
List<IAzureUserAccountSubscriptionContext> subscriptionList = subscriptions.ToList();
|
||||
|
||||
List<IAzureUserAccountSubscriptionContext> newSelectedSubscriptions = subscriptionIds == null
|
||||
? subscriptionList
|
||||
: subscriptionList.Where(x => subscriptionIds.Contains(x.Subscription.SubscriptionId)).ToList();
|
||||
|
||||
//If the current account changes during setting selected subscription, none of the ids should be found
|
||||
//so we just reset the selected subscriptions
|
||||
if (subscriptionIds != null && subscriptionIds.Any() && newSelectedSubscriptions.Count == 0)
|
||||
{
|
||||
newSelectedSubscriptions = subscriptionList;
|
||||
}
|
||||
lock (_selectedSubscriptionsLockObject)
|
||||
{
|
||||
if (!SelectedSubscriptionsEquals(newSelectedSubscriptions))
|
||||
{
|
||||
_selectedSubscriptions = newSelectedSubscriptions;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool SelectedSubscriptionsEquals(List<IAzureUserAccountSubscriptionContext> newSelectedSubscriptions)
|
||||
{
|
||||
if (_selectedSubscriptions != null && _selectedSubscriptions.Count() == newSelectedSubscriptions.Count)
|
||||
{
|
||||
return newSelectedSubscriptions.All(subscription => _selectedSubscriptions.Contains(subscription));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to find a subscription given subscription id
|
||||
/// </summary>
|
||||
public bool TryParseSubscriptionIdentifier(string value, out IAzureSubscriptionIdentifier subscription)
|
||||
{
|
||||
// TODO can port this over from the VS implementation if needed, but for now disabling as we don't serialize / deserialize subscriptions
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,13 +13,14 @@ using Microsoft.Azure.Management.Sql;
|
||||
using Microsoft.Azure.Management.Sql.Models;
|
||||
using RestFirewallRule = Microsoft.Azure.Management.Sql.Models.FirewallRule;
|
||||
using Microsoft.SqlTools.ResourceProvider.Core.Authentication;
|
||||
using Microsoft.SqlTools.ResourceProvider.Core.FirewallRule;
|
||||
using Microsoft.SqlTools.ResourceProvider.Core.Firewall;
|
||||
using Microsoft.SqlTools.ResourceProvider.Core.Extensibility;
|
||||
using Microsoft.SqlTools.Utility;
|
||||
using Microsoft.Rest;
|
||||
using System.Globalization;
|
||||
using Microsoft.Rest.Azure;
|
||||
using Microsoft.SqlTools.ResourceProvider.Core;
|
||||
using System.Collections;
|
||||
|
||||
namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
{
|
||||
@@ -31,7 +32,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
ServerTypes.SqlServer,
|
||||
Categories.Azure,
|
||||
typeof(IAzureResourceManager),
|
||||
"Microsoft.SqlServer.ConnectionServices.Azure.Impl.VsAzureResourceManager",
|
||||
"Microsoft.SqlTools.ResourceProvider.DefaultImpl.AzureResourceManager",
|
||||
1)
|
||||
]
|
||||
public class AzureResourceManager : ExportableBase, IAzureResourceManager
|
||||
@@ -45,18 +46,24 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
Metadata = new ExportableMetadata(
|
||||
ServerTypes.SqlServer,
|
||||
Categories.Azure,
|
||||
"Microsoft.SqlServer.ConnectionServices.Azure.Impl.VsAzureResourceManager");
|
||||
"Microsoft.SqlTools.ResourceProvider.DefaultImpl.AzureResourceManager");
|
||||
}
|
||||
|
||||
public async Task<IAzureResourceManagementSession> CreateSessionAsync(IAzureUserAccountSubscriptionContext subscriptionContext)
|
||||
public Task<IAzureResourceManagementSession> CreateSessionAsync(IAzureUserAccountSubscriptionContext subscriptionContext)
|
||||
{
|
||||
CommonUtil.CheckForNull(subscriptionContext, "subscriptionContext");
|
||||
try
|
||||
{
|
||||
ServiceClientCredentials credentials = await CreateCredentialsAsync(subscriptionContext);
|
||||
SqlManagementClient sqlManagementClient = new SqlManagementClient(_resourceManagementUri, credentials);
|
||||
ResourceManagementClient resourceManagementClient = new ResourceManagementClient(_resourceManagementUri, credentials);
|
||||
return new AzureResourceManagementSession(sqlManagementClient, resourceManagementClient, subscriptionContext);
|
||||
ServiceClientCredentials credentials = CreateCredentials(subscriptionContext);
|
||||
SqlManagementClient sqlManagementClient = new SqlManagementClient(credentials)
|
||||
{
|
||||
SubscriptionId = subscriptionContext.Subscription.SubscriptionId
|
||||
};
|
||||
ResourceManagementClient resourceManagementClient = new ResourceManagementClient(credentials)
|
||||
{
|
||||
SubscriptionId = subscriptionContext.Subscription.SubscriptionId
|
||||
};
|
||||
return Task.FromResult<IAzureResourceManagementSession>(new AzureResourceManagementSession(sqlManagementClient, resourceManagementClient, subscriptionContext));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -120,27 +127,29 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
AzureResourceManagementSession vsAzureResourceManagementSession = azureResourceManagementSession as AzureResourceManagementSession;
|
||||
if(vsAzureResourceManagementSession != null)
|
||||
{
|
||||
IEnumerable<ResourceGroup> resourceGroupNames = await GetResourceGroupsAsync(vsAzureResourceManagementSession);
|
||||
if (resourceGroupNames != null)
|
||||
// Note: Ideally wouldn't need to query resource groups, but the current impl requires it
|
||||
// since any update will need the resource group name and it's not returned from the server.
|
||||
// This has a very negative impact on perf, so we should investigate running these queries
|
||||
// in parallel
|
||||
|
||||
try
|
||||
{
|
||||
foreach (ResourceGroup resourceGroupExtended in resourceGroupNames)
|
||||
IServersOperations serverOperations = vsAzureResourceManagementSession.SqlManagementClient.Servers;
|
||||
IPage<Server> servers = await serverOperations.ListAsync();
|
||||
if (servers != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
IServersOperations serverOperations = vsAzureResourceManagementSession.SqlManagementClient.Servers;
|
||||
IPage<Server> servers = await serverOperations.ListByResourceGroupAsync(resourceGroupExtended.Name);
|
||||
if (servers != null)
|
||||
{
|
||||
sqlServers.AddRange(servers.Select(x =>
|
||||
new SqlAzureResource(x) { ResourceGroupName = resourceGroupExtended.Name }));
|
||||
}
|
||||
}
|
||||
catch (HttpOperationException ex)
|
||||
{
|
||||
throw new AzureResourceFailedException(SR.FailedToGetAzureSqlServersErrorMessage, ex.Response.StatusCode);
|
||||
}
|
||||
sqlServers.AddRange(servers.Select(server => {
|
||||
var serverResource = new SqlAzureResource(server);
|
||||
// TODO ResourceGroup name
|
||||
return serverResource;
|
||||
}));
|
||||
}
|
||||
}
|
||||
catch (HttpOperationException ex)
|
||||
{
|
||||
throw new AzureResourceFailedException(
|
||||
string.Format(CultureInfo.CurrentCulture, SR.FailedToGetAzureSqlServersWithError, ex.Message), ex.Response.StatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
@@ -175,21 +184,24 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
StartIpAddress = firewallRuleRequest.StartIpAddress.ToString()
|
||||
};
|
||||
IFirewallRulesOperations firewallRuleOperations = vsAzureResourceManagementSession.SqlManagementClient.FirewallRules;
|
||||
var firewallRuleResponse = await firewallRuleOperations.CreateOrUpdateAsync(
|
||||
azureSqlServer.ResourceGroupName,
|
||||
var firewallRuleResponse = await firewallRuleOperations.CreateOrUpdateWithHttpMessagesAsync(
|
||||
azureSqlServer.ResourceGroupName ?? string.Empty,
|
||||
azureSqlServer.Name,
|
||||
firewallRuleRequest.FirewallRuleName,
|
||||
firewallRule);
|
||||
firewallRule,
|
||||
GetCustomHeaders());
|
||||
var response = firewallRuleResponse.Body;
|
||||
return new FirewallRuleResponse()
|
||||
{
|
||||
StartIpAddress = firewallRuleResponse.StartIpAddress,
|
||||
EndIpAddress = firewallRuleResponse.EndIpAddress,
|
||||
StartIpAddress = response.StartIpAddress,
|
||||
EndIpAddress = response.EndIpAddress,
|
||||
Created = true
|
||||
};
|
||||
}
|
||||
catch (HttpOperationException ex)
|
||||
{
|
||||
throw new AzureResourceFailedException(SR.FirewallRuleCreationFailed, ex.Response.StatusCode);
|
||||
throw new AzureResourceFailedException(
|
||||
string.Format(CultureInfo.CurrentCulture, SR.FirewallRuleCreationFailedWithError, ex.Message), ex.Response.StatusCode);
|
||||
}
|
||||
}
|
||||
// else respond with failure case
|
||||
@@ -200,11 +212,22 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceException(TraceEventType.Error, (int) TraceId.AzureResource, ex, "Failed to get databases");
|
||||
TraceException(TraceEventType.Error, (int) TraceId.AzureResource, ex, "Failed to create firewall rule");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string,List<string>> GetCustomHeaders()
|
||||
{
|
||||
// For some unknown reason the firewall rule method defaults to returning XML. Fixes this by adding an Accept header
|
||||
// ensuring it's always JSON
|
||||
var headers = new Dictionary<string,List<string>>();
|
||||
headers["Accept"] = new List<string>() {
|
||||
"application/json"
|
||||
};
|
||||
return headers;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the azure resource groups for given subscription
|
||||
/// </summary>
|
||||
@@ -226,7 +249,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
}
|
||||
catch (HttpOperationException ex)
|
||||
{
|
||||
throw new AzureResourceFailedException(SR.FailedToGetAzureResourceGroupsErrorMessage, ex.Response.StatusCode);
|
||||
throw new AzureResourceFailedException(string.Format(CultureInfo.CurrentCulture, SR.FailedToGetAzureResourceGroupsErrorMessage, ex.Message), ex.Response.StatusCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,18 +262,104 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
public async Task<IEnumerable<IAzureUserAccountSubscriptionContext>> GetSubscriptionContextsAsync(IAzureUserAccount userAccount)
|
||||
{
|
||||
List<IAzureUserAccountSubscriptionContext> contexts = new List<IAzureUserAccountSubscriptionContext>();
|
||||
foreach (IAzureTenant tenant in userAccount.AllTenants)
|
||||
{
|
||||
AzureTenant azureTenant = tenant as AzureTenant;
|
||||
if (azureTenant != null)
|
||||
{
|
||||
ServiceClientCredentials credentials = CreateCredentials(azureTenant);
|
||||
using (SubscriptionClient client = new SubscriptionClient(_resourceManagementUri, credentials))
|
||||
{
|
||||
IEnumerable<Subscription> subs = await GetSubscriptionsAsync(client);
|
||||
contexts.AddRange(subs.Select(sub =>
|
||||
{
|
||||
AzureSubscriptionIdentifier subId = new AzureSubscriptionIdentifier(userAccount, azureTenant.TenantId, sub.SubscriptionId, _resourceManagementUri);
|
||||
AzureUserAccountSubscriptionContext context = new AzureUserAccountSubscriptionContext(subId, credentials);
|
||||
return context;
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
return contexts;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the azure resource groups for given subscription
|
||||
/// </summary>
|
||||
private async Task<IEnumerable<Subscription>> GetSubscriptionsAsync(SubscriptionClient subscriptionClient)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (subscriptionClient != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
ISubscriptionsOperations subscriptionsOperations = subscriptionClient.Subscriptions;
|
||||
IPage<Subscription> subscriptionList = await subscriptionsOperations.ListAsync();
|
||||
if (subscriptionList != null)
|
||||
{
|
||||
return subscriptionList.AsEnumerable();
|
||||
}
|
||||
|
||||
}
|
||||
catch (HttpOperationException ex)
|
||||
{
|
||||
throw new AzureResourceFailedException(
|
||||
string.Format(CultureInfo.CurrentCulture, SR.AzureSubscriptionFailedErrorMessage, ex.Message), ex.Response.StatusCode);
|
||||
}
|
||||
}
|
||||
|
||||
return Enumerable.Empty<Subscription>();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceException(TraceEventType.Error, (int)TraceId.AzureResource, ex, "Failed to get azure resource groups");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates credential instance for given subscription
|
||||
/// </summary>
|
||||
private Task<ServiceClientCredentials> CreateCredentialsAsync(IAzureUserAccountSubscriptionContext subscriptionContext)
|
||||
private ServiceClientCredentials CreateCredentials(IAzureTenant tenant)
|
||||
{
|
||||
AzureTenant azureTenant = tenant as AzureTenant;
|
||||
|
||||
if (azureTenant != null)
|
||||
{
|
||||
TokenCredentials credentials;
|
||||
if (!string.IsNullOrWhiteSpace(azureTenant.TokenType))
|
||||
{
|
||||
credentials = new TokenCredentials(azureTenant.AccessToken, azureTenant.TokenType);
|
||||
}
|
||||
else
|
||||
{
|
||||
credentials = new TokenCredentials(azureTenant.AccessToken);
|
||||
}
|
||||
|
||||
return credentials;
|
||||
}
|
||||
throw new NotSupportedException("This uses an unknown subscription type");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates credential instance for given subscription
|
||||
/// </summary>
|
||||
private ServiceClientCredentials CreateCredentials(IAzureUserAccountSubscriptionContext subscriptionContext)
|
||||
{
|
||||
AzureUserAccountSubscriptionContext azureUserSubContext =
|
||||
subscriptionContext as AzureUserAccountSubscriptionContext;
|
||||
|
||||
if (azureUserSubContext != null)
|
||||
{
|
||||
return Task.FromResult(azureUserSubContext.Credentials);
|
||||
return azureUserSubContext.Credentials;
|
||||
}
|
||||
throw new NotSupportedException("This uses an unknown subscription type");
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
/// </summary>
|
||||
public class AzureResourceWrapper : IAzureResource
|
||||
{
|
||||
public const string ResourceGroupsPart = "resourceGroups";
|
||||
private string resourceGroupName;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the resource
|
||||
/// </summary>
|
||||
@@ -71,7 +74,39 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
/// <summary>
|
||||
/// Resource Group Name
|
||||
/// </summary>
|
||||
public string ResourceGroupName { get; set; }
|
||||
public string ResourceGroupName {
|
||||
get
|
||||
{
|
||||
if (this.resourceGroupName == null)
|
||||
{
|
||||
this.resourceGroupName = ParseResourceGroupNameFromId();
|
||||
}
|
||||
return this.resourceGroupName;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.resourceGroupName = value;
|
||||
}
|
||||
}
|
||||
|
||||
private string ParseResourceGroupNameFromId()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Id))
|
||||
{
|
||||
string[] idParts = Id.Split('/');
|
||||
|
||||
// Look for the "resourceGroups" section and return the section after this, hence
|
||||
// always stop before idParts.Length - 1
|
||||
for (int i = 0; i < idParts.Length - 1; i++)
|
||||
{
|
||||
if (string.Compare(idParts[i], ResourceGroupsPart, StringComparison.OrdinalIgnoreCase) == 0)
|
||||
{
|
||||
return idParts[i + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resource Location
|
||||
|
||||
@@ -17,9 +17,10 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
/// <summary>
|
||||
/// Default constructor to initialize the subscription identifier
|
||||
/// </summary>
|
||||
public AzureSubscriptionIdentifier(IAzureUserAccount userAccount, string subscriptionId, Uri serviceManagementEndpoint)
|
||||
public AzureSubscriptionIdentifier(IAzureUserAccount userAccount, string tenantId, string subscriptionId, Uri serviceManagementEndpoint)
|
||||
{
|
||||
UserAccount = userAccount;
|
||||
TenantId = tenantId;
|
||||
SubscriptionId = subscriptionId;
|
||||
ServiceManagementEndpoint = serviceManagementEndpoint;
|
||||
}
|
||||
@@ -56,6 +57,15 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the tenant this subscription comes from
|
||||
/// </summary>
|
||||
public string TenantId
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// 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 Microsoft.SqlTools.ResourceProvider.Core;
|
||||
using Microsoft.SqlTools.ResourceProvider.Core.Authentication;
|
||||
|
||||
namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementation for <see cref="IAzureTenant" /> using VS services
|
||||
/// Contains information about an Azure account
|
||||
/// </summary>
|
||||
public class AzureTenant : IAzureTenant
|
||||
{
|
||||
public string TenantId
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string AccountDisplayableId
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// URI defining the root for resource lookup
|
||||
/// </summary>
|
||||
public string Resource { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Access token for use in login scenarios. Note that we could consider implementing this better in the
|
||||
/// </summary>
|
||||
public string AccessToken
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Optional token type defining whether this is a Bearer token or other type of token
|
||||
/// </summary>
|
||||
public string TokenType
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.SqlTools.ResourceProvider.Core;
|
||||
using Microsoft.SqlTools.ResourceProvider.Core.Authentication;
|
||||
|
||||
@@ -36,7 +37,9 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
this.DisplayInfo = new AzureUserAccountDisplayInfo(azureUserAccount.DisplayInfo);
|
||||
this.NeedsReauthentication = azureUserAccount.NeedsReauthentication;
|
||||
this.TenantId = azureUserAccount.TenantId;
|
||||
this.AllTenants = azureUserAccount.AllTenants;
|
||||
this.UniqueId = azureUserAccount.UniqueId;
|
||||
AzureUserAccount account = azureUserAccount as AzureUserAccount;
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns true if given user account equals this class
|
||||
@@ -46,6 +49,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
return other != null &&
|
||||
CommonUtil.SameString(other.UniqueId, UniqueId) &&
|
||||
CommonUtil.SameString(other.TenantId, TenantId);
|
||||
// TODO probably should check the AllTenants field
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -88,6 +92,12 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
|
||||
public IList<IAzureTenant> AllTenants
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
215
src/Microsoft.SqlTools.ResourceProvider.DefaultImpl/Localization/sr.cs
Normal file → Executable file
215
src/Microsoft.SqlTools.ResourceProvider.DefaultImpl/Localization/sr.cs
Normal file → Executable file
@@ -1,105 +1,160 @@
|
||||
// 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.DefaultImpl
|
||||
{
|
||||
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.DefaultImpl
|
||||
{
|
||||
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 FailedToGetAzureDatabasesErrorMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return Keys.GetString(Keys.FailedToGetAzureDatabasesErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static string FailedToGetAzureDatabasesErrorMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return Keys.GetString(Keys.FailedToGetAzureDatabasesErrorMessage);
|
||||
}
|
||||
|
||||
public static string FailedToGetAzureSubscriptionsErrorMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return Keys.GetString(Keys.FailedToGetAzureSubscriptionsErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public static string FailedToGetAzureResourceGroupsErrorMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return Keys.GetString(Keys.FailedToGetAzureResourceGroupsErrorMessage);
|
||||
}
|
||||
|
||||
public static string FailedToGetAzureResourceGroupsErrorMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return Keys.GetString(Keys.FailedToGetAzureResourceGroupsErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public static string FailedToGetAzureSqlServersErrorMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return Keys.GetString(Keys.FailedToGetAzureSqlServersErrorMessage);
|
||||
}
|
||||
|
||||
public static string FailedToGetAzureSqlServersErrorMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return Keys.GetString(Keys.FailedToGetAzureSqlServersErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public static string FirewallRuleCreationFailed
|
||||
{
|
||||
get
|
||||
{
|
||||
return Keys.GetString(Keys.FirewallRuleCreationFailed);
|
||||
}
|
||||
|
||||
public static string FailedToGetAzureSqlServersWithError
|
||||
{
|
||||
get
|
||||
{
|
||||
return Keys.GetString(Keys.FailedToGetAzureSqlServersWithError);
|
||||
}
|
||||
}
|
||||
|
||||
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class Keys
|
||||
{
|
||||
static ResourceManager resourceManager = new ResourceManager("Microsoft.SqlTools.ResourceProvider.DefaultImpl.Localization.SR", typeof(SR).GetTypeInfo().Assembly);
|
||||
|
||||
static CultureInfo _culture = null;
|
||||
|
||||
public static string FirewallRuleCreationFailed
|
||||
{
|
||||
get
|
||||
{
|
||||
return Keys.GetString(Keys.FirewallRuleCreationFailed);
|
||||
}
|
||||
}
|
||||
|
||||
public static string FirewallRuleCreationFailedWithError
|
||||
{
|
||||
get
|
||||
{
|
||||
return Keys.GetString(Keys.FirewallRuleCreationFailedWithError);
|
||||
}
|
||||
}
|
||||
|
||||
public static string AzureSubscriptionFailedErrorMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return Keys.GetString(Keys.AzureSubscriptionFailedErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public static string UnsupportedAuthType
|
||||
{
|
||||
get
|
||||
{
|
||||
return Keys.GetString(Keys.UnsupportedAuthType);
|
||||
}
|
||||
}
|
||||
|
||||
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class Keys
|
||||
{
|
||||
static ResourceManager resourceManager = new ResourceManager("Microsoft.SqlTools.ResourceProvider.DefaultImpl.Localization.SR", typeof(SR).GetTypeInfo().Assembly);
|
||||
|
||||
static CultureInfo _culture = null;
|
||||
|
||||
|
||||
public const string FailedToGetAzureDatabasesErrorMessage = "FailedToGetAzureDatabasesErrorMessage";
|
||||
|
||||
|
||||
public const string FailedToGetAzureSubscriptionsErrorMessage = "FailedToGetAzureSubscriptionsErrorMessage";
|
||||
|
||||
|
||||
public const string FailedToGetAzureResourceGroupsErrorMessage = "FailedToGetAzureResourceGroupsErrorMessage";
|
||||
|
||||
|
||||
public const string FailedToGetAzureSqlServersErrorMessage = "FailedToGetAzureSqlServersErrorMessage";
|
||||
|
||||
|
||||
public const string FailedToGetAzureSqlServersWithError = "FailedToGetAzureSqlServersWithError";
|
||||
|
||||
|
||||
public const string FirewallRuleCreationFailed = "FirewallRuleCreationFailed";
|
||||
|
||||
|
||||
private Keys()
|
||||
{ }
|
||||
public const string FirewallRuleCreationFailedWithError = "FirewallRuleCreationFailedWithError";
|
||||
|
||||
public static CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return _culture;
|
||||
}
|
||||
set
|
||||
{
|
||||
_culture = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetString(string key)
|
||||
{
|
||||
return resourceManager.GetString(key, _culture);
|
||||
}
|
||||
public const string AzureSubscriptionFailedErrorMessage = "AzureSubscriptionFailedErrorMessage";
|
||||
|
||||
|
||||
public const string UnsupportedAuthType = "UnsupportedAuthType";
|
||||
|
||||
|
||||
private Keys()
|
||||
{ }
|
||||
|
||||
public static CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return _culture;
|
||||
}
|
||||
set
|
||||
{
|
||||
_culture = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetString(string key)
|
||||
{
|
||||
return resourceManager.GetString(key, _culture);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
282
src/Microsoft.SqlTools.ResourceProvider.DefaultImpl/Localization/sr.resx
Normal file → Executable file
282
src/Microsoft.SqlTools.ResourceProvider.DefaultImpl/Localization/sr.resx
Normal file → Executable file
@@ -1,136 +1,156 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype=">text/microsoft-resx</resheader>
|
||||
<resheader name="version=">2.0</resheader>
|
||||
<resheader name="reader=">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer=">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1="><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing=">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64=">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64=">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata=">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true=">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded=">
|
||||
<xsd:element name="metadata=">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly=">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data=">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader=">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="FailedToGetAzureDatabasesErrorMessage" xml:space="preserve">
|
||||
<value>An error occurred while getting Azure databases</value>
|
||||
<comment></comment>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype=">text/microsoft-resx</resheader>
|
||||
<resheader name="version=">2.0</resheader>
|
||||
<resheader name="reader=">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer=">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1="><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing=">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64=">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64=">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata=">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true=">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded=">
|
||||
<xsd:element name="metadata=">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly=">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data=">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader=">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="FailedToGetAzureDatabasesErrorMessage" xml:space="preserve">
|
||||
<value>An error occurred while getting Azure databases</value>
|
||||
<comment></comment>
|
||||
</data>
|
||||
<data name="FailedToGetAzureResourceGroupsErrorMessage" xml:space="preserve">
|
||||
<value>An error occurred while getting Azure resource groups</value>
|
||||
<comment></comment>
|
||||
<data name="FailedToGetAzureSubscriptionsErrorMessage" xml:space="preserve">
|
||||
<value>An error occurred while getting Azure subscriptions: {0}</value>
|
||||
<comment></comment>
|
||||
</data>
|
||||
<data name="FailedToGetAzureSqlServersErrorMessage" xml:space="preserve">
|
||||
<value>An error occurred while getting Azure Sql Servers</value>
|
||||
<comment></comment>
|
||||
<data name="FailedToGetAzureResourceGroupsErrorMessage" xml:space="preserve">
|
||||
<value>An error occurred while getting Azure resource groups: {0}</value>
|
||||
<comment></comment>
|
||||
</data>
|
||||
<data name="FirewallRuleCreationFailed" xml:space="preserve">
|
||||
<value>An error occurred while creating a new firewall rule.</value>
|
||||
<comment></comment>
|
||||
<data name="FailedToGetAzureSqlServersErrorMessage" xml:space="preserve">
|
||||
<value>An error occurred while getting Azure Sql Servers</value>
|
||||
<comment></comment>
|
||||
</data>
|
||||
<data name="FailedToGetAzureSqlServersWithError" xml:space="preserve">
|
||||
<value>An error occurred while getting Azure Sql Servers: '{0}'</value>
|
||||
<comment></comment>
|
||||
</data>
|
||||
<data name="FirewallRuleCreationFailed" xml:space="preserve">
|
||||
<value>An error occurred while creating a new firewall rule.</value>
|
||||
<comment></comment>
|
||||
</data>
|
||||
<data name="FirewallRuleCreationFailedWithError" xml:space="preserve">
|
||||
<value>An error occurred while creating a new firewall rule: '{0}'</value>
|
||||
<comment></comment>
|
||||
</data>
|
||||
<data name="AzureSubscriptionFailedErrorMessage" xml:space="preserve">
|
||||
<value>An error occurred while getting Azure subscriptions</value>
|
||||
<comment></comment>
|
||||
</data>
|
||||
<data name="UnsupportedAuthType" xml:space="preserve">
|
||||
<value>Unsupported account type '{0}' for this provider</value>
|
||||
<comment></comment>
|
||||
</data>
|
||||
</root>
|
||||
|
||||
@@ -23,6 +23,11 @@
|
||||
############################################################################
|
||||
# Azure Core DLL
|
||||
FailedToGetAzureDatabasesErrorMessage = An error occurred while getting Azure databases
|
||||
FailedToGetAzureResourceGroupsErrorMessage = An error occurred while getting Azure resource groups
|
||||
FailedToGetAzureSubscriptionsErrorMessage = An error occurred while getting Azure subscriptions: {0}
|
||||
FailedToGetAzureResourceGroupsErrorMessage = An error occurred while getting Azure resource groups: {0}
|
||||
FailedToGetAzureSqlServersErrorMessage = An error occurred while getting Azure Sql Servers
|
||||
FirewallRuleCreationFailed = An error occurred while creating a new firewall rule.
|
||||
FailedToGetAzureSqlServersWithError = An error occurred while getting Azure Sql Servers: '{0}'
|
||||
FirewallRuleCreationFailed = An error occurred while creating a new firewall rule.
|
||||
FirewallRuleCreationFailedWithError = An error occurred while creating a new firewall rule: '{0}'
|
||||
AzureSubscriptionFailedErrorMessage = An error occurred while getting Azure subscriptions
|
||||
UnsupportedAuthType = Unsupported account type '{0}' for this provider
|
||||
@@ -8,7 +8,7 @@
|
||||
<note></note>
|
||||
</trans-unit>
|
||||
<trans-unit id="FailedToGetAzureResourceGroupsErrorMessage">
|
||||
<source>An error occurred while getting Azure resource groups</source>
|
||||
<source>An error occurred while getting Azure resource groups: {0}</source>
|
||||
<target state="new">An error occurred while getting Azure resource groups</target>
|
||||
<note></note>
|
||||
</trans-unit>
|
||||
@@ -22,6 +22,31 @@
|
||||
<target state="new">An error occurred while creating a new firewall rule.</target>
|
||||
<note></note>
|
||||
</trans-unit>
|
||||
<trans-unit id="AzureSubscriptionFailedErrorMessage">
|
||||
<source>An error occurred while getting Azure subscriptions</source>
|
||||
<target state="new">An error occurred while getting Azure subscriptions</target>
|
||||
<note></note>
|
||||
</trans-unit>
|
||||
<trans-unit id="UnsupportedAuthType">
|
||||
<source>Unsupported account type '{0}' for this provider</source>
|
||||
<target state="new">Unsupported account type '{0}' for this provider</target>
|
||||
<note></note>
|
||||
</trans-unit>
|
||||
<trans-unit id="FailedToGetAzureSqlServersWithError">
|
||||
<source>An error occurred while getting Azure Sql Servers: '{0}'</source>
|
||||
<target state="new">An error occurred while getting Azure Sql Servers: '{0}'</target>
|
||||
<note></note>
|
||||
</trans-unit>
|
||||
<trans-unit id="FirewallRuleCreationFailedWithError">
|
||||
<source>An error occurred while creating a new firewall rule: '{0}'</source>
|
||||
<target state="new">An error occurred while creating a new firewall rule: '{0}'</target>
|
||||
<note></note>
|
||||
</trans-unit>
|
||||
<trans-unit id="FailedToGetAzureSubscriptionsErrorMessage">
|
||||
<source>An error occurred while getting Azure subscriptions: {0}</source>
|
||||
<target state="new">An error occurred while getting Azure subscriptions: {0}</target>
|
||||
<note></note>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
@@ -3,12 +3,12 @@
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<PackageId>Microsoft.SqlTools.ResourceProvider.DefaultImpl</PackageId>
|
||||
<AssemblyName>Microsoft.SqlTools.ResourceProvider.DefaultImpl</AssemblyName>
|
||||
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
|
||||
<ApplicationIcon />
|
||||
<OutputType>Library</OutputType>
|
||||
<StartupObject />
|
||||
<Description>Provides the default for SqlTools applications.</Description>
|
||||
<Copyright><EFBFBD> Microsoft Corporation. All rights reserved.</Copyright>
|
||||
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
|
||||
<ApplicationIcon />
|
||||
<OutputType>Library</OutputType>
|
||||
<StartupObject />
|
||||
<Description>Provides the default for SqlTools applications.</Description>
|
||||
<Copyright><EFBFBD> Microsoft Corporation. All rights reserved.</Copyright>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="1.6.0-preview" />
|
||||
@@ -18,7 +18,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="2.0.0" />
|
||||
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
|
||||
<PackageReference Include="System.Composition" Version="1.1.0" />
|
||||
<PackageReference Include="Microsoft.Azure.Management.Sql" Version="1.6.0-preview" />
|
||||
<PackageReference Include="Microsoft.Azure.Management.Sql" Version="1.7.0-preview" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Microsoft.SqlTools.ResourceProvider.Core\Microsoft.SqlTools.ResourceProvider.Core.csproj" />
|
||||
|
||||
Reference in New Issue
Block a user