问题
I'm trying to update Content Type property of a file located in my Azure $web blob container using Azure CLI. I'm trying to do this because it's wrongly set and my service-worker.js (for my PWA) needs to have "application/javascript" instead of "text/plain; charset=utf-8" in order to be registered.
回答1:
When using Azure cli, you should use az storage blob update.
The sample code:
az storage blob update --container-name xxx --name xxx --account-key xxx --account-name xxx --content-type "application/javascript"
回答2:
I found a way of doing this using 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"'
Please let me know if you find a way of doing using the Azure CLI or in my way but recursively (for all .js files) or in any other way.
来源:https://stackoverflow.com/questions/62155272/azure-cli-edit-content-type-file-property