Skip to content

Setting CORS for Azure Blob Storage #5552

Answered by gerasiie
AndiRudi asked this question in Q&A
Discussion options

You must be logged in to vote

I made it working this way:

    var storage = builder.AddAzureStorage("storage").ConfigureInfrastructure(x =>
    {
        var blobStorage = x.GetProvisionableResources().OfType<BlobService>().Single();

        blobStorage.CorsRules.Add(new BicepValue<StorageCorsRule>(new StorageCorsRule
        {
            AllowedOrigins = [new BicepValue<string>("https://localhost:7268")],
            AllowedMethods = [CorsRuleAllowedMethod.Get, CorsRuleAllowedMethod.Put, CorsRuleAllowedMethod.Options],
            AllowedHeaders = [new BicepValue<string>("*")],
            ExposedHeaders = [new BicepValue<string>("*")],
            MaxAgeInSeconds = new BicepValue<int>(3600)
        }));
    });

Replies: 6 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@AndiRudi
Comment options

Comment options

You must be logged in to vote
1 reply
@AndiRudi
Comment options

Comment options

You must be logged in to vote
1 reply
@AndiRudi
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by davidfowl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants