Azure CLI 编辑内容类型文件属性

问题描述 投票:0回答:1

我正试图使用 Azure CLI 更新位于我的 Azure $web blob 容器中的文件的 Content Type 属性。我试图这样做是因为它设置错误,我的 service-worker.js(用于我的 PWA)需要有 "applicationjavascript "而不是 "textplain; charset=utf-8 "才能注册。

azure azure-storage azure-storage-blobs azure-cli azure-storage-files
1个回答
1
投票

当使用Azure cli时,你应该使用 az存储blob更新.

示例代码。

az storage blob update --container-name xxx --name xxx --account-key xxx --account-name xxx --content-type "application/javascript"

0
投票

我找到了一种使用Azure Pipelines来实现这一目标的方法。


- task: AzureFileCopy@4
  displayName: "Azure Storage - copy new files"
  inputs:
    SourcePath: '$(System.DefaultWorkingDirectory)/dist/*'
    azureSubscription: 'johnykes-PAYG(44df419f-b455-4c4d-a8f8-c2a5fd479f10)'
    Destination: 'AzureBlob'
    storage: 'johnykeschatfrontend'
    ContainerName: '$web'

- task: AzureFileCopy@4
  displayName: "Azure Storage - overwrite .js files with correct Content Type"
  inputs:
    SourcePath: '$(System.DefaultWorkingDirectory)/dist/*.js'
    azureSubscription: 'johnykes-PAYG(44df419f-b455-4c4d-a8f8-c2a5fd479f10)'
    Destination: 'AzureBlob'
    storage: 'johnykeschatfrontend'
    ContainerName: '$web'
    AdditionalArgumentsForBlobCopy: '--content-type "application/javascript"'

如果你找到了使用Azure CLI或以我的方式,但递归地(对所有.js文件)或以任何其他方式做的方法,请让我知道。

© www.soinside.com 2019 - 2024. All rights reserved.