Skip to content

Commit a745e49

Browse files
Added PackageAction Set for Update-AzSynapseSparkPool to support removing and adding packages in one action (#21579)
* Added AzureSynapseSparkPool PackageAction Set to allow removing and update of a package in one action * updated Synapse/ChangeLog.md * updated help file Update-AzSynapseSparkPool.md * added PackageAction Set example to help file for Update-AzSynapseSparkPool command --------- Co-authored-by: Morris Emming <[email protected]>
1 parent 3966a39 commit a745e49

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

src/Synapse/Synapse/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
## Upcoming Release
2222
* Updated Azure.Core to 1.31.0.
23+
* Added PackageAction `Set` for `Update-AzSynapseSparkPool` to support removing and adding packages in one action
2324

2425
## Version 2.3.0
2526
* Upgraded Azure.Analytics.Synapse.Artifacts to 1.0.0-preview.17

src/Synapse/Synapse/Commands/ManagementCommands/SparkPool/UpdateAzureSynapseSparkPool.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@ public override void ExecuteCmdlet()
267267

268268
if (this.IsParameterBound(c => c.PackageAction) && this.IsParameterBound(c => c.Package))
269269
{
270-
if (this.PackageAction == SynapseConstants.PackageActionType.Add)
270+
if (this.PackageAction == SynapseConstants.PackageActionType.Add || this.PackageAction == SynapseConstants.PackageActionType.Set)
271271
{
272-
if (existingSparkPool.CustomLibraries == null)
272+
if (existingSparkPool.CustomLibraries == null || this.PackageAction == SynapseConstants.PackageActionType.Set)
273273
{
274274
existingSparkPool.CustomLibraries = new List<LibraryInfo>();
275275
}

src/Synapse/Synapse/Models/SynapseConstants.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,8 @@ public class RepositoryType
332332
public enum PackageActionType
333333
{
334334
Add,
335-
Remove
335+
Remove,
336+
Set
336337
}
337338
public enum UserAssignedManagedIdentityActionType
338339
{

src/Synapse/Synapse/help/Update-AzSynapseSparkPool.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,28 +169,42 @@ The first command retrieves an Apache Spark pool in Azure Synapse Analytics. The
169169

170170
### Example 14
171171
```powershell
172+
$workspace_packages = Get-AzSynapseWorkspacePackage -WorkspaceName ContosoWorkspace
173+
174+
$pool = Get-AzSynapseSparkPool -ResourceGroupName ContosoResourceGroup -WorkspaceName ContosoWorkspace -Name ContosoSparkPool
175+
$library_names = $pool.WorkspacePackages | Where-Object {$_.name -notlike "new_package-*"} | ForEach-Object {$_.name}
176+
$library_names += "new_package-2.0-py3-none-any.whl"
177+
178+
$new_pool_packages = @($workspace_packages | Where-Object {$_.name -in $library_names})
179+
Update-AzSynapseSparkPool -ResourceGroupName ContosoResourceGroup -WorkspaceName ContosoWorkspace -Name ContosoSparkPool -PackageAction Set -Package $new_pool_packages
180+
```
181+
182+
The first command retrieves the packages available in the workspace. The second command group retrieves the spark pool to get the packages currently linked to this pool and removes all versions of the package starting with `new_package-` from the retrieved list. The new version of the package is then added to this list. In the third group of commands the package list, containing only package names, is tranformed into a list of workspace packages by filtering the list of available workspace_packages accordingly and is then linked to the spark pool.
183+
184+
### Example 15
185+
```powershell
172186
$config = Get-AzSynapseSparkConfiguration -WorkspaceName ContosoWorkspace -Name ContosoSparkConfig1
173187
Update-AzSynapseSparkPool -WorkspaceName ContosoWorkspace -Name ContosoSparkPool -Tag @{"key" = "value"} -NodeCount 5 -NodeSize Medium -SparkConfiguration $configs
174188
```
175189

176190
This command updates an Apache Spark pool in Azure Synapse Analytics and specify a Spark configuration for the Spark pool.
177191

178-
### Example 15
192+
### Example 16
179193
```powershell
180194
Update-AzSynapseSparkPool -WorkspaceName ContosoWorkspace -Name ContosoSparkPool -NodeSize small -ForceApplySetting
181195
```
182196

183197
This command updates an Apache Spark pool in Azure Synapse Analytics, set NodeSize to small for the spark pool and force stop any running jobs in the Spark pool to apply this new setting.
184198

185-
### Example 16
199+
### Example 17
186200
```powershell
187201
$pool = Get-AzSynapseSparkPool -ResourceGroupName ContosoResourceGroup -WorkspaceName ContosoWorkspace -Name ContosoSparkPool
188202
$pool | Update-AzSynapseSparkPool -PackageAction Remove -Package $pool.WorkspacePackages -ForceApplySetting
189203
```
190204

191205
The first command retrieves an Apache Spark pool in Azure Synapse Analytics. The second command removes all workspace packages that are linked to that Apache Spark pool and force stop any running jobs in the Spark pool to apply this new setting.
192206

193-
### Example 17
207+
### Example 18
194208
```powershell
195209
Update-AzSynapseSparkPool -WorkspaceName ContosoWorkspace -Name ContosoSparkPool -EnableIsolatedCompute $true -NodeSize XXXLarge
196210
```
@@ -480,7 +494,7 @@ Package action must be specified when you add or remove a workspace package from
480494
Type: Microsoft.Azure.Commands.Synapse.Models.SynapseConstants+PackageActionType
481495
Parameter Sets: (All)
482496
Aliases:
483-
Accepted values: Add, Remove
497+
Accepted values: Add, Remove, Set
484498

485499
Required: False
486500
Position: Named

0 commit comments

Comments
 (0)