我正试图使用 Azure CLI 更新位于我的 Azure $web blob 容器中的文件的 Content Type 属性。我试图这样做是因为它设置错误,我的 service-worker.js(用于我的 PWA)需要有 "applicationjavascript "而不是 "textplain; charset=utf-8 "才能注册。
当使用Azure cli时,你应该使用 az存储blob更新.
示例代码。
az storage blob update --container-name xxx --name xxx --account-key xxx --account-name xxx --content-type "application/javascript"
我找到了一种使用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文件)或以任何其他方式做的方法,请让我知道。