Skip to content

Commit

Permalink
adding arm template
Browse files Browse the repository at this point in the history
  • Loading branch information
segraef committed Mar 22, 2020
1 parent a7dc7c8 commit 4a3eb6d
Show file tree
Hide file tree
Showing 3 changed files with 249 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/azdeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ jobs:
uses: segraef/azdeploy@v1
with:
resourceGroupName: ${{ secrets.resourceGroupName }}
templateFile: ${{ secrets.templateFile }}
parametersFile: ${{ secrets.parametersFile }}
templateFile: "deploy.json"
parametersFile: "parameters.json"
resourceGroupCommand: ${{ secrets.resourceGroupCommand }}
238 changes: 238 additions & 0 deletions .github/workflows/deploy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountName": {
"type": "string",
"maxLength": 24,
"metadata": {
"description": "Required. Name of the Storage Account."
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Optional. Location for all resources."
}
},
"storageAccountKind": {
"type": "string",
"defaultValue": "StorageV2",
"allowedValues": [
"Storage",
"StorageV2",
"BlobStorage",
"FileStorage",
"BlockBlobStorage"
],
"metadata": {
"description": "Optional. Type of Storage Account to create."
}
},
"storageAccountSku": {
"type": "string",
"defaultValue": "Standard_GRS",
"allowedValues": [
"Standard_LRS",
"Standard_GRS",
"Standard_RAGRS",
"Standard_ZRS",
"Premium_LRS",
"Premium_ZRS",
"Standard_GZRS",
"Standard_RAGZRS"
],
"metadata": {
"description": "Optional. Storage Account Sku Name."
}
},
"storageAccountAccessTier": {
"type": "string",
"defaultValue": "Hot",
"allowedValues": [
"Hot",
"Cool"
],
"metadata": {
"description": "Optional. Storage Account Access Tier."
}
},
"vNetId": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "Optional. Virtual Network Identifier used to create a service endpoint."
}
},
"networkAcls": {
"type": "object",
"defaultValue": {
},
"metadata": {
"description": "Optional. Networks ACLs, this value contains IPs to whitelist and/or Subnet information."
}
},
"blobContainers": {
"type": "array",
"defaultValue": [
],
"metadata": {
"description": "Optional. Blob containers to create."
}
},
"utcYear": {
"type": "string",
"defaultValue": "[utcNow('yyyy')]",
"metadata": {
"description": "Optional. Year data used to generate a SAS token. Default is the current year."
}
},
"lockForDeletion": {
"type": "bool",
"defaultValue": false,
"metadata": {
"description": "Optional. Switch to lock storage from deletion."
}
},
"tags": {
"type": "object",
"defaultValue": {
},
"metadata": {
"description": "Optional. Tags of the Storage Account resource."
}
}
},
"variables": {
"cleanStorageAccountName": "[replace(tolower(parameters('storageAccountName')), '-', '')]",
"accountSasProperties": {
"signedServices": "bt",
"signedPermission": "racuw",
"signedExpiry": "[concat(string(add(int(parameters('utcYear')), 100)), '-12-31T23:59:59Z')]",
"signedResourceTypes": "co",
"signedProtocol": "https"
},
"virtualNetworkRules": {
"copy": [
{
"name": "virtualNetworkRules",
"count": "[if(empty(parameters('networkAcls')), 0, length(parameters('networkAcls').virtualNetworkRules))]",
"input": {
"id": "[concat(parameters('vNetId'), '/subnets/', parameters('networkAcls').virtualNetworkRules[copyIndex('virtualNetworkRules')].subnet)]"
}
}
]
},
"networkAcls": {
"bypass": "[if(empty(parameters('networkAcls')), json('null'), parameters('networkAcls').bypass)]",
"defaultAction": "[if(empty(parameters('networkAcls')), json('null'), parameters('networkAcls').defaultAction)]",
"virtualNetworkRules": "[if(empty(parameters('networkAcls')), json('null'), variables('virtualNetworkRules').virtualNetworkRules)]",
"ipRules": "[if(empty(parameters('networkAcls')), json('null'), if(equals(length(parameters('networkAcls').ipRules), 0), json('null'), parameters('networkAcls').ipRules))]"
}
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('cleanStorageAccountName')]",
"apiVersion": "2019-04-01",
"location": "[parameters('location')]",
"kind": "[parameters('storageAccountKind')]",
"sku": {
"name": "[parameters('storageAccountSku')]"
},
"tags": "[parameters('Tags')]",
"properties": {
"encryption": {
"keySource": "Microsoft.Storage",
"services": {
"blob": "[if(or(equals(parameters('storageAccountKind'), 'BlockBlobStorage'), equals(parameters('storageAccountKind'), 'BlobStorage'), equals(parameters('storageAccountKind'), 'StorageV2'), equals(parameters('storageAccountKind'), 'Storage')), json('{\"enabled\": true}'), json('null'))]",
"file": "[if(or(equals(parameters('storageAccountKind'), 'FileStorage'), equals(parameters('storageAccountKind'), 'StorageV2'), equals(parameters('storageAccountKind'), 'Storage')), json('{\"enabled\": true}'), json('null'))]"
}
},
"accessTier": "[parameters('storageAccountAccessTier')]",
"supportsHttpsTrafficOnly": true,
"networkAcls": "[if(empty(parameters('networkAcls')), json('null'), variables('networkAcls'))]"
},
"resources": [
{
"type": "providers/locks",
"apiVersion": "2016-09-01",
"condition": "[parameters('lockForDeletion')]",
"name": "Microsoft.Authorization/storageDoNotDelete",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/', variables('cleanStorageAccountName'))]"
],
"comments": "Resource lock on the Storage Account",
"properties": {
"level": "CannotDelete"
}
}
]
},
{
"name": "[if(empty(parameters('blobContainers')), concat(variables('cleanStorageAccountName'), '/', 'default/dummy'), concat(variables('cleanStorageAccountName'), '/default/', parameters('blobContainers')[copyIndex('blobContainersLoop')].name))]",
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
"apiVersion": "2018-03-01-preview",
"condition": "[not(empty(parameters('blobContainers')))]",
"copy": {
"name": "blobContainersLoop",
"count": "[if(empty(parameters('blobContainers')) , 1, length(parameters('blobContainers')))]"
},
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('cleanStorageAccountName'))]"
]
}
],
"outputs": {
"storageAccountResourceId": {
"type": "string",
"value": "[resourceId('Microsoft.Storage/storageAccounts', variables('cleanStorageAccountName'))]",
"metadata": {
"description": "The Resource Id of the Storage Account."
}
},
"storageAccountRegion": {
"type": "string",
"value": "[parameters('location')]",
"metadata": {
"description": "The Region of the Storage Account."
}
},
"storageAccountName": {
"type": "string",
"value": "[variables('cleanStorageAccountName')]",
"metadata": {
"description": "The Name of the Storage Account."
}
},
"storageAccountResourceGroup": {
"type": "string",
"value": "[resourceGroup().name]",
"metadata": {
"description": "The name of the Resource Group the Storage Account was created in."
}
},
"storageAccountSasToken": {
"type": "securestring",
"value": "[listAccountSas(variables('cleanStorageAccountName'), '2019-04-01', variables('accountSasProperties')).accountSasToken]",
"metadata": {
"description": "The SAS Token for the Storage Account."
}
},
"storageAccountAccessKey": {
"type": "securestring",
"value": "[listKeys(variables('cleanStorageAccountName'), '2016-12-01').keys[0].value]",
"metadata": {
"description": "The Access Key for the Storage Account."
}
},
"storageAccountPrimaryBlobEndpoint": {
"type": "string",
"value": "[reference(concat('Microsoft.Storage/storageAccounts/', variables('cleanStorageAccountName')), '2019-04-01').primaryEndpoints.blob]",
"metadata": {
"description": "The public endpoint of the Storage Account."
}
}
}
}
9 changes: 9 additions & 0 deletions .github/workflows/parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountName": {
"value": "aga-sa-3f7d65d0s7"
}
}
}

0 comments on commit 4a3eb6d

Please sign in to comment.