【问题标题】:Azure CLI edit Content Type file propertyAzure CLI 编辑内容类型文件属性
【发布时间】:2020-09-21 02:44:55
【问题描述】:
我正在尝试使用 Azure CLI 更新位于我的 Azure $web blob 容器中的文件的内容类型属性。我正在尝试这样做,因为它设置错误并且我的 service-worker.js(对于我的 PWA)需要具有“application/javascript”而不是“text/plain; charset=utf-8”才能注册。
【问题讨论】:
标签:
azure
azure-storage
azure-blob-storage
azure-cli
azure-storage-files
【解决方案1】:
使用 Azure cli 时,应使用az storage blob update。
示例代码:
az storage blob update --container-name xxx --name xxx --account-key xxx --account-name xxx --content-type "application/javascript"
【解决方案2】:
我找到了一种使用 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 文件)或以任何其他方式进行操作的方法,请告诉我。