-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Synapse] - Build track 2 data plane SDK #12275
Merged
idear1203
merged 16 commits into
Azure:master
from
idear1203:synapse_track_2_data_plane_sdk
Jun 6, 2020
+112,768
−2
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4a28dd4
[Synapse] - Build track 2 SDK
d2e1321
Update ci.yml
idear1203 ed21101
Remove unused gitignore
idear1203 1e2c362
Resolve compilation error
idear1203 2860727
Fix build error
idear1203 45aaee8
Update README
idear1203 85784e9
Update code snippets and README
idear1203 704596f
Update README
idear1203 4ee4db8
Add file header for code snippet
idear1203 93a1495
Remove template api
idear1203 28de6df
Rename Azure.Analytics.Synapse.Development to Azure.Analytics.Synapse…
idear1203 631ab8c
Re-generate to the latest Swagger spec
idear1203 72e4c47
Regenerate with the latest code generator
idear1203 9e37ad7
Resolve comments
idear1203 0c364f7
Make VersionString internal and remove setter
idear1203 5213b13
Sync up with master, consume official Swagger repo and regenerate code
idear1203 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
sdk/synapse/Azure.Analytics.Synapse.AccessControl/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Release History | ||
|
||
## 1.0.0-preview.1 (Unreleased) | ||
- Initial release |
6 changes: 6 additions & 0 deletions
6
sdk/synapse/Azure.Analytics.Synapse.AccessControl/Directory.Build.props
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<!-- | ||
Add any shared properties you want for the projects under this package directory that need to be set before the auto imported Directory.Build.props | ||
--> | ||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., Directory.Build.props))\Directory.Build.props" /> | ||
</Project> |
121 changes: 121 additions & 0 deletions
121
sdk/synapse/Azure.Analytics.Synapse.AccessControl/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# Azure Synapse Analytics Access Control client library for .NET | ||
|
||
This directory contains the open source subset of the .NET SDK. For documentation of the complete Azure SDK, please see the [Microsoft Azure .NET Developer Center](http://azure.microsoft.com/en-us/develop/net/). | ||
|
||
The Azure Synapse Analytics access control client library enables programmatically managing role assignments. | ||
|
||
Azure Synapse is a limitless analytics service that brings together enterprise data warehousing and Big Data analytics. It gives you the freedom to query data on your terms, using either serverless on-demand or provisioned resources—at scale. Azure Synapse brings these two worlds together with a unified experience to ingest, prepare, manage, and serve data for immediate BI and machine learning needs. | ||
|
||
## Getting started | ||
|
||
The complete Microsoft Azure SDK can be downloaded from the [Microsoft Azure Downloads Page](http://azure.microsoft.com/en-us/downloads/?sdk=net) and ships with support for building deployment packages, integrating with tooling, rich command line tooling, and more. | ||
|
||
For the best development experience, developers should use the official Microsoft NuGet packages for libraries. NuGet packages are regularly updated with new functionality and hotfixes. | ||
|
||
### Install the package | ||
Install the Azure Synapse Analytics access control client library for .NET with [NuGet][nuget]: | ||
|
||
```PowerShell | ||
dotnet add package Azure.Analytics.Synapse.AccessControl --version 0.1.0-preview.1 | ||
``` | ||
|
||
### Prerequisites | ||
* An [Azure subscription][azure_sub]. | ||
* An existing Azure Synapse workspace. If you need to create an Azure Synapse workspace, you can use the Azure Portal or [Azure CLI][azure_cli]. | ||
|
||
If you use the Azure CLI, the command looks like below: | ||
|
||
```PowerShell | ||
az synapse workspace create \ | ||
--name <your-workspace-name> \ | ||
--resource-group <your-resource-group-name> \ | ||
--storage-account <your-storage-account-name> \ | ||
--file-system <your-storage-file-system-name> \ | ||
--sql-admin-login-user <your-sql-admin-user-name> \ | ||
--sql-admin-login-password <your-sql-admin-user-password> \ | ||
--location <your-workspace-location> | ||
``` | ||
|
||
### Authenticate the client | ||
In order to interact with the Azure Synapse Analytics service, you'll need to create an instance of the [AccessControlClient][accesscontrol_client_class] class. You need a **workspace endpoint**, which you may see as "Development endpoint" in the portal, | ||
and **client secret credentials (client id, client secret, tenant id)** to instantiate a client object. | ||
|
||
Client secret credential authentication is being used in this getting started section but you can find more ways to authenticate with [Azure identity][azure_identity]. To use the [DefaultAzureCredential][DefaultAzureCredential] provider shown below, | ||
or other credential providers provided with the Azure SDK, you should install the Azure.Identity package: | ||
|
||
```PowerShell | ||
Install-Package Azure.Identity | ||
``` | ||
|
||
## Key concepts | ||
|
||
### AccessControlClient | ||
With a `AccessControlClient` you can get role assignments from the workspace, create new role assignments, and delete role assignments. | ||
|
||
### Role Assignment | ||
The way you control access to Synapse resources is to create role assignments. A role assignment is the process of attaching a role definition to a user, group, service principal, or managed identity at a particular scope for the purpose of granting access. Access is granted by creating a role assignment, and access is revoked by removing a role assignment. | ||
|
||
## Examples | ||
The Azure.Analytics.Synapse.AccessControl package supports synchronous and asynchronous APIs. The following section covers some of the most common Azure Synapse Analytics access control related tasks: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit - maybe explain what a 'role assignment' is here since all your examples jump right into it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good suggestion! Added to Key concepts section. |
||
|
||
### Role assignment examples | ||
* [Create a role assignment](#create-a-role-assignment) | ||
* [Retrieve a role assignment](#retrieve-a-role-assignment) | ||
* [List role assignments](#list-role-assignments) | ||
* [Delete a role assignment](#delete-a-role-assignment) | ||
|
||
### Create a role assignment | ||
|
||
`CreateRoleAssignment` creates a role assignment. | ||
|
||
```C# Snippet:CreateRoleAssignment | ||
RoleAssignmentOptions options = new RoleAssignmentOptions(sqlAdminRoleId, principalId); | ||
RoleAssignmentDetails roleAssignment = client.CreateRoleAssignment(options); | ||
``` | ||
|
||
### Retrieve a role assignment | ||
|
||
`GetRoleAssignmentById` retrieves a role assignment by the given principal ID. | ||
|
||
```C# Snippet:RetrieveRoleAssignment | ||
RoleAssignmentDetails roleAssignment = client.GetRoleAssignmentById(principalId); | ||
``` | ||
|
||
### List role assignments | ||
`GetRoleAssignments` enumerates the role assignments in the Synapse workspace. | ||
|
||
```C# Snippet:ListRoleAssignments | ||
IReadOnlyList<RoleAssignmentDetails> roleAssignments = client.GetRoleAssignments().Value; | ||
foreach (RoleAssignmentDetails assignment in roleAssignments) | ||
{ | ||
Console.WriteLine(assignment.Id); | ||
} | ||
``` | ||
|
||
### Delete a role assignment | ||
|
||
`DeleteRoleAssignmentById` deletes a role assignment by the given principal ID. | ||
|
||
```C# Snippet:DeleteRoleAssignment | ||
client.DeleteRoleAssignmentById(roleAssignment.Id); | ||
``` | ||
|
||
## To build | ||
|
||
For information on building the Azure Synapse client library, please see [Building the Microsoft Azure SDK for .NET](https://github.com/azure/azure-sdk-for-net#to-build) | ||
|
||
## Target frameworks | ||
|
||
For information about the target frameworks of the Azure Synapse client library, please refer to the [Target Frameworks](https://github.com/azure/azure-sdk-for-net#target-frameworks) of the Microsoft Azure SDK for .NET. | ||
|
||
## Troubleshooting | ||
|
||
Please open issue in github. | ||
|
||
## Next steps | ||
|
||
The next step is adding more examples | ||
|
||
## Contributing | ||
|
||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. |
43 changes: 43 additions & 0 deletions
43
...se/Azure.Analytics.Synapse.AccessControl/src/Azure.Analytics.Synapse.AccessControl.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<Description>This is the Microsoft Azure Synapse Analytics Access Control client library</Description> | ||
<AssemblyTitle>Azure.Analytics.Synapse.AccessControl</AssemblyTitle> | ||
<Version>1.0.0-preview.1</Version> | ||
<PackageTags>Microsoft Azure Synapse Access Control;$(PackageCommonTags)</PackageTags> | ||
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks> | ||
<EnableApiCompat>false</EnableApiCompat> | ||
|
||
<NoWarn> | ||
$(NoWarn); | ||
SA1649; | ||
CA1812; | ||
<!-- Missing XML comment for publicly visible type or member --> | ||
CS1591; | ||
</NoWarn> | ||
</PropertyGroup> | ||
|
||
<Import Project="..\..\Azure.Analytics.Synapse.Shared\src\Azure.Analytics.Synapse.Shared.projitems" Label="Shared" /> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.Text.Json" /> | ||
</ItemGroup> | ||
|
||
<!-- Shared source from Azure.Core --> | ||
<ItemGroup> | ||
<Compile Include="$(AzureCoreSharedSources)Argument.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" /> | ||
<Compile Include="$(AzureCoreSharedSources)ArrayBufferWriter.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" /> | ||
<Compile Include="$(AzureCoreSharedSources)AzureKeyCredentialPolicy.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" /> | ||
<Compile Include="$(AzureCoreSharedSources)ClientDiagnostics.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" /> | ||
<Compile Include="$(AzureCoreSharedSources)ContentTypeUtilities.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" /> | ||
<Compile Include="$(AzureCoreSharedSources)DiagnosticScope.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" /> | ||
<Compile Include="$(AzureCoreSharedSources)DiagnosticScopeFactory.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" /> | ||
<Compile Include="$(AzureCoreSharedSources)ForwardsClientCallsAttribute.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" /> | ||
<Compile Include="$(AzureCoreSharedSources)HttpMessageSanitizer.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" /> | ||
<Compile Include="$(AzureCoreSharedSources)OperationHelpers.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" /> | ||
<Compile Include="$(AzureCoreSharedSources)TaskExtensions.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" /> | ||
<Compile Include="$(AzureCoreSharedSources)AzureResourceProviderNamespaceAttribute.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" /> | ||
</ItemGroup> | ||
|
||
<Import Project="$(MSBuildThisFileDirectory)..\..\..\core\Azure.Core\src\Azure.Core.props" /> | ||
|
||
</Project> |
31 changes: 31 additions & 0 deletions
31
sdk/synapse/Azure.Analytics.Synapse.AccessControl/src/Customization/AccessControlClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using Azure.Core; | ||
using Azure.Core.Pipeline; | ||
|
||
namespace Azure.Analytics.Synapse.AccessControl | ||
{ | ||
public partial class AccessControlClient | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AccessControlClient"/>. | ||
/// </summary> | ||
public AccessControlClient(Uri endpoint, TokenCredential credential) | ||
: this(endpoint, credential, AccessControlClientOptions.Default) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AccessControlClient"/>. | ||
/// </summary> | ||
public AccessControlClient(Uri endpoint, TokenCredential credential, AccessControlClientOptions options) | ||
: this(new ClientDiagnostics(options), | ||
SynapseClientPipeline.Build(options, credential), | ||
endpoint.ToString(), | ||
options.VersionString) | ||
{ | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...pse/Azure.Analytics.Synapse.AccessControl/src/Customization/AccessControlClientOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using Azure.Core; | ||
using System; | ||
|
||
namespace Azure.Analytics.Synapse.AccessControl | ||
{ | ||
/// <summary> | ||
/// The options for <see cref="AccessControlClient"/>. | ||
/// </summary> | ||
public class AccessControlClientOptions : ClientOptions | ||
{ | ||
private const ServiceVersion Latest = ServiceVersion.V2020_02_01_preview; | ||
|
||
internal static AccessControlClientOptions Default { get; } = new AccessControlClientOptions(); | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AccessControlClientOptions"/>. | ||
/// </summary> | ||
public AccessControlClientOptions(ServiceVersion serviceVersion = Latest) | ||
{ | ||
VersionString = serviceVersion switch | ||
{ | ||
ServiceVersion.V2020_02_01_preview => "2020-02-01-preview", | ||
_ => throw new ArgumentOutOfRangeException(nameof(serviceVersion)) | ||
}; | ||
} | ||
|
||
/// <summary> | ||
/// API version for Azure Synapse Access Control service. | ||
/// </summary> | ||
internal string VersionString { get; } | ||
|
||
/// <summary> | ||
/// The Synapse service version. | ||
/// </summary> | ||
public enum ServiceVersion | ||
{ | ||
/// <summary> | ||
/// The 2019-06-01-preview of the template service. | ||
/// </summary> | ||
#pragma warning disable CA1707 | ||
V2020_02_01_preview = 1 | ||
#pragma warning restore CA1707 | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit - move this line to the top of this section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed