【问题标题】:Azure release pipeline task. There is currently a lease on the blob and no lease ID was specified in the requestAzure 发布管道任务。 Blob 当前存在租约,请求中未指定租约 ID
【发布时间】:2022-01-19 09:20:27
【问题描述】:

我有一个 Azure 发布管道,其中一个步骤是将文件(比如说“xyz.txt”)作为 Blob 文件从工作目录复制到 Azure 存储容器。直到昨天,它工作正常并按预期工作。

steps:
- task: AzureFileCopy@3
  displayName: 'Copy file to BLOB'
  inputs:
    SourcePath: '$(System.DefaultWorkingDirectory)/FilePath'
    azureSubscription: 'ABCSubscription'
    Destination: AzureBlob
    storage: ABCstorage
    ContainerName: abcContainerName

现在我对文件(“xyz.txt”)进行了一些更改,每当我从发布管道创建发布时,我都会看到错误 "The remote server returned an error: (412) There is currently a lease on the blob and no lease ID was specified in the request..。这导致发布管道失败。解决办法是什么?

我是否必须登录门户并手动单击"Break lease"。有没有办法只通过管道来做到这一点("Break lease")?

【问题讨论】:

    标签: azure-devops azure-blob-storage azure-pipelines-release-pipeline


    【解决方案1】:

    您可以使用以下解决方法解除租约

    解决方案 1: 在 Azure Devops 中会如下所示:

    steps: 
    
      - task: AzureCLI@2 
    
        displayName: "Break lease on terraform state" 
    
        name: BreakLease 
    
        inputs: 
    
          azureSubscription: ${{ parameters.ServiceConnectionName }} 
    
          scriptType: "pscore" 
    
          scriptLocation: "inlineScript" 
    
          inlineScript: "az storage blob lease break --container-name 'test' --blob-name '${{ parameters.File }}' --account-name '${{ parameters.StorageAccountName }}'" 
    

    解决方案2:你可以通过azure storage explorer来解除租约:

    如果你想打破集装箱租约

    第 1 步: 进入 storage account --> 选择 container 右键单击​​ container 选择 Break lease强>。

    容器中的blob也是如此。

    解决方案 3:使用 Azure CLI 命令解除租约

    az storage blob lease break --blob-name   --container-name [--account-key]  [--account-name] 
    [--auth-mode {key, login}] [--connection-string] [--if-match] [--if-modified-since] 
    [--if-none-match] [--if-unmodified-since] [--lease-break-period] [--sas-token] 
    [--subscription] [--tags-condition] [--timeout] 
    
     
    

    更多详情请参考此文档:https://docs.microsoft.com/en-us/cli/azure/storage/blob/lease?view=azure-cli-latest#az_storage_blob_lease_break

    【讨论】:

    • 谢谢@ShrutiJoshi!试试这个。
    • 如果答案对您有帮助,您可以接受它作为答案(单击答案旁边的复选标记,将其从灰色切换为已填充。)。这对其他社区成员可能是有益的。谢谢
    • 解决方案 1 非常适合我。我已经接受了这个答案。
    猜你喜欢
    • 2022-11-05
    • 1970-01-01
    • 2023-03-14
    • 1970-01-01
    • 1970-01-01
    • 2018-12-14
    • 1970-01-01
    • 2021-06-19
    • 2016-06-25
    相关资源
    最近更新 更多