-
Notifications
You must be signed in to change notification settings - Fork 4k
[Synapse] - new cmdlets for Spark job definition #15156
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
38f037d
Save current status
8786b73
Save current status
e63934c
Upgrade artfacts to 1.0.0-preview.9
5f092bf
Save current status
e99b45c
Remvoe SQL script
ada8257
Add example files
6dd1b4e
Update examples
9acffc1
Update changelog
38187a6
Remove rename parameter set
b218fad
Fix changelog
4ae245a
Fix online version
26a0d73
Suppresses breaking change issues
2a18918
Remove serialized cmdlets config files for Synapse
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
53 changes: 53 additions & 0 deletions
53
...mands/DataPlaneCommands/Artifact/SparkJobDefinitions/GetAzureSynapseSparkJobDefinition.cs
This file contains hidden or 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,53 @@ | ||
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; | ||
using Microsoft.Azure.Commands.Synapse.Common; | ||
using Microsoft.Azure.Commands.Synapse.Models; | ||
using Microsoft.WindowsAzure.Commands.Utilities.Common; | ||
using System.Linq; | ||
using System.Management.Automation; | ||
|
||
namespace Microsoft.Azure.Commands.Synapse | ||
{ | ||
[Cmdlet(VerbsCommon.Get, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + SynapseConstants.SynapsePrefix + SynapseConstants.SparkJobDefinition, | ||
DefaultParameterSetName = GetByName)] | ||
[OutputType(typeof(PSSparkJobDefinitionResource))] | ||
public class GetAzureSynapseSparkJobDefinition : SynapseArtifactsCmdletBase | ||
{ | ||
private const string GetByName = "GetByName"; | ||
private const string GetByObject = "GetByObject"; | ||
|
||
[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = GetByName, | ||
Mandatory = true, HelpMessage = HelpMessages.WorkspaceName)] | ||
[ResourceNameCompleter(ResourceTypes.Workspace, "ResourceGroupName")] | ||
[ValidateNotNullOrEmpty] | ||
public override string WorkspaceName { get; set; } | ||
|
||
[Parameter(ValueFromPipeline = true, ParameterSetName = GetByObject, | ||
Mandatory = true, HelpMessage = HelpMessages.WorkspaceObject)] | ||
[ValidateNotNull] | ||
public PSSynapseWorkspace WorkspaceObject { get; set; } | ||
|
||
[Parameter(ValueFromPipelineByPropertyName = false, Mandatory = false, HelpMessage = HelpMessages.SparkJobDefinitionName)] | ||
[ValidateNotNullOrEmpty] | ||
[Alias("SparkJobDefinitionName")] | ||
public string Name { get; set; } | ||
|
||
public override void ExecuteCmdlet() | ||
{ | ||
if (this.IsParameterBound(c => c.WorkspaceObject)) | ||
{ | ||
this.WorkspaceName = this.WorkspaceObject.Name; | ||
} | ||
|
||
if (this.IsParameterBound(c => c.Name)) | ||
{ | ||
WriteObject(new PSSparkJobDefinitionResource(SynapseAnalyticsClient.GetSparkJobDefinition(this.Name))); | ||
} | ||
else | ||
{ | ||
var pipeline = SynapseAnalyticsClient.GetSparkJobDefinitionsByWorkspace() | ||
.Select(element => new PSSparkJobDefinitionResource(element)); | ||
WriteObject(pipeline, true); | ||
} | ||
} | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
...ds/DataPlaneCommands/Artifact/SparkJobDefinitions/RemoveAzureSynapseSparkJobDefinition.cs
This file contains hidden or 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,81 @@ | ||
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; | ||
using Microsoft.Azure.Commands.Synapse.Common; | ||
using Microsoft.Azure.Commands.Synapse.Models; | ||
using Microsoft.Azure.Commands.Synapse.Properties; | ||
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models; | ||
using Microsoft.WindowsAzure.Commands.Utilities.Common; | ||
using System.Management.Automation; | ||
|
||
namespace Microsoft.Azure.Commands.Synapse | ||
{ | ||
[Cmdlet(VerbsCommon.Remove, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + SynapseConstants.SynapsePrefix + SynapseConstants.SparkJobDefinition, | ||
DefaultParameterSetName = RemoveByName, SupportsShouldProcess = true)] | ||
[OutputType(typeof(bool))] | ||
public class RemoveAzureSynapseSparkJobDefinition : SynapseArtifactsCmdletBase | ||
{ | ||
private const string RemoveByName = "RemoveByName"; | ||
private const string RemoveByObject = "RemoveByObject"; | ||
private const string RemoveByInputObject = "RemoveByInputObject"; | ||
|
||
[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = RemoveByName, | ||
Mandatory = true, HelpMessage = HelpMessages.WorkspaceName)] | ||
[ResourceNameCompleter(ResourceTypes.Workspace, "ResourceGroupName")] | ||
[ValidateNotNullOrEmpty] | ||
public override string WorkspaceName { get; set; } | ||
|
||
[Parameter(ValueFromPipeline = true, ParameterSetName = RemoveByObject, | ||
Mandatory = true, HelpMessage = HelpMessages.WorkspaceObject)] | ||
[ValidateNotNull] | ||
public PSSynapseWorkspace WorkspaceObject { get; set; } | ||
|
||
[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = RemoveByName, Mandatory = true, HelpMessage = HelpMessages.SparkJobDefinitionName)] | ||
[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = RemoveByObject, Mandatory = true, HelpMessage = HelpMessages.SparkJobDefinitionName)] | ||
[ValidateNotNullOrEmpty] | ||
[Alias("SparkJobDefinitionName")] | ||
public string Name { get; set; } | ||
|
||
[Parameter(ValueFromPipeline = true, ParameterSetName = RemoveByInputObject, | ||
Mandatory = true, HelpMessage = HelpMessages.SparkJobDefinitionObject)] | ||
[ValidateNotNull] | ||
public PSSparkJobDefinitionResource InputObject { get; set; } | ||
|
||
[Parameter(Mandatory = false, HelpMessage = HelpMessages.PassThru)] | ||
public SwitchParameter PassThru { get; set; } | ||
|
||
[Parameter(Mandatory = false, HelpMessage = HelpMessages.AsJob)] | ||
public SwitchParameter AsJob { get; set; } | ||
|
||
[Parameter(Mandatory = false, HelpMessage = HelpMessages.Force)] | ||
public SwitchParameter Force { get; set; } | ||
|
||
public override void ExecuteCmdlet() | ||
{ | ||
if (this.IsParameterBound(c => c.WorkspaceObject)) | ||
{ | ||
this.WorkspaceName = this.WorkspaceObject.Name; | ||
} | ||
|
||
if (this.IsParameterBound(c => c.InputObject)) | ||
{ | ||
var resourceIdentifier = new ResourceIdentifier(this.InputObject.Id); | ||
this.WorkspaceName = resourceIdentifier.ParentResource; | ||
this.WorkspaceName = this.WorkspaceName.Substring(this.WorkspaceName.LastIndexOf('/') + 1); | ||
this.Name = resourceIdentifier.ResourceName; | ||
} | ||
|
||
ConfirmAction( | ||
Force.IsPresent, | ||
string.Format(Resources.RemoveSynapseSparkJobDefinition, Name), | ||
string.Format(Resources.RemovingSynapseSparkJobDefinition, this.Name, this.WorkspaceName), | ||
Name, | ||
() => | ||
{ | ||
SynapseAnalyticsClient.DeleteSparkJobDefinition(this.Name); | ||
if (PassThru) | ||
{ | ||
WriteObject(true); | ||
} | ||
}); | ||
} | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...mands/DataPlaneCommands/Artifact/SparkJobDefinitions/SetAzureSynapseSparkJobDefinition.cs
This file contains hidden or 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,60 @@ | ||
using Microsoft.Azure.Commands.Common.Exceptions; | ||
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; | ||
using Microsoft.Azure.Commands.Synapse.Common; | ||
using Microsoft.Azure.Commands.Synapse.Models; | ||
using Microsoft.Azure.Commands.Synapse.Properties; | ||
using Microsoft.WindowsAzure.Commands.Utilities.Common; | ||
using System; | ||
using System.Management.Automation; | ||
|
||
namespace Microsoft.Azure.Commands.Synapse | ||
{ | ||
[Cmdlet(VerbsCommon.Set, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + SynapseConstants.SynapsePrefix + SynapseConstants.SparkJobDefinition, | ||
DefaultParameterSetName = SetByName, SupportsShouldProcess = true)] | ||
[Alias("New-" + ResourceManager.Common.AzureRMConstants.AzureRMPrefix + SynapseConstants.SynapsePrefix + SynapseConstants.SparkJobDefinition)] | ||
[OutputType(typeof(PSSparkJobDefinitionResource))] | ||
public class SetAzureSynapseSparkJobDefinition : SynapseArtifactsCmdletBase | ||
{ | ||
private const string SetByName = "SetByName"; | ||
private const string SetByObject = "SetByObject"; | ||
|
||
[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = SetByName, | ||
Mandatory = true, HelpMessage = HelpMessages.WorkspaceName)] | ||
[ResourceNameCompleter(ResourceTypes.Workspace, "ResourceGroupName")] | ||
[ValidateNotNullOrEmpty] | ||
public override string WorkspaceName { get; set; } | ||
|
||
[Parameter(ValueFromPipeline = true, ParameterSetName = SetByObject, | ||
Mandatory = true, HelpMessage = HelpMessages.WorkspaceObject)] | ||
[ValidateNotNull] | ||
public PSSynapseWorkspace WorkspaceObject { get; set; } | ||
|
||
[Parameter(ValueFromPipelineByPropertyName = false, Mandatory = true, HelpMessage = HelpMessages.SparkJobDefinitionName)] | ||
[ValidateNotNullOrEmpty] | ||
[Alias("SparkJobDefinitionName")] | ||
public string Name { get; set; } | ||
|
||
[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = SetByObject, Mandatory = true, HelpMessage = HelpMessages.JsonFilePath)] | ||
[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = SetByName, Mandatory = true, HelpMessage = HelpMessages.JsonFilePath)] | ||
[ValidateNotNullOrEmpty] | ||
[Alias("File")] | ||
public string DefinitionFile { get; set; } | ||
|
||
[Parameter(Mandatory = false, HelpMessage = HelpMessages.AsJob)] | ||
public SwitchParameter AsJob { get; set; } | ||
|
||
public override void ExecuteCmdlet() | ||
{ | ||
if (this.IsParameterBound(c => c.WorkspaceObject)) | ||
{ | ||
this.WorkspaceName = this.WorkspaceObject.Name; | ||
} | ||
|
||
if (this.ShouldProcess(this.WorkspaceName, String.Format(Resources.SettingSynapseSparkJobDefinition, this.Name, this.WorkspaceName))) | ||
{ | ||
string rawJsonContent = SynapseAnalyticsClient.ReadJsonFileContent(this.TryResolvePath(DefinitionFile)); | ||
WriteObject(new PSSparkJobDefinitionResource(SynapseAnalyticsClient.CreateOrUpdateSparkJobDefinition(this.Name, rawJsonContent))); | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or 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
This file contains hidden or 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,30 @@ | ||
using Azure.Analytics.Synapse.Artifacts.Models; | ||
|
||
namespace Microsoft.Azure.Commands.Synapse.Models | ||
{ | ||
public class PSSparkJobDefinition | ||
{ | ||
public PSSparkJobDefinition(SparkJobDefinition properties) | ||
{ | ||
Description = properties?.Description; | ||
TargetBigDataPool = properties?.TargetBigDataPool != null ? new PSBigDataPoolReference(properties.TargetBigDataPool) : null; | ||
RequiredSparkVersion = properties?.RequiredSparkVersion; | ||
JobProperties = properties?.JobProperties != null ? new PSSparkJobProperties(properties.JobProperties) : null; | ||
} | ||
|
||
/// <summary> The description of the Spark job definition. </summary> | ||
public string Description { get; set; } | ||
|
||
/// <summary> Big data pool reference. </summary> | ||
public PSBigDataPoolReference TargetBigDataPool { get; set; } | ||
|
||
/// <summary> The required Spark version of the application. </summary> | ||
public string RequiredSparkVersion { get; set; } | ||
|
||
/// <summary> The language of the Spark application. </summary> | ||
public string Language { get; set; } | ||
|
||
/// <summary> The properties of the Spark job. </summary> | ||
public PSSparkJobProperties JobProperties { get; set; } | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Synapse/Synapse/Models/PSSparkJobDefinitionResource.cs
This file contains hidden or 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,16 @@ | ||
using Azure.Analytics.Synapse.Artifacts.Models; | ||
|
||
namespace Microsoft.Azure.Commands.Synapse.Models | ||
{ | ||
public class PSSparkJobDefinitionResource : PSSubResource | ||
{ | ||
public PSSparkJobDefinitionResource(SparkJobDefinitionResource sparkJobDefinition) | ||
: base(sparkJobDefinition.Id, sparkJobDefinition.Name, sparkJobDefinition.Type, sparkJobDefinition.Etag) | ||
{ | ||
Properties = sparkJobDefinition?.Properties != null ? new PSSparkJobDefinition(sparkJobDefinition.Properties) : null; | ||
} | ||
|
||
/// <summary> Properties of spark job definition. </summary> | ||
public PSSparkJobDefinition Properties { get; set; } | ||
} | ||
} |
This file contains hidden or 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,63 @@ | ||
using Azure.Analytics.Synapse.Artifacts.Models; | ||
using System.Collections.Generic; | ||
|
||
namespace Microsoft.Azure.Commands.Synapse.Models | ||
{ | ||
public class PSSparkJobProperties | ||
{ | ||
public PSSparkJobProperties(SparkJobProperties sparkJobProperties) | ||
{ | ||
this.Name = sparkJobProperties.Name; | ||
this.File = sparkJobProperties.File; | ||
this.ClassName = sparkJobProperties.ClassName; | ||
this.Configuration = sparkJobProperties.Conf; | ||
this.Arguments = sparkJobProperties.Args; | ||
this.Jars = sparkJobProperties.Files; | ||
this.Archives = sparkJobProperties.Archives; | ||
this.DriverMemory = sparkJobProperties.DriverMemory; | ||
this.DriverCores = sparkJobProperties.DriverCores; | ||
this.ExecutorMemory = sparkJobProperties.ExecutorMemory; | ||
this.ExecutorCores = sparkJobProperties.ExecutorCores; | ||
this.NumberOfExecutors = sparkJobProperties.NumExecutors; | ||
} | ||
|
||
/// <summary> The name of the job. </summary> | ||
public string Name { get; set; } | ||
|
||
/// <summary> File containing the application to execute. </summary> | ||
public string File { get; set; } | ||
|
||
/// <summary> Main class for Java/Scala application. </summary> | ||
public string ClassName { get; set; } | ||
|
||
/// <summary> Spark configuration properties. </summary> | ||
public object Configuration { get; set; } | ||
|
||
/// <summary> Command line arguments for the application. </summary> | ||
public IList<string> Arguments { get; } | ||
|
||
/// <summary> Jars to be used in this job. </summary> | ||
public IList<string> Jars { get; } | ||
|
||
/// <summary> files to be used in this job. </summary> | ||
public IList<string> Files { get; } | ||
|
||
/// <summary> Archives to be used in this job. </summary> | ||
public IList<string> Archives { get; } | ||
|
||
/// <summary> Amount of memory to use for the driver process. </summary> | ||
public string DriverMemory { get; set; } | ||
|
||
/// <summary> Number of cores to use for the driver. </summary> | ||
public int DriverCores { get; set; } | ||
|
||
/// <summary> Amount of memory to use per executor process. </summary> | ||
public string ExecutorMemory { get; set; } | ||
|
||
/// <summary> Number of cores to use for each executor. </summary> | ||
public int ExecutorCores { get; set; } | ||
|
||
/// <summary> Number of executors to launch for this job. </summary> | ||
public int NumberOfExecutors { get; set; } | ||
} | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.