Last active
December 3, 2019 10:45
-
-
Save jamesbjackson/1e62f38794075c4544d70dd92eccdf9a to your computer and use it in GitHub Desktop.
Azure Support in Sparkleformation.io
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"name": { | |
"type": "string", | |
"defaultValue": "storage_account_name", | |
"metadata": { | |
"description": "Unique DNS name for the Storage Account" | |
} | |
}, | |
"skuName": { | |
"type": "string", | |
"defaultValue": "Standard_LRS", | |
"allowedValues": [ | |
"Standard_LRS", | |
"Standard_ZRS", | |
"Standard_GRS", | |
"Standard_RAGRS", | |
"Premium_LRS" | |
], | |
"metadata": { | |
"description": "The SKU name to be used by the Storage Account" | |
} | |
} | |
}, | |
"outputs": { | |
"storageAccountName": { | |
"value": "[parameters('name')]", | |
"type": "string" | |
}, | |
"storageAccountId": { | |
"value": "[resourceId('Microsoft.Storage/storageAccounts', parameters('name'))]", | |
"type": "string" | |
}, | |
"storageAccountAccessKey": { | |
"value": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('name')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value]", | |
"type": "string" | |
}, | |
"storageAccountBlobPrimaryEndpoint": { | |
"value": "[reference(resourceId('Microsoft.Storage/storageAccounts', parameters('name')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).primaryEndpoints.blob]", | |
"type": "string" | |
} | |
}, | |
"resources": [ | |
{ | |
"type": "Microsoft.Storage/storageAccounts", | |
"location": "[resourceGroup().location]", | |
"sku": { | |
"name": "[parameters('skuName')]" | |
}, | |
"kind": "Storage", | |
"apiVersion": "2016-01-01", | |
"name": "[parameters('name')]" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SparkleFormation.component(:base, :provider => :azure) do | |
set!('$schema', 'https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#') | |
content_version '1.0.0.0' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
require_relative '../config/boot' | |
require 'pp' | |
sparkle_dir = File.expand_path(File.join(File.dirname(__FILE__), "../sparkleformation")) | |
template_fname = File.expand_path(ARGV[0]) | |
rel_fname = File.join(File.dirname(template_fname).gsub(/^.*templates\//, ''), File.basename(template_fname, ".rb")) | |
opts = {} | |
if !ARGV[1].nil? | |
opts[:state] = Imp::Params::Resolver.load(ARGV[1]) | |
end | |
SparkleFormation.sparkle_path = sparkle_dir | |
tpl = SparkleFormation.compile(template_fname, opts) | |
puts JSON.pretty_generate(tpl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
compile_time_parameters = {} | |
SparkleFormation.new(:default_storage_account, :provider => :azure, :compile_time_parameters => compile_time_parameters).load(:base) do | |
parameters.name do | |
type registry!(:string) | |
default_value "storage_account_name" | |
metadata.description "Unique DNS name for the Storage Account" | |
end | |
parameters.sku_name do | |
type registry!(:string) | |
default_value "Standard_LRS" | |
allowed_values %w( Standard_LRS Standard_ZRS Standard_GRS Standard_RAGRS Premium_LRS ) | |
metadata.description "The SKU name to be used by the Storage Account" | |
end | |
storage_account_resource = dynamic!(:storage_storageaccounts, parameters!(:name), :resource_name_suffix => "") do | |
location resource_group!().location.to_s | |
sku.name parameters!(:sku_name).to_s | |
kind "Storage" | |
end | |
outputs.storage_account_name do | |
value parameters!(:name).to_s | |
type registry!(:string) | |
end | |
outputs.storage_account_id do | |
value resource_id!(storage_account_resource.resource_name!).to_s | |
type registry!(:string) | |
end | |
outputs.storage_account_access_key do | |
value list_keys!(resource_id!(storage_account_resource.resource_name!), providers!('Microsoft.Storage','storageAccounts').apiVersions[0]).keys[0].value.to_s | |
type registry!(:string) | |
end | |
outputs.storage_account_blob_primary_endpoint do | |
value reference!(resource_id!(storage_account_resource.resource_name!), providers!('Microsoft.Storage', 'storageAccounts').apiVersions[0]).primaryEndpoints.blob.to_s | |
type registry!(:string) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment