Azure CLI 存储集 cors - 意外的令牌

Azure CLI storage set cors - Unexpected token

我正在尝试按照上述方式设置 CORS ,但出现错误:

$ azure storage cors set --blob static --cors [{\"AllowedOrigins\":\"*\",\"AllowedMethods\":\"GET\"}]
info:    Executing command storage cors set
+ Setting storage CORS rules for service: blob                                 
error:   Unexpected token :

[{\"AllowedOrigins\":\"*\",\"AllowedMethods\":\"GET\"}] 怎么了?

我认为您缺少 MaxAgeInSeconds 参数。如果我尝试不使用此参数,则会出现错误。但是以下对我有用:

azure storage cors set --blob static 
--cors "[{\"AllowedOrigins\":\"*\",\"AllowedMethods\":\"GET\",\"MaxAgeInSeconds\":\"86400\",\"AllowedHeaders\":\"*\",\"ExposedHeaders\":\"*\"}]"
-a "account-name" -k "account-key" --verbose