Skip to content

Commit

Permalink
Example to deploy an ARM template
Browse files Browse the repository at this point in the history
  • Loading branch information
pplu committed Jan 5, 2018
1 parent 4f76e44 commit adc05ab
Showing 1 changed file with 91 additions and 0 deletions.
91 changes: 91 additions & 0 deletions examples/deploy_arm_template.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/usr/bin/env perl

use strict;
use warnings;
use Azure;

my $rg = $ARGV[0] or die "Usage $0 resource_group_name";

my $template = <<JSON;
{
"\$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"newZoneName": {
"type": "string",
"defaultValue": "[concat(uniqueString(resourceGroup().id), '.azurequickstart.org')]",
"metadata": {
"description": "The name of the DNS zone to be created. Must have at least 2 segements, e.g. hostname.org"
}
},
"newRecordName": {
"type": "string",
"defaultValue": "www",
"metadata": {
"description": "The name of the DNS record to be created. The name is relative to the zone, not the FQDN."
}
}
},
"resources": [
{
"type": "Microsoft.Network/dnszones",
"name": "[parameters('newZoneName')]",
"apiVersion": "2016-04-01",
"location": "global",
"properties": { }
},
{
"type": "Microsoft.Network/dnszones/a",
"name": "[concat(parameters('newZoneName'), '/', parameters('newRecordName'))]",
"apiVersion": "2016-04-01",
"location": "global",
"dependsOn": [
"[parameters('newZoneName')]"
],
"properties": {
"TTL": 3600,
"ARecords": [
{
"ipv4Address": "1.2.3.4"
},
{
"ipv4Address": "1.2.3.5"
}
]
}
}
],
"outputs": {
"nameServers": {
"type": "array",
"value": "[reference(parameters('newZoneName')).nameServers]"
}
}
}
JSON

use JSON;

my $rm = Azure->new(
)->service('ResourceManagement');

my $result = $rm->CreateOrUpdateDeployments(
api_version => '2017-05-10',
subscriptionId => $ENV{AZURE_SUBSCRIPTION_ID},
deploymentName => 'DeploymentName',
resourceGroupName => $rg,
parameters => {
properties => {
mode => 'complete',
parameters => {
newZoneName => { value => 'testable.com' },
newRecordName => { value => 'www2' },
},
template => decode_json($template),
}
}
);

use Data::Dumper;
print Dumper($result);

0 comments on commit adc05ab

Please sign in to comment.