Skip to content

Commit

Permalink
[Synapse] - Support ShouldProcess for 3 cmdlets (#12670)
Browse files Browse the repository at this point in the history
  • Loading branch information
idear1203 authored Aug 15, 2020
1 parent 6638449 commit a75f4c2
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Microsoft.Azure.Commands.Synapse
{
[Cmdlet(VerbsLifecycle.Submit, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + SynapseConstants.SynapsePrefix + SynapseConstants.SparkJob, DefaultParameterSetName = RunSparkJobParameterSetName)]
[Cmdlet(VerbsLifecycle.Submit, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + SynapseConstants.SynapsePrefix + SynapseConstants.SparkJob, DefaultParameterSetName = RunSparkJobParameterSetName, SupportsShouldProcess = true)]
[OutputType(typeof(PSSynapseSparkJob))]
public class SubmitAzureSynapseSparkJob : SynapseSparkCmdletBase
{
Expand Down Expand Up @@ -184,8 +184,11 @@ public override void ExecuteCmdlet()
batchRequest.Configuration[SynapseConstants.SparkDotNetAssemblySearchPathsKey] = string.Join(",", paths);
}

var jobInformation = SynapseAnalyticsClient.SubmitSparkBatchJob(batchRequest, waitForCompletion:false);
WriteObject(new PSSynapseSparkJob(jobInformation));
if (this.ShouldProcess(this.SparkPoolName, string.Format(Resources.SubmittingSynapseSparkJob, this.SparkPoolName, this.WorkspaceName)))
{
var jobInformation = SynapseAnalyticsClient.SubmitSparkBatchJob(batchRequest, waitForCompletion: false);
WriteObject(new PSSynapseSparkJob(jobInformation));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
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.Azure.Management.Synapse.Models;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
Expand All @@ -12,7 +13,7 @@

namespace Microsoft.Azure.Commands.Synapse
{
[Cmdlet(VerbsLifecycle.Start, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + SynapseConstants.SynapsePrefix + SynapseConstants.SparkSession, DefaultParameterSetName = CreateByNameParameterSet)]
[Cmdlet(VerbsLifecycle.Start, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + SynapseConstants.SynapsePrefix + SynapseConstants.SparkSession, DefaultParameterSetName = CreateByNameParameterSet, SupportsShouldProcess = true)]
[OutputType(typeof(PSSynapseSparkSession))]
public class StartAzureSynapseSparkSession : SynapseSparkCmdletBase
{
Expand Down Expand Up @@ -101,20 +102,23 @@ public override void ExecuteCmdlet()
ExecutorCount = this.ExecutorCount
};

var sparkSession = SynapseAnalyticsClient.CreateSparkSession(livyRequest, waitForCompletion:true);

PSSynapseSparkSession psSparkSession = null;
if (this.IsParameterBound(c => c.Language))
{
this.Language = LanguageType.Parse(this.Language);
psSparkSession = new PSSynapseSparkSession(this.Language, sparkSession);
}
else
if (this.ShouldProcess(this.SparkPoolName, string.Format(Resources.StartingSynapseSparkSession, this.SparkPoolName, this.WorkspaceName)))
{
psSparkSession = new PSSynapseSparkSession(sparkSession);
}
var sparkSession = SynapseAnalyticsClient.CreateSparkSession(livyRequest, waitForCompletion: true);

PSSynapseSparkSession psSparkSession = null;
if (this.IsParameterBound(c => c.Language))
{
this.Language = LanguageType.Parse(this.Language);
psSparkSession = new PSSynapseSparkSession(this.Language, sparkSession);
}
else
{
psSparkSession = new PSSynapseSparkSession(sparkSession);
}

WriteObject(psSparkSession);
WriteObject(psSparkSession);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
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.Management.Automation;

namespace Microsoft.Azure.Commands.Synapse
{
[Cmdlet(VerbsLifecycle.Invoke, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + SynapseConstants.SynapsePrefix + SynapseConstants.SparkStatement, DefaultParameterSetName = RunSparkStatementByCodePathParameterSet)]
[Cmdlet(VerbsLifecycle.Invoke, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + SynapseConstants.SynapsePrefix + SynapseConstants.SparkStatement, DefaultParameterSetName = RunSparkStatementByCodePathParameterSet, SupportsShouldProcess = true)]
[OutputType(typeof(PSSynapseExtendedSparkStatement))]
public class InvokeAzureSynapseSparkStatement : SynapseSparkCmdletBase
{
Expand Down Expand Up @@ -105,9 +106,12 @@ public override void ExecuteCmdlet()
Code = this.Code
};

var sessionStmt = SynapseAnalyticsClient.SubmitSparkSessionStatement(this.SessionId, livyRequest, waitForCompletion:true);
var psSessionStmt = new PSSynapseExtendedSparkStatement(sessionStmt);
WriteObject(psSessionStmt);
if (this.ShouldProcess(this.SparkPoolName, string.Format(Resources.InvokingSparkStatement, this.SparkPoolName, this.WorkspaceName)))
{
var sessionStmt = SynapseAnalyticsClient.SubmitSparkSessionStatement(this.SessionId, livyRequest, waitForCompletion:true);
var psSessionStmt = new PSSynapseExtendedSparkStatement(sessionStmt);
WriteObject(psSessionStmt);
}
}
}
}
33 changes: 21 additions & 12 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.

15 changes: 9 additions & 6 deletions src/Synapse/Synapse/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,6 @@
<data name="FilePathDoesNotExist" xml:space="preserve">
<value>The file at path '{0}' does not exist or the current user does not have permission to it. Please ensure the path exists and is accessible.</value>
</data>
<data name="InteractiveSparkSessionTips" xml:space="preserve">
<value>InteractiveSparkSessionTips</value>
</data>
<data name="InvalidDefaultSubscription" xml:space="preserve">
<value>No default subscription has been designated. Use Select-AzSubscription -Default &lt;subscriptionName&gt; to set the default subscription.</value>
</data>
Expand Down Expand Up @@ -249,9 +246,6 @@
<data name="SqlPoolDoesNotExist" xml:space="preserve">
<value>Cannot perform the requested operation because the specified SQL pool '{0}' does not exist.</value>
</data>
<data name="StartSparkSessionNonInteractiveMessage" xml:space="preserve">
<value>{0} must be issued in interactive mode.</value>
</data>
<data name="StoppingSparkJob" xml:space="preserve">
<value>Stopping Spark job with Id: '{0}' ...</value>
</data>
Expand Down Expand Up @@ -327,4 +321,13 @@
<data name="UpdatingSynapseSqlDatabase" xml:space="preserve">
<value>Updating SQL Database '{0}' in resource group '{1}' under Workspace '{2}'.</value>
</data>
<data name="InvokingSparkStatement" xml:space="preserve">
<value>Invoking Spark statement in Spark pool '{0}' under workspace '{1}' ...</value>
</data>
<data name="StartingSynapseSparkSession" xml:space="preserve">
<value>Starting Spark session in Spark pool '{0}' under workspace '{1}' ...</value>
</data>
<data name="SubmittingSynapseSparkJob" xml:space="preserve">
<value>Submitting Spark job in Spark pool '{0}' under workspace '{1}' ...</value>
</data>
</root>
42 changes: 37 additions & 5 deletions src/Synapse/Synapse/help/Invoke-AzSynapseSparkStatement.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,28 @@ Invokes a Synapse Analytics Spark statement.
```
Invoke-AzSynapseSparkStatement -WorkspaceName <String> -SparkPoolName <String> -Language <String>
-SessionId <Int32> -FilePath <String> [-Response] [-AsJob] [-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
[-WhatIf] [-Confirm] [<CommonParameters>]
```

### RunSparkStatementByCodeParameterSet
```
Invoke-AzSynapseSparkStatement -WorkspaceName <String> -SparkPoolName <String> -Language <String>
-SessionId <Int32> -Code <String> [-Response] [-AsJob] [-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
-SessionId <Int32> -Code <String> [-Response] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

### RunSparkStatementByCodeAndInputObjectParameterSet
```
Invoke-AzSynapseSparkStatement -Language <String> -SessionObject <PSSynapseSparkSession> [-SessionId <Int32>]
-Code <String> [-Response] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
-Code <String> [-Response] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

### RunSparkStatementByCodePathAndInputObjectParameterSet
```
Invoke-AzSynapseSparkStatement -Language <String> -SessionObject <PSSynapseSparkSession> [-SessionId <Int32>]
-FilePath <String> [-Response] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
-FilePath <String> [-Response] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -250,6 +252,36 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
Expand Down
34 changes: 32 additions & 2 deletions src/Synapse/Synapse/help/Start-AzSynapseSparkSession.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ Starts a Synapse Analytics Spark session.
```
Start-AzSynapseSparkSession -WorkspaceName <String> -SparkPoolName <String> [-Language <String>] -Name <String>
[-ReferenceFile <String[]>] -ExecutorCount <Int32> -ExecutorSize <String> [-Configuration <Hashtable>]
[-AsJob] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
[-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### CreateByParentObjectParameterSet
```
Start-AzSynapseSparkSession -SparkPoolObject <PSSynapseSparkPool> [-Language <String>] -Name <String>
[-ReferenceFile <String[]>] -ExecutorCount <Int32> -ExecutorSize <String> [-Configuration <Hashtable>]
[-AsJob] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
[-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -215,6 +215,36 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
Expand Down
34 changes: 32 additions & 2 deletions src/Synapse/Synapse/help/Submit-AzSynapseSparkJob.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ Submits a Synapse Analytics Spark job.
Submit-AzSynapseSparkJob -WorkspaceName <String> -SparkPoolName <String> -Language <String> -Name <String>
-MainDefinitionFile <String> [-MainClassName <String>] [-CommandLineArgument <String[]>]
[-ReferenceFile <String[]>] -ExecutorCount <Int32> -ExecutorSize <String> [-Configuration <Hashtable>]
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### RunSparkJobByParentObjectParameterSet
```
Submit-AzSynapseSparkJob -SparkPoolObject <PSSynapseSparkPool> -Language <String> -Name <String>
-MainDefinitionFile <String> [-MainClassName <String>] [-CommandLineArgument <String[]>]
[-ReferenceFile <String[]>] -ExecutorCount <Int32> -ExecutorSize <String> [-Configuration <Hashtable>]
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -258,6 +258,36 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
Expand Down

This file was deleted.

0 comments on commit a75f4c2

Please sign in to comment.