Skip to content

Commit a73abe5

Browse files
authored
Merge pull request #21 from codez-one/paje/make_azure_deployment_more_smoth_and_even_more_money_savings
improve the default ARM deployment
2 parents 65d5466 + 42dd086 commit a73abe5

File tree

2 files changed

+79
-12
lines changed

2 files changed

+79
-12
lines changed

Readme.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ This can be used on the download page:
1515
In every [release](https://github.com/codez-one/CZ.Azure.FileExchange/releases/latest) of this repository you will find a `azuredeploy.json`.
1616
Just take this json and deploy it [here](https://portal.azure.com/#create/Microsoft.Template).
1717
After this you have in your resource group an storage account and a static web app.
18-
Find out the URL of your static website add the CORS rule for it:
19-
20-
![Configure Cors](docs/.assets/ce554abc-df88-45ae-8348-6c97f8e8dbef.png)
2118

2219
After this download the two ZIPs of the release (API.zip & Frontend.zip) and extract them.
2320

main.bicep

Lines changed: 79 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
param name string
2-
2+
param location string = resourceGroup().location
33
resource storage 'Microsoft.Storage/storageAccounts@2021-06-01' = {
4-
name: uniqueString(resourceGroup().id,'7f358957-c1be-48ad-8902-808564e0556f')
5-
location: resourceGroup().location
4+
name: uniqueString(resourceGroup().id, '7f358957-c1be-48ad-8902-808564e0556f')
5+
location: location
66
kind: 'StorageV2'
77
sku: {
88
name: 'Standard_LRS'
99
}
10-
properties: {
11-
12-
}
10+
properties: {}
1311
}
1412

13+
1514
resource website 'Microsoft.Web/staticSites@2021-02-01' = {
1615
name: name
17-
location: resourceGroup().location
16+
location: location
1817
sku: {
1918
name: 'Free'
2019
tier: 'Free'
2120
}
22-
properties:{}
21+
properties: {}
2322
}
2423

25-
resource websiteconfig 'Microsoft.Web/staticSites/config@2021-02-01' ={
24+
resource websiteconfig 'Microsoft.Web/staticSites/config@2021-02-01' = {
2625
dependsOn: [
2726
storage
2827
]
@@ -32,3 +31,74 @@ resource websiteconfig 'Microsoft.Web/staticSites/config@2021-02-01' ={
3231
StorageConnectionString: 'DefaultEndpointsProtocol=https;AccountName=${storage.name};AccountKey=${storage.listKeys().keys[0].value};EndpointSuffix=${environment().suffixes.storage}'
3332
}
3433
}
34+
35+
resource storageBlobServiceConfig 'Microsoft.Storage/storageAccounts/blobServices@2021-08-01' = {
36+
parent: storage
37+
name: 'default'
38+
properties: {
39+
lastAccessTimeTrackingPolicy:{
40+
enable: true
41+
}
42+
cors: {
43+
corsRules: [
44+
{
45+
allowedOrigins: [
46+
website.properties.defaultHostname
47+
'https://*.${location}.azurestaticapps.net'
48+
]
49+
exposedHeaders: [
50+
'*'
51+
]
52+
maxAgeInSeconds: 0
53+
allowedMethods: [
54+
'GET'
55+
'PUT'
56+
'OPTIONS'
57+
]
58+
allowedHeaders: [
59+
'*'
60+
]
61+
}
62+
]
63+
}
64+
}
65+
}
66+
67+
resource storageSaveMonyPolicy 'Microsoft.Storage/storageAccounts/managementPolicies@2021-08-01' = {
68+
parent: storage
69+
name: 'default'
70+
dependsOn: [
71+
storageBlobServiceConfig
72+
]
73+
properties: {
74+
policy: {
75+
rules: [
76+
{
77+
type: 'Lifecycle'
78+
name: 'save money'
79+
definition: {
80+
actions: {
81+
baseBlob: {
82+
tierToCool: {
83+
daysAfterLastAccessTimeGreaterThan: 10
84+
}
85+
tierToArchive: {
86+
daysAfterLastAccessTimeGreaterThan: 30
87+
}
88+
enableAutoTierToHotFromCool: true
89+
delete: {
90+
daysAfterLastAccessTimeGreaterThan: 365
91+
}
92+
}
93+
}
94+
filters:{
95+
blobTypes: [
96+
'blockBlob'
97+
]
98+
}
99+
}
100+
}
101+
]
102+
}
103+
}
104+
}

0 commit comments

Comments
 (0)