Skip to content

Commit a75f4c2

Browse files
authored
[Synapse] - Support ShouldProcess for 3 cmdlets (#12670)
1 parent 6638449 commit a75f4c2

File tree

9 files changed

+162
-51
lines changed

9 files changed

+162
-51
lines changed

src/Synapse/Synapse/Commands/DataPlaneCommands/SparkJob/SubmitAzureSynapseSparkJob.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

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

187-
var jobInformation = SynapseAnalyticsClient.SubmitSparkBatchJob(batchRequest, waitForCompletion:false);
188-
WriteObject(new PSSynapseSparkJob(jobInformation));
187+
if (this.ShouldProcess(this.SparkPoolName, string.Format(Resources.SubmittingSynapseSparkJob, this.SparkPoolName, this.WorkspaceName)))
188+
{
189+
var jobInformation = SynapseAnalyticsClient.SubmitSparkBatchJob(batchRequest, waitForCompletion: false);
190+
WriteObject(new PSSynapseSparkJob(jobInformation));
191+
}
189192
}
190193
}
191194
}

src/Synapse/Synapse/Commands/DataPlaneCommands/SparkSession/StartAzureSynapseSparkSession.cs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
33
using Microsoft.Azure.Commands.Synapse.Common;
44
using Microsoft.Azure.Commands.Synapse.Models;
5+
using Microsoft.Azure.Commands.Synapse.Properties;
56
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
67
using Microsoft.Azure.Management.Synapse.Models;
78
using Microsoft.WindowsAzure.Commands.Utilities.Common;
@@ -12,7 +13,7 @@
1213

1314
namespace Microsoft.Azure.Commands.Synapse
1415
{
15-
[Cmdlet(VerbsLifecycle.Start, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + SynapseConstants.SynapsePrefix + SynapseConstants.SparkSession, DefaultParameterSetName = CreateByNameParameterSet)]
16+
[Cmdlet(VerbsLifecycle.Start, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + SynapseConstants.SynapsePrefix + SynapseConstants.SparkSession, DefaultParameterSetName = CreateByNameParameterSet, SupportsShouldProcess = true)]
1617
[OutputType(typeof(PSSynapseSparkSession))]
1718
public class StartAzureSynapseSparkSession : SynapseSparkCmdletBase
1819
{
@@ -101,20 +102,23 @@ public override void ExecuteCmdlet()
101102
ExecutorCount = this.ExecutorCount
102103
};
103104

104-
var sparkSession = SynapseAnalyticsClient.CreateSparkSession(livyRequest, waitForCompletion:true);
105-
106-
PSSynapseSparkSession psSparkSession = null;
107-
if (this.IsParameterBound(c => c.Language))
108-
{
109-
this.Language = LanguageType.Parse(this.Language);
110-
psSparkSession = new PSSynapseSparkSession(this.Language, sparkSession);
111-
}
112-
else
105+
if (this.ShouldProcess(this.SparkPoolName, string.Format(Resources.StartingSynapseSparkSession, this.SparkPoolName, this.WorkspaceName)))
113106
{
114-
psSparkSession = new PSSynapseSparkSession(sparkSession);
115-
}
107+
var sparkSession = SynapseAnalyticsClient.CreateSparkSession(livyRequest, waitForCompletion: true);
108+
109+
PSSynapseSparkSession psSparkSession = null;
110+
if (this.IsParameterBound(c => c.Language))
111+
{
112+
this.Language = LanguageType.Parse(this.Language);
113+
psSparkSession = new PSSynapseSparkSession(this.Language, sparkSession);
114+
}
115+
else
116+
{
117+
psSparkSession = new PSSynapseSparkSession(sparkSession);
118+
}
116119

117-
WriteObject(psSparkSession);
120+
WriteObject(psSparkSession);
121+
}
118122
}
119123
}
120124
}

src/Synapse/Synapse/Commands/DataPlaneCommands/SparkStatement/InvokeAzureSynapseSparkStatement.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
33
using Microsoft.Azure.Commands.Synapse.Common;
44
using Microsoft.Azure.Commands.Synapse.Models;
5+
using Microsoft.Azure.Commands.Synapse.Properties;
56
using Microsoft.WindowsAzure.Commands.Utilities.Common;
67
using System.Management.Automation;
78

89
namespace Microsoft.Azure.Commands.Synapse
910
{
10-
[Cmdlet(VerbsLifecycle.Invoke, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + SynapseConstants.SynapsePrefix + SynapseConstants.SparkStatement, DefaultParameterSetName = RunSparkStatementByCodePathParameterSet)]
11+
[Cmdlet(VerbsLifecycle.Invoke, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + SynapseConstants.SynapsePrefix + SynapseConstants.SparkStatement, DefaultParameterSetName = RunSparkStatementByCodePathParameterSet, SupportsShouldProcess = true)]
1112
[OutputType(typeof(PSSynapseExtendedSparkStatement))]
1213
public class InvokeAzureSynapseSparkStatement : SynapseSparkCmdletBase
1314
{
@@ -105,9 +106,12 @@ public override void ExecuteCmdlet()
105106
Code = this.Code
106107
};
107108

108-
var sessionStmt = SynapseAnalyticsClient.SubmitSparkSessionStatement(this.SessionId, livyRequest, waitForCompletion:true);
109-
var psSessionStmt = new PSSynapseExtendedSparkStatement(sessionStmt);
110-
WriteObject(psSessionStmt);
109+
if (this.ShouldProcess(this.SparkPoolName, string.Format(Resources.InvokingSparkStatement, this.SparkPoolName, this.WorkspaceName)))
110+
{
111+
var sessionStmt = SynapseAnalyticsClient.SubmitSparkSessionStatement(this.SessionId, livyRequest, waitForCompletion:true);
112+
var psSessionStmt = new PSSynapseExtendedSparkStatement(sessionStmt);
113+
WriteObject(psSessionStmt);
114+
}
111115
}
112116
}
113117
}

src/Synapse/Synapse/Properties/Resources.Designer.cs

Lines changed: 21 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Synapse/Synapse/Properties/Resources.resx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,6 @@
198198
<data name="FilePathDoesNotExist" xml:space="preserve">
199199
<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>
200200
</data>
201-
<data name="InteractiveSparkSessionTips" xml:space="preserve">
202-
<value>InteractiveSparkSessionTips</value>
203-
</data>
204201
<data name="InvalidDefaultSubscription" xml:space="preserve">
205202
<value>No default subscription has been designated. Use Select-AzSubscription -Default &lt;subscriptionName&gt; to set the default subscription.</value>
206203
</data>
@@ -249,9 +246,6 @@
249246
<data name="SqlPoolDoesNotExist" xml:space="preserve">
250247
<value>Cannot perform the requested operation because the specified SQL pool '{0}' does not exist.</value>
251248
</data>
252-
<data name="StartSparkSessionNonInteractiveMessage" xml:space="preserve">
253-
<value>{0} must be issued in interactive mode.</value>
254-
</data>
255249
<data name="StoppingSparkJob" xml:space="preserve">
256250
<value>Stopping Spark job with Id: '{0}' ...</value>
257251
</data>
@@ -327,4 +321,13 @@
327321
<data name="UpdatingSynapseSqlDatabase" xml:space="preserve">
328322
<value>Updating SQL Database '{0}' in resource group '{1}' under Workspace '{2}'.</value>
329323
</data>
324+
<data name="InvokingSparkStatement" xml:space="preserve">
325+
<value>Invoking Spark statement in Spark pool '{0}' under workspace '{1}' ...</value>
326+
</data>
327+
<data name="StartingSynapseSparkSession" xml:space="preserve">
328+
<value>Starting Spark session in Spark pool '{0}' under workspace '{1}' ...</value>
329+
</data>
330+
<data name="SubmittingSynapseSparkJob" xml:space="preserve">
331+
<value>Submitting Spark job in Spark pool '{0}' under workspace '{1}' ...</value>
332+
</data>
330333
</root>

src/Synapse/Synapse/help/Invoke-AzSynapseSparkStatement.md

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,28 @@ Invokes a Synapse Analytics Spark statement.
1616
```
1717
Invoke-AzSynapseSparkStatement -WorkspaceName <String> -SparkPoolName <String> -Language <String>
1818
-SessionId <Int32> -FilePath <String> [-Response] [-AsJob] [-DefaultProfile <IAzureContextContainer>]
19-
[<CommonParameters>]
19+
[-WhatIf] [-Confirm] [<CommonParameters>]
2020
```
2121

2222
### RunSparkStatementByCodeParameterSet
2323
```
2424
Invoke-AzSynapseSparkStatement -WorkspaceName <String> -SparkPoolName <String> -Language <String>
25-
-SessionId <Int32> -Code <String> [-Response] [-AsJob] [-DefaultProfile <IAzureContextContainer>]
26-
[<CommonParameters>]
25+
-SessionId <Int32> -Code <String> [-Response] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
26+
[-Confirm] [<CommonParameters>]
2727
```
2828

2929
### RunSparkStatementByCodeAndInputObjectParameterSet
3030
```
3131
Invoke-AzSynapseSparkStatement -Language <String> -SessionObject <PSSynapseSparkSession> [-SessionId <Int32>]
32-
-Code <String> [-Response] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
32+
-Code <String> [-Response] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
33+
[<CommonParameters>]
3334
```
3435

3536
### RunSparkStatementByCodePathAndInputObjectParameterSet
3637
```
3738
Invoke-AzSynapseSparkStatement -Language <String> -SessionObject <PSSynapseSparkSession> [-SessionId <Int32>]
38-
-FilePath <String> [-Response] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
39+
-FilePath <String> [-Response] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
40+
[<CommonParameters>]
3941
```
4042

4143
## DESCRIPTION
@@ -250,6 +252,36 @@ Accept pipeline input: False
250252
Accept wildcard characters: False
251253
```
252254
255+
### -Confirm
256+
Prompts you for confirmation before running the cmdlet.
257+
258+
```yaml
259+
Type: System.Management.Automation.SwitchParameter
260+
Parameter Sets: (All)
261+
Aliases: cf
262+
263+
Required: False
264+
Position: Named
265+
Default value: None
266+
Accept pipeline input: False
267+
Accept wildcard characters: False
268+
```
269+
270+
### -WhatIf
271+
Shows what would happen if the cmdlet runs. The cmdlet is not run.
272+
273+
```yaml
274+
Type: System.Management.Automation.SwitchParameter
275+
Parameter Sets: (All)
276+
Aliases: wi
277+
278+
Required: False
279+
Position: Named
280+
Default value: None
281+
Accept pipeline input: False
282+
Accept wildcard characters: False
283+
```
284+
253285
### CommonParameters
254286
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).
255287

src/Synapse/Synapse/help/Start-AzSynapseSparkSession.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ Starts a Synapse Analytics Spark session.
1616
```
1717
Start-AzSynapseSparkSession -WorkspaceName <String> -SparkPoolName <String> [-Language <String>] -Name <String>
1818
[-ReferenceFile <String[]>] -ExecutorCount <Int32> -ExecutorSize <String> [-Configuration <Hashtable>]
19-
[-AsJob] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
19+
[-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
2020
```
2121

2222
### CreateByParentObjectParameterSet
2323
```
2424
Start-AzSynapseSparkSession -SparkPoolObject <PSSynapseSparkPool> [-Language <String>] -Name <String>
2525
[-ReferenceFile <String[]>] -ExecutorCount <Int32> -ExecutorSize <String> [-Configuration <Hashtable>]
26-
[-AsJob] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
26+
[-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
2727
```
2828

2929
## DESCRIPTION
@@ -215,6 +215,36 @@ Accept pipeline input: False
215215
Accept wildcard characters: False
216216
```
217217
218+
### -Confirm
219+
Prompts you for confirmation before running the cmdlet.
220+
221+
```yaml
222+
Type: System.Management.Automation.SwitchParameter
223+
Parameter Sets: (All)
224+
Aliases: cf
225+
226+
Required: False
227+
Position: Named
228+
Default value: None
229+
Accept pipeline input: False
230+
Accept wildcard characters: False
231+
```
232+
233+
### -WhatIf
234+
Shows what would happen if the cmdlet runs. The cmdlet is not run.
235+
236+
```yaml
237+
Type: System.Management.Automation.SwitchParameter
238+
Parameter Sets: (All)
239+
Aliases: wi
240+
241+
Required: False
242+
Position: Named
243+
Default value: None
244+
Accept pipeline input: False
245+
Accept wildcard characters: False
246+
```
247+
218248
### CommonParameters
219249
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).
220250

src/Synapse/Synapse/help/Submit-AzSynapseSparkJob.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ Submits a Synapse Analytics Spark job.
1717
Submit-AzSynapseSparkJob -WorkspaceName <String> -SparkPoolName <String> -Language <String> -Name <String>
1818
-MainDefinitionFile <String> [-MainClassName <String>] [-CommandLineArgument <String[]>]
1919
[-ReferenceFile <String[]>] -ExecutorCount <Int32> -ExecutorSize <String> [-Configuration <Hashtable>]
20-
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
20+
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
2121
```
2222

2323
### RunSparkJobByParentObjectParameterSet
2424
```
2525
Submit-AzSynapseSparkJob -SparkPoolObject <PSSynapseSparkPool> -Language <String> -Name <String>
2626
-MainDefinitionFile <String> [-MainClassName <String>] [-CommandLineArgument <String[]>]
2727
[-ReferenceFile <String[]>] -ExecutorCount <Int32> -ExecutorSize <String> [-Configuration <Hashtable>]
28-
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
28+
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
2929
```
3030

3131
## DESCRIPTION
@@ -258,6 +258,36 @@ Accept pipeline input: False
258258
Accept wildcard characters: False
259259
```
260260
261+
### -Confirm
262+
Prompts you for confirmation before running the cmdlet.
263+
264+
```yaml
265+
Type: System.Management.Automation.SwitchParameter
266+
Parameter Sets: (All)
267+
Aliases: cf
268+
269+
Required: False
270+
Position: Named
271+
Default value: None
272+
Accept pipeline input: False
273+
Accept wildcard characters: False
274+
```
275+
276+
### -WhatIf
277+
Shows what would happen if the cmdlet runs. The cmdlet is not run.
278+
279+
```yaml
280+
Type: System.Management.Automation.SwitchParameter
281+
Parameter Sets: (All)
282+
Aliases: wi
283+
284+
Required: False
285+
Position: Named
286+
Default value: None
287+
Accept pipeline input: False
288+
Accept wildcard characters: False
289+
```
290+
261291
### CommonParameters
262292
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).
263293

tools/StaticAnalysis/Exceptions/Az.Synapse/SignatureIssues.csv

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)