Skip to content

Commit

Permalink
[Synapse] Add support for workspace Repository Configuration (#15660)
Browse files Browse the repository at this point in the history
* Update change log

* Support CICD

* Add PSWorkspaceRepositoryConfiguration

* Revert gen3 changes

* link to git repo when create a workspace

* add help docs

* redesign git repo related cmdlets

* update New-AzSynapseWorkspace.md

* update changelog

* fix for ci test

Co-authored-by: Dongwei Wang <[email protected]>
Co-authored-by: Wan Yang <[email protected]>
  • Loading branch information
3 people authored Aug 13, 2021
1 parent 2ce9bcc commit 4eeda23
Show file tree
Hide file tree
Showing 17 changed files with 481 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/Synapse/Synapse/Az.Synapse.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ CmdletsToExport = 'Get-AzSynapseSparkJob', 'Stop-AzSynapseSparkJob',
'Set-AzSynapseSparkJobDefinition',
'Get-AzSynapseManagedPrivateEndpoint',
'New-AzSynapseManagedPrivateEndpoint',
'Remove-AzSynapseManagedPrivateEndpoint'
'Remove-AzSynapseManagedPrivateEndpoint',
'New-AzSynapseGitRepositoryConfig'

# Variables to export from this module
# VariablesToExport = @()
Expand Down
5 changes: 4 additions & 1 deletion src/Synapse/Synapse/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
- Added `Remove-AzSynapseManagedPrivateEndpoint` cmdlet
* Fixed the blank page issue of pause setting and scale setting for Apache Spark pool through management API
* Updated `Set-AzSynapseSqlActiveDirectoryAdministrator` to support for setting SQL Admin by `DisplayName` or by `ObjectId`
* Renamed `Update-AzSynapseWorkspaceKey` to `Enable-AzSynapseWorkspace` to activate a new synapse workspace without `-Activate` parameter
* Renamed `Update-AzSynapseWorkspaceKey` to `Enable-AzSynapseWorkspace` to activate a new synapse workspace without `-Activate` parameter
* Added `New-AzSynapseGitRepositoryConfig` cmdlet to create Git repository configuration
* Updated `New-AzSynapseWorkspace` and `Update-AzSynapseWorkspace` to support for connecting a workspace to a Git reposirory
- Added parameters `-GitRepositoryType`

## Version 0.14.0
* Added parameter `-ManagedResourceGroupName` for the `New-AzSynapseWorkspace` cmdlet
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using Microsoft.Azure.Commands.Synapse.Common;
using Microsoft.Azure.Commands.Synapse.Models;
using Microsoft.Azure.Commands.Synapse.Properties;
using Microsoft.Azure.Management.Synapse.Models;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using System;
using System.Management.Automation;

namespace Microsoft.Azure.Commands.Synapse.Commands
{
[Cmdlet(VerbsCommon.New, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + SynapseConstants.SynapsePrefix + SynapseConstants.GitRepositoryConfig)]
[OutputType(typeof(PSWorkspaceRepositoryConfiguration))]
public class NewAzureSynapseGitRepositoryConfig : SynapseManagementCmdletBase
{
[Parameter(Mandatory = true, HelpMessage = HelpMessages.RepositoryType)]
[ValidateSet(SynapseConstants.RepositoryType.GitHub, SynapseConstants.RepositoryType.AzureDevOpsGit, IgnoreCase = false)]
[ValidateNotNullOrEmpty]
public string RepositoryType { get; set; }

[Parameter(Mandatory = false, HelpMessage = HelpMessages.HostName)]
[ValidateNotNullOrEmpty]
public string HostName { get; set; }

[Parameter(Mandatory = true, HelpMessage = HelpMessages.AccountName)]
[ValidateNotNullOrEmpty]
public string AccountName { get; set; }

[Parameter(Mandatory = false, HelpMessage = HelpMessages.ProjectName)]
[ValidateNotNullOrEmpty]
public string ProjectName { get; set; }

[Parameter(Mandatory = true, HelpMessage = HelpMessages.RepositoryName)]
[ValidateNotNullOrEmpty]
public string RepositoryName { get; set; }

[Parameter(Mandatory = true, HelpMessage = HelpMessages.CollaborationBranch)]
[ValidateNotNullOrEmpty]
public string CollaborationBranch { get; set; }

[Parameter(Mandatory = false, HelpMessage = HelpMessages.RootFolder)]
[ValidateNotNullOrEmpty]
public string RootFolder { get; set; } = "/";

[Parameter(Mandatory = false, HelpMessage = HelpMessages.TenantId)]
[ValidateNotNullOrEmpty]
public Guid TenantId { get; set; }

public override void ExecuteCmdlet()
{
if (this.RepositoryType == SynapseConstants.RepositoryType.AzureDevOpsGit && this.ProjectName == null)
{
throw new PSArgumentException(string.Format(Resources.WorkspaceGitRepoParameterException, "ProjectName"), "ProjectName");
}

if (this.RepositoryType == SynapseConstants.RepositoryType.AzureDevOpsGit)
{
if (!this.IsParameterBound(c => c.TenantId))
{
this.TenantId = SynapseAnalyticsClient.GetTenantId();
}
}

var settings = new WorkspaceRepositoryConfiguration
{
Type = this.RepositoryType == SynapseConstants.RepositoryType.AzureDevOpsGit ? SynapseConstants.RepositoryType.WorkspaceVSTSConfiguration : SynapseConstants.RepositoryType.WorkspaceGitHubConfiguration,
HostName = this.RepositoryType == SynapseConstants.RepositoryType.GitHub ? this.HostName : null,
AccountName = this.AccountName,
ProjectName = this.RepositoryType == SynapseConstants.RepositoryType.AzureDevOpsGit ? this.ProjectName : null,
RepositoryName = this.RepositoryName,
CollaborationBranch = this.CollaborationBranch,
TenantId = this.TenantId,
RootFolder = this.RootFolder
};

WriteObject(new PSWorkspaceRepositoryConfiguration(settings));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public class NewAzureSynapseWorkspace : SynapseManagementCmdletBase
[ValidateNotNullOrEmpty]
public string ManagedResourceGroupName { get; set; }

[Parameter(Mandatory = false, HelpMessage = HelpMessages.GitRepository)]
[ValidateNotNull]
public PSWorkspaceRepositoryConfiguration GitRepository { get; set; }

public override void ExecuteCmdlet()
{
try
Expand Down Expand Up @@ -134,7 +138,8 @@ public override void ExecuteCmdlet()
KeyVaultUrl = this.EncryptionKeyIdentifier
}
}
} : null
} : null,
WorkspaceRepositoryConfiguration = this.IsParameterBound(c => c.GitRepository) ? this.GitRepository.ToSdkObject() : null
};

if (ShouldProcess(Name, string.Format(Resources.CreatingSynapseWorkspace, this.ResourceGroupName, this.Name)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public class UpdateAzureSynapseWorkspace : SynapseManagementCmdletBase
[ValidateNotNullOrEmpty]
public string EncryptionKeyName { get; set; }

[Parameter(Mandatory = false, HelpMessage = HelpMessages.GitRepository)]
[ValidateNotNull]
public PSWorkspaceRepositoryConfiguration GitRepository { get; set; }

[Parameter(Mandatory = false, HelpMessage = HelpMessages.AsJob)]
public SwitchParameter AsJob { get; set; }

Expand Down Expand Up @@ -116,6 +120,7 @@ public override void ExecuteCmdlet()
}
}
} : null;
patchInfo.WorkspaceRepositoryConfiguration = this.IsParameterBound(c => c.GitRepository) ? this.GitRepository.ToSdkObject() : null;

if (ShouldProcess(this.Name, string.Format(Resources.UpdatingSynapseWorkspace, this.Name, this.ResourceGroupName)))
{
Expand Down
20 changes: 20 additions & 0 deletions src/Synapse/Synapse/Common/HelpMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ public static class HelpMessages

public const string SqlAdministratorLoginCredential = "SQL administrator credentials.";

public const string GitRepository = "Git Repository Settings. Connect workspace to the repository for source control and collaboration for work on your workspace pipelines";

public const string RepositoryType = "Select the repository type that you want to use to store your artifacts for this Synapse Analytics workspace, the type include DevOps and GitHub.";

public const string HostName = "GitHub Enterprise host name. For example: https://github.mydomain.com";

public const string AccountName = "GitHub or DevOps account name used for the repository.";

public const string ProjectName = "The project name you are connecting, only specify it when you choose DevOps.";

public const string RepositoryName = "The name of the repository you are connecting.";

public const string CollaborationBranch = "Select the branch name where you will collaborate with others and from which you will publish.";

public const string PublishBranch = "The publish branch is the branch in your repository where publishing related ARM templates are stored and update. The default value is workspace_publish.";

public const string RootFolder = "Displays the name of the folder to the location of your Azure Data Factory JSON resources are imported. The default value is /";

public const string TenantId = "Select the tenant Id to use when signing in into the Azure DevOps Git repository.";

public const string DoNotAssignManagedIdentity = "Do not assign the workspace's system-assigned managed identity CONTROL permissions to SQL pools for pipeline integration.";

public const string SparkPoolName = "Name of Synapse Spark pool.";
Expand Down
6 changes: 6 additions & 0 deletions src/Synapse/Synapse/Models/PSSynapseWorkspace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public PSSynapseWorkspace(Workspace workspace)
this.ExtraProperties = workspace.ExtraProperties;
this.ManagedVirtualNetworkSettings = workspace?.ManagedVirtualNetworkSettings != null ? new PSManagedVirtualNetworkSettings(workspace?.ManagedVirtualNetworkSettings) : null;
this.Encryption = workspace?.Encryption != null ? new PSEncryptionDetails(workspace?.Encryption) : null;
this.WorkspaceRepositoryConfiguration = workspace.WorkspaceRepositoryConfiguration != null ? new PSWorkspaceRepositoryConfiguration(workspace?.WorkspaceRepositoryConfiguration) : null;
}

/// <summary>
Expand Down Expand Up @@ -89,5 +90,10 @@ public PSSynapseWorkspace(Workspace workspace)
/// Gets or sets the encryption details of the workspace
/// </summary>
public PSEncryptionDetails Encryption { get; set; }

/// <summary>
/// Gets or sets git integration settings
/// </summary>
public PSWorkspaceRepositoryConfiguration WorkspaceRepositoryConfiguration { get; set; }
}
}
83 changes: 83 additions & 0 deletions src/Synapse/Synapse/Models/PSWorkspaceRepositoryConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using Microsoft.Azure.Management.Synapse.Models;

namespace Microsoft.Azure.Commands.Synapse.Models
{
public class PSWorkspaceRepositoryConfiguration
{
private WorkspaceRepositoryConfiguration workspaceRepositoryConfiguration;

public PSWorkspaceRepositoryConfiguration(WorkspaceRepositoryConfiguration workspaceRepositoryConfiguration)
{
this.workspaceRepositoryConfiguration = workspaceRepositoryConfiguration;
this.Type = workspaceRepositoryConfiguration.Type;
this.HostName = workspaceRepositoryConfiguration.HostName;
this.AccountName = workspaceRepositoryConfiguration.AccountName;
this.ProjectName = workspaceRepositoryConfiguration.ProjectName;
this.RepositoryName = workspaceRepositoryConfiguration.RepositoryName;
this.CollaborationBranch = workspaceRepositoryConfiguration.CollaborationBranch;
this.RootFolder = workspaceRepositoryConfiguration.RootFolder;
this.LastCommitId = workspaceRepositoryConfiguration.LastCommitId;
this.TenantId = workspaceRepositoryConfiguration.TenantId;
}

/// <summary>
/// Gets or sets type of workspace repositoryID configuration. Example
/// WorkspaceVSTSConfiguration, WorkspaceGitHubConfiguration
/// </summary>
public string Type { get; set; }

/// <summary>
/// Gets or sets gitHub Enterprise host name. For example:
/// https://github.mydomain.com
/// </summary>
public string HostName { get; set; }

/// <summary>
/// Gets or sets account name
/// </summary>
public string AccountName { get; set; }

/// <summary>
/// Gets or sets VSTS project name
/// </summary>
public string ProjectName { get; set; }

/// <summary>
/// Gets or sets repository name
/// </summary>
public string RepositoryName { get; set; }

/// <summary>
/// Gets or sets collaboration branch
/// </summary>
public string CollaborationBranch { get; set; }

/// <summary>
/// Gets or sets root folder to use in the repository
/// </summary>
public string RootFolder { get; set; }

/// <summary>
/// Gets or sets the last commit ID
/// </summary>
public string LastCommitId { get; set; }

/// <summary>
/// Gets or sets the VSTS tenant ID
/// </summary>
public System.Guid? TenantId { get; set; }

public WorkspaceRepositoryConfiguration ToSdkObject()
{
return new WorkspaceRepositoryConfiguration
{
Type = this.Type,
AccountName = this.AccountName,
ProjectName = this.ProjectName,
RepositoryName = this.RepositoryName,
CollaborationBranch = this.CollaborationBranch,
RootFolder = this.RootFolder
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ public Workspace CreateWorkspace(string resourceGroupName, string workspaceName,
}
}

public Guid GetTenantId()
{
return this._tenantId;
}

public Workspace UpdateWorkspace(string resourceGroupName, string workspaceName, WorkspacePatchInfo updateParams)
{
try
Expand Down
10 changes: 10 additions & 0 deletions src/Synapse/Synapse/Models/SynapseConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ public static class SynapseConstants

public const string ManagedVirtualNetworkConfig = nameof(ManagedVirtualNetworkConfig);

public const string GitRepositoryConfig = nameof(GitRepositoryConfig);

public const string EncryptionConfig = nameof(EncryptionConfig);

public const string WorkspaceKey = nameof(WorkspaceKey);
Expand Down Expand Up @@ -243,5 +245,13 @@ public enum WorkspaceItemType
LinkedService,
Credential
}

public class RepositoryType
{
public const string GitHub = "GitHub";
public const string AzureDevOpsGit = "AzureDevOpsGit";
public const string WorkspaceGitHubConfiguration = "WorkspaceGitHubConfiguration";
public const string WorkspaceVSTSConfiguration = "WorkspaceVSTSConfiguration";
}
}
}
9 changes: 9 additions & 0 deletions src/Synapse/Synapse/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Synapse/Synapse/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -690,4 +690,7 @@ Are you sure you want to continue?</value>
<data name="SettingSynapseManagedPrivateEndPoint" xml:space="preserve">
<value>Creating or updating Synapse managed private endpoint '{0}' in workspace '{1}'.</value>
</data>
<data name="WorkspaceGitRepoParameterException" xml:space="preserve">
<value>'{0}' is not provided.</value>
</data>
</root>
3 changes: 3 additions & 0 deletions src/Synapse/Synapse/help/Az.Synapse.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ Invokes a Synapse Analytics Spark statement.
### [New-AzSynapseFirewallRule](New-AzSynapseFirewallRule.md)
Creates a Synapse Analytics Firewall Rule.

### [New-AzSynapseGitRepositoryConfig](New-AzSynapseGitRepositoryConfig.md)
Creates Git repository configuration.

### [New-AzSynapseIntegrationRuntimeKey](New-AzSynapseIntegrationRuntimeKey.md)
Regenerate self-hosted integration runtime key.

Expand Down
Loading

0 comments on commit 4eeda23

Please sign in to comment.