So, I've been tinkering for a while now and I've been struggling with adding cors to my Blob Containers in Azure using the @azure/arm-storage nodejs package.
Anyone got a clue how to set service properties?
Here is what I got:
async setCorsOnResource(storageAccountName, cors) {
try {
const service = await this.createBlobServicesManager();
service.setServiceProperties(this.resourceName, storageAccountName, cors);
} catch (err) {
console.error(err);
}
}
cors look like this:
const cors = {
CorsRule: [{
AllowedOrigins: ['*'],
AllowedMethods: ['GET'],
AllowedHeaders: [],
ExposedHeaders: [],
MaxAgeInSeconds: 60
}],
};
At this point I'm just mashing things together but I don't know what I'm doing wrong.
Here is their documentation if you want to get a better understanding of how the BlobServices class works. https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-arm-storage/11.0.0/interfaces/blobserviceproperties.html#cors