Skip to content

Commit

Permalink
Add ETag Validation for Update-AzDataTableEntity and `Remove-AzData…
Browse files Browse the repository at this point in the history
…TableEntity` (#61)
  • Loading branch information
PalmEmanuel authored Mar 21, 2024
2 parents d0ddd0b + bf10475 commit 1244cb7
Show file tree
Hide file tree
Showing 9 changed files with 374 additions and 219 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ The format is based on and uses the types of changes according to [Keep a Change

## [Unreleased]

### Added

- ETag validation for Update- & Remove-AzDataTableEntity ([#58](https://github.com/PalmEmanuel/AzBobbyTables/issues/58))

### Fixed

- Missing examples of Remove-AzDataTableEntity

## [3.1.3] - 2024-01-20

### Added
Expand Down
239 changes: 136 additions & 103 deletions docs/help/Remove-AzDataTableEntity.md
Original file line number Diff line number Diff line change
@@ -1,103 +1,136 @@
---
external help file: AzBobbyTables.PS.dll-Help.xml
Module Name: AzBobbyTables
online version:
schema: 2.0.0
---

# Remove-AzDataTableEntity

## SYNOPSIS

Remove one or more entities from an Azure Table.

## SYNTAX

```
Remove-AzDataTableEntity -Context <AzDataTableContext> -Entity <Object[]>
[<CommonParameters>]
```

## DESCRIPTION

Remove one or more entities from an Azure Table, as an array of either Hashtables or PSObjects, based on PartitionKey and RowKey.

## EXAMPLES

### Example 1

```powershell
PS C:\> $Entity = @{ PartitionKey = 'Example'; RowKey = '1' }
PS C:\> Remove-AzDataTableEntity -Entity $Entity -TableName $TableName -StorageAccountName $Name -StorageAccountKey $Key
```

Remove the entity with PartitionKey "Example" and RowKey "1", using the storage account name and an access key.

### Example 2

```powershell
PS C:\> $UserEntity = Get-AzDataTableEntity -Filter "FirstName eq 'Bobby' and LastName eq 'Tables'" -TableName $TableName -ConnectionString $ConnectionString
PS C:\> Remove-AzDataTableEntity -Entity $UserEntity -TableName $TableName -StorageAccountName $Name -StorageAccountKey $Key
```

Get the user "Bobby Tables" from the table using a connection string, then remove the user using the storage account name and an access key.

### Example 3

```powershell
PS C:\> $Users = Get-AzDataTableEntity -Filter "LastName eq 'Tables'" -TableName $TableName -ConnectionString $ConnectionString
PS C:\> Remove-AzDataTableEntity -Entity $Users -TableName $TableName -StorageAccountName $Name -StorageAccountKey $Key
```

Gets all users with the last name "Tables" from the table using a connection string, then removes the users using the storage account name and an access key.

## PARAMETERS

### -Context

A context object created by New-AzDataTableContext, with authentication information for the table to operate on.

```yaml
Type: AzDataTableContext
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Entity
The entities to remove from the table.
```yaml
Type: Object[]
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
### System.Collections.Hashtable[] or System.Management.Automation.PSObject[]
This cmdlet takes either an array of hashtables or psobjects as input to the Entity parameter, which can also be provided through the pipeline.
## OUTPUTS
### None
## NOTES
## RELATED LINKS
---
external help file: AzBobbyTables.PS.dll-Help.xml
Module Name: AzBobbyTables
online version:
schema: 2.0.0
---

# Remove-AzDataTableEntity

## SYNOPSIS

Remove one or more entities from an Azure Table.

## SYNTAX

```
Remove-AzDataTableEntity -Context <AzDataTableContext> -Entity <Object[]> [-Force]
[<CommonParameters>]
```

## DESCRIPTION

Remove one or more entities from an Azure Table, as an array of either Hashtables or PSObjects, based on PartitionKey and RowKey.

## EXAMPLES

### Example 1

```powershell
PS C:\> $Context = New-AzDataTableContext -TableName $TableName -StorageAccountName $Name -StorageAccountKey $Key
PS C:\> $Entity = @{ PartitionKey = 'Example'; RowKey = '1' }
PS C:\> Remove-AzDataTableEntity -Entity $Entity -TableName $TableName -Context $Context
```

Remove the entity with PartitionKey "Example" and RowKey "1", using the storage account name and an access key.

### Example 2

```powershell
PS C:\> $Context = New-AzDataTableContext -TableName $TableName -ConnectionString $ConnectionString
PS C:\> $UserEntity = Get-AzDataTableEntity -Filter "FirstName eq 'Bobby' and LastName eq 'Tables'" -Context $Context
PS C:\> Remove-AzDataTableEntity -Entity $UserEntity -Context $Context
```

Get the user "Bobby Tables" from the table using a connection string, then remove the user using the storage account name and an access key.

### Example 3

```powershell
PS C:\> $Context = New-AzDataTableContext -StorageAccountName $StorageName -TableName $TableName -ManagedIdentity
PS C:\> $Users = Get-AzDataTableEntity -Filter "LastName eq 'Tables'" -Context $Context
PS C:\> Remove-AzDataTableEntity -Entity $Users -Context $Context
```

Gets all users with the last name "Tables" from the table using a system-assigned managed identity, then removes the users.

### Example 4

```powershell
PS C:\> $Context = New-AzDataTableContext -TableName $TableName -ConnectionString $ConnectionString
PS C:\> $Users = Get-AzDataTableEntity -Filter "LastName eq 'Tables'" -Context $Context
PS C:\> # Imagine that the users are updated somewhere else
PS C:\> Remove-AzDataTableEntity -Entity $Users -Context $Context
PS C:\> # ERROR - The ETag of Users do not match
PS C:\> Remove-AzDataTableEntity -Entity $Users -Context $Context -Force
PS C:\> # OK - The -Force switch overrides ETag validation
```

Force remove all users with the last name Tables, overriding ETag validation.

## PARAMETERS

### -Context

A context object created by New-AzDataTableContext, with authentication information for the table to operate on.

```yaml
Type: AzDataTableContext
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Entity
The entities to remove from the table.
```yaml
Type: Object[]
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -Force
Skips ETag validation and remove entity even if it has changed.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

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, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
### System.Collections.Hashtable[] or System.Management.Automation.PSObject[]
This cmdlet takes either an array of hashtables or psobjects as input to the Entity parameter, which can also be provided through the pipeline.
## OUTPUTS
### None
## NOTES
## RELATED LINKS
Loading

0 comments on commit 1244cb7

Please sign in to comment.