Powershell 命令 Set-AzureStorageBlobContent 忽略标志

Powershell command Set-AzureStorageBlobContent ignore flag

我想将新的 blob 上传到 Azure 存储帐户,但只有其中一个不存在。我想知道是否有任何方法可以设置 Set-AzureStorageBlobContent 命令以忽略已经存在的项目,这样我就可以在一次操作中实现它?

I want to upload new blob to Azure storage account, but only of it doesn't already exist.

Set-AzureStorageBlobContent, it seems that there are not existing parameters that could be used to skip/ignore the existing blob while uploading the file to blob. As a workaround, we could use Get-AzureStorageBlob cmdlet 的文档中检查 blob 在 运行 Set-AzureStorageBlobContent cmdlet 将文件上传到 blob 之前是否已经存在。

try
{   
     $blob = Get-AzureStorageBlob -Blob $blobName -Container $containerName -Context $blobContext -ErrorAction Stop

     Write-Host "Blob is existing"
}
catch 
{
    # The blob doesn't exist
    # Add logic here 

    Write-Host "Blob Not Found"

    Write-Host "Start Upload Blob"

    Set-AzureStorageBlobContent -File $filename -Container $containerName -Blob $blobName -Context $blobContext 
}