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:
Kevin Cunnane
2017-10-09 15:45:33 -07:00
committed by GitHub
parent fecf56bce2
commit 7acc668c04
49 changed files with 1844 additions and 556 deletions

View File

@@ -20,6 +20,11 @@
<ItemGroup>
<ProjectReference Include="..\Microsoft.SqlTools.Hosting\Microsoft.SqlTools.Hosting.csproj" />
<!-- Note: must reference the resource provider projects in order for them to be bundled into the app. Otherwise will not have any of the required DLLs and
dependencies included when the project is shipped. If adding new DLLs, add them here or find another solution to keep them bundled
-->
<ProjectReference Include="..\Microsoft.SqlTools.ResourceProvider.Core\Microsoft.SqlTools.ResourceProvider.Core.csproj" />
<ProjectReference Include="..\Microsoft.SqlTools.ResourceProvider.DefaultImpl\Microsoft.SqlTools.ResourceProvider.DefaultImpl.csproj" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Localization\sr.resx" />

View File

@@ -11,11 +11,11 @@ using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ResourceProvider
{
/// <summary>
/// Main application class for Credentials Service Host executable
/// Main application class for the executable that supports the resource provider and identity services
/// </summary>
internal class Program
{
private const string ServiceName = "SqlToolsAzure.exe";
private const string ServiceName = "SqlToolsResourceProviderService.exe";
/// <summary>
/// Main entry point into the Credentials Service Host
@@ -31,7 +31,7 @@ namespace Microsoft.SqlTools.ResourceProvider
return;
}
string logFilePath = "sqltoolsazure";
string logFilePath = "SqlToolsResourceProviderService";
if (!string.IsNullOrWhiteSpace(commandOptions.LoggingDirectory))
{
logFilePath = Path.Combine(commandOptions.LoggingDirectory, logFilePath);
@@ -40,11 +40,11 @@ namespace Microsoft.SqlTools.ResourceProvider
// turn on Verbose logging during early development
// we need to switch to Normal when preparing for public preview
Logger.Initialize(logFilePath: logFilePath, minimumLogLevel: LogLevel.Verbose, isEnabled: commandOptions.EnableLogging);
Logger.Write(LogLevel.Normal, "Starting SqlTools Azure Provider");
Logger.Write(LogLevel.Normal, "Starting SqlTools Resource Provider");
// set up the host details and profile paths
var hostDetails = new HostDetails(
name: "SqlTools Azure Provider",
name: "SqlTools Resource Provider",
profileId: "Microsoft.SqlTools.ResourceProvider",
version: new Version(1, 0));

View File

@@ -2,6 +2,8 @@
// 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 System.Reflection;
using Microsoft.SqlTools.Extensibility;
using Microsoft.SqlTools.Hosting;
using Microsoft.SqlTools.Hosting.Protocol;
@@ -45,18 +47,25 @@ namespace Microsoft.SqlTools.ResourceProvider
{
// Load extension provider, which currently finds all exports in current DLL. Can be changed to find based
// on directory or assembly list quite easily in the future
ExtensionServiceProvider serviceProvider = ExtensionServiceProvider.CreateDefaultServiceProvider();
ExtensionServiceProvider serviceProvider = ExtensionServiceProvider.CreateFromAssembliesInDirectory(GetResourceProviderExtensionDlls());
serviceProvider.RegisterSingleService(sqlToolsContext);
serviceProvider.RegisterSingleService(serviceHost);
// CredentialService.Instance.InitializeService(serviceHost);
// serviceProvider.RegisterSingleService(CredentialService.Instance);
InitializeHostedServices(serviceProvider, serviceHost);
serviceHost.InitializeRequestHandlers();
}
public static IEnumerable<string> GetResourceProviderExtensionDlls()
{
return new string[] {
"SqlToolsResourceProviderService.dll",
"Microsoft.SqlTools.ResourceProvider.Core.dll",
"Microsoft.SqlTools.ResourceProvider.DefaultImpl.dll"
};
}
/// <summary>
/// Internal to support testing. Initializes <see cref="IHostedService"/> instances in the service,
/// and registers them for their preferred service type