Azure / Azure/azure-powershell

Set Blob Metadata API call doesn't restrict users to define null as value for metadata however Set-AzStorageBlobContent imposing restrictions

Open
#22,506 4 comments 0 reactions 1 assignee Claimed by @blueww View on GitHub
act-codegen-extensibility-squad bug customer-reported Service Attention Storage
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
3d 14h
Merged PRs (30d)
54

Description

### Description

[Set Blob Metadata](https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Frest%2Fapi%2Fstorageservices%2Fset-blob-metadata%3Ftabs%3Dazure-ad&data=05%7C01%7CGanesh.Maddipudi%40microsoft.com%7C86d81e767a424dfd694708db94a97590%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638267227812486520%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=TQIFWswg1esgM8PA2BO13w9KNKnjxEqwWAIElkSQcSo%3D&reserved=0) API doesn't restrict users to define **null** as value for metadata. However, PS cmdlet **Set-AzStorageBlobContent** have validations in place so that users won't set null value. I see this behavior inconsistency in direct API calls vs PS. Can you please fix this?

### Issue script & Debug output

```PowerShell
$Metadata = @{
"Description" = ""
}

Start-Transcript
$DebugPreference = 'continue'
# Upload the blob with metadata
Set-AzStorageBlobContent -Context $Context -Container $ContainerName -Blob $BlobName -File $LocalFilePath -Metadata $Metadata
Stop-Transcript
```

### Environment data

```PowerShell
$PSVersionTable

Name Value
---- -----
PSVersion 5.1.23516.1000
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.23516.1000
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
```

### Module versions

```PowerShell
Get-Module Az*

ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 2.12.1 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault...}
Script 5.4.1 Az.Storage {Add-AzRmStorageContainerLegalHold, Add-AzStorageAccountManagementPolicyAction, Add-AzStorageAccountNetworkR...
```

### Error output

```PowerShell
Set-AzStorageBlobContent : The argument must not be empty string.
At line:4 char:1
+ Set-AzStorageBlobContent -Context $Context -Container $ContainerName ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Set-AzStorageBlobContent], StorageException
+ FullyQualifiedErrorId : StorageException,Microsoft.WindowsAzure.Commands.Storage.Blob.SetAzureBlobContentCommand
Set-AzStorageBlobContent : The argument must not be empty string.
```

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.