Azure / Azure/azure-powershell

[Az.ServiceFabric] Update-AzServiceFabricDurability fails when existing durability value is lowercase

Open
#30,014 2 comments 1 reaction 2 assignees Claimed by @a0x1ab View on GitHub
act-observability-squad bug Service Fabric
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
2d 17h
Merged PRs (30d)
51

Description

### Description

`Update-AzServiceFabricDurability` fails when the existing Service Fabric cluster node type stores `durabilityLevel` with lowercase casing, for example `"silver"`.

A customer reproduced this in Azure Cloud Shell on 2026-08-13. Every requested value fails with the same error, including `Silver`, `Bronze`, and arbitrary tests. `-WhatIf` also fails:

```powershell
Update-AzServiceFabricDurability `
-ResourceGroupName "" `
-Name "" `
-NodeType "" `
-DurabilityLevel Silver `
-WhatIf
```

Actual result:

```text
Update-AzServiceFabricDurability: Requested value 'silver' was not found.
```

The error reports the existing lowercase value, not the requested value.

Expected behavior: the cmdlet should parse recognized durability values without regard to casing, or return an actionable validation error identifying the malformed existing resource property. `-WhatIf` should be able to evaluate the requested operation.

This blocks the supported procedure for aligning durability in the Service Fabric cluster node type and its corresponding VMSS Service Fabric extension.

### Root cause in current source

The cmdlet parses the current cluster node type before reaching `ShouldProcess`:

- https://github.com/Azure/azure-powershell/blob/main/src/ServiceFabric/ServiceFabric/Commands/UpdateAzureRmServiceFabricDurability.cs#L81-L83
- https://github.com/Azure/azure-powershell/blob/main/src/ServiceFabric/ServiceFabric/Commands/UpdateAzureRmServiceFabricDurability.cs#L121

The shared helper uses the case-sensitive `Enum.Parse(Type, String)` overload:

- https://github.com/Azure/azure-powershell/blob/main/src/ServiceFabric/ServiceFabric/Commands/ServiceFabricClusterCmdlet.cs#L130-L133

The enum members are title-cased `Bronze`, `Silver`, and `Gold`:

- https://github.com/Azure/azure-powershell/blob/main/src/ServiceFabric/ServiceFabric/Models/DurabilityLevel.cs#L18-L22

Consequently, an existing value of `"silver"` throws before the requested value or `ShouldProcess` can be evaluated.

### Suggested fix

Parse case-insensitively and add coverage for lowercase values from both the cluster resource and VMSS extension:

```csharp
return (DurabilityLevel)Enum.Parse(
typeof(DurabilityLevel),
durabilityLevel,
ignoreCase: true);
```

A `TryParse(..., ignoreCase: true, ...)` implementation with an actionable error for unknown values would be preferable.

There is another direct case-sensitive parse in `UpdateAzureRmServiceFabricNodeBase.cs` that should be reviewed:

https://github.com/Azure/azure-powershell/blob/main/src/ServiceFabric/ServiceFabric/Commands/UpdateAzureRmServiceFabricNodeBase.cs#L65

### Environment data

Azure Cloud Shell, reproduced 2026-08-13. Exact `$PSVersionTable` output was not captured in the incident report.

### Module versions

Exact Cloud Shell module versions were not captured. The defect remains present in the `main` branch as of 2026-08-14.

### Error output

```text
Update-AzServiceFabricDurability: Requested value 'silver' was not found.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.