Edit json for Resource Sharing (CORS) on Blob Service

Jeff Schulz 0 Reputation points

I am entering one or more lines and filling in the fields for oneor mor cors rules for my blob service ...
but, I would like to edit/download the .json file instead. How can i do that, do i have to go thru the rest apis ? ex. there is 'JSON view' on storage main page/

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,473 questions
{count} votes

1 answer

Sort by: Most helpful
  1. KarishmaTiwari-MSFT 18,627 Reputation points Microsoft Employee

    @Jeff Schulz Thanks for posting your query on Microsoft Q&A.

    Currently there isn't a way to update the CORS rules via JSON view on Azure portal.
    But you can use Azure CLI or Azure PowerShell to update the CORS rules, if you do not want to go the REST API way. For example, to update CORS rules using Azure PowerShell,

    Set Storage context

    $ctx1=New-AzStorageContext -StorageAccountName "sname" -StorageAccountKey "abc"

    Get Storage CORS rule

    $CorsRules = Get-AzStorageCORSRule -ServiceType Blob -Context $ctx1      

    View existing CORS rules if any.

    Write-Output $CorsRules 


    AllowedOrigins  : {}
    AllowedHeaders  : {*}
    ExposedHeaders  : {}
    AllowedMethods  : {Get}
    MaxAgeInSeconds : 0

    Update CORS rule:

    $CorsRules[0].AllowedMethods = @("Get", "Connect", "Merge")        
    Set-AzStorageCORSRule -ServiceType Blob -CorsRules $CorsRules -Context $ctx1
    $CorsRules = Get-AzStorageCORSRule -ServiceType Blob -Context $ctx1                                                                                   Write-Output $CorsRules  


    AllowedOrigins  : {}
    AllowedHeaders  : {*}
    ExposedHeaders  : {}
    AllowedMethods  : {Get, Connect, Merge}
    MaxAgeInSeconds : 0

    This way, you can update the CORS rules.

    You may also find these documents helpful:

    If you have any questions, please let us know in the "comments" and we would be happy to help you. Comment is the fastest way of notifying the experts.

    If this helps, please 'Accept answer', 'mark as helpful' so that it can help others in the community looking for help on the same topic.

    0 comments No comments