cloudformation failed to create subnets - json

I was trying to run a code and i had this error but cant identify the problem. i got the error message The CIDR '10.0.1.0/24' conflicts with another subnet (Service: AmazonEC2; Status Code: 400; Error Code: InvalidSubnet.Conflict; Request ID: e0de23a8-d921-475f-aadd-84dac3109664; Proxy: null)
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "This is a network with one Vpc, 4 Subnet; 2 private, 2 public",
"Metadata": {},
"Parameters": {
"MyVpcCidr": {
"Description": "This is the cidr for appVpc",
"Type": "String",
"Default": "10.0.0.0/16"
},
"AZ1": {
"Description": "AZ 1 for my network",
"Type": "AWS::EC2::AvailabilityZone::Name"
},
"Priv1Cidr": {
"Description": "This is the cidr for my appPriv1Subnet",
"Type": "String",
"Default": "10.0.1.0/24"
},
"Priv2Cidr": {
"Description": "This is the cidr for my appPriv2Subnet",
"Type": "String",
"Default": "10.0.3.0/24"
},
"AZ2": {
"Description": "AZ 2 for my network",
"Type": "AWS::EC2::AvailabilityZone::Name"
},
"Pub1Cidr": {
"Description": "Cidr for my appPubSN1",
"Type": "String",
"Default": "10.0.2.0/24"
},
"Pub2Cidr": {
"Description": "Cidr for appPubSN2",
"Type": "String",
"Default": "10.0.4.0/16"
}
},
"Mappings": {},
"Conditions": {},
"Resources": {
"appVpc": {
"Type": "AWS::EC2::VPC",
"Properties": {
"CidrBlock": {
"Ref": "MyVpcCidr"
},
"Tags": [
{
"Key": "Name",
"Value": "AppVpc"
}
]
}
},
"appPriv1Subnet": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"AvailabilityZone": {
"Ref": "AZ1"
},
"VpcId": {
"Ref": "appVpc"
},
"CidrBlock": {
"Ref": "Priv1Cidr"
},
"Tags": [
{
"Key": "Name",
"Value": "Apppriv1subnet"
}
]
}
},
"appPriv2Subnet": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"AvailabilityZone": {
"Ref": "AZ2"
},
"VpcId": {
"Ref": "appVpc"
},
"CidrBlock": {
"Ref": "Priv2Cidr"
},
"Tags": [
{
"Key": "Name",
"Value": "AppPriv2Subnet"
}
]
}
},
"appPubSN1": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"AvailabilityZone": {
"Ref": "AZ1"
},
"VpcId": {
"Ref": "appVpc"
},
"CidrBlock": {
"Ref": "Pub1Cidr"
},
"Tags": [
{
"Key": "Name",
"Value": "AppPubsn1"
}
]
}
},
"appPubSN2": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"AvailabilityZone": {
"Ref": "AZ2"
},
"VpcId": {
"Ref": "appVpc"
},
"CidrBlock": {
"Ref": "Pub2Cidr"
},
"Tags": [
{
"Key": "Name",
"Value": "AppPubsn2"
}
]
}
},
"appIG": {
"Type": "AWS::EC2::InternetGateway",
"Properties": {
"Tags": [
{
"Key": "Name",
"Value": "AppIG"
}
]
}
},
"AttachGateway": {
"Type": "AWS::EC2::VPCGatewayAttachment",
"Properties": {
"VpcId": {
"Ref": "appVpc"
},
"InternetGatewayId": {
"Ref": "appIG"
}
}
},
"appPrivRT": {
"Type": "AWS::EC2::RouteTable",
"Properties": {
"VpcId": {
"Ref": "appVpc"
},
"Tags": [
{
"Key": "Name",
"Value": "AppPrivRt"
}
]
}
},
"PrivRTA1": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"SubnetId": {
"Ref": "appPriv1Subnet"
},
"RouteTableId": {
"Ref": "appPrivRT"
}
}
},
"PrivRTA2": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"SubnetId": {
"Ref": "appPriv2Subnet"
},
"RouteTableId": {
"Ref": "appPrivRT"
}
}
},
"appEIP": {
"Type": "AWS::EC2::EIP",
"Properties": {
"Domain": "vpc"
}
},
"appNatgw": {
"Type": "AWS::EC2::NatGateway",
"Properties": {
"AllocationId": {
"Fn::GetAtt": [
"appEIP",
"AllocationId"
]
},
"SubnetId": {
"Ref": "appPubSN1"
},
"Tags": [
{
"Key": "Name",
"Value": "Appnatgw"
}
]
}
},
"appPrivRoute": {
"Type": "AWS::EC2::Route",
"Properties": {
"RouteTableId": {
"Ref": "appPrivRT"
},
"DestinationCidrBlock": "0.0.0.0/0",
"NatGatewayId": {
"Ref": "appNatgw"
}
}
},
"appPubRT": {
"Type": "AWS::EC2::RouteTable",
"Properties": {
"VpcId": {
"Ref": "appVpc"
},
"Tags": [
{
"Key": "Name",
"Value": "AppPubRT"
}
]
}
},
"PubRTA1": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"SubnetId": {
"Ref": "appPubSN1"
},
"RouteTableId": {
"Ref": "appPubRT"
}
}
},
"PubRTA2": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"SubnetId": {
"Ref": "appPubSN2"
},
"RouteTableId": {
"Ref": "appPubRT"
}
}
},
"appPubRoute": {
"Type": "AWS::EC2::Route",
"Properties": {
"RouteTableId": {
"Ref": "appPubRT"
},
"DestinationCidrBlock": "0.0.0.0/0",
"GatewayId": {
"Ref": "appIG"
}
}
},
"appSG": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Allow ssh port 22 and port 80",
"SecurityGroupIngress": [
{
"IpProtocol": "tcp",
"FromPort": "22",
"ToPort": "22",
"CidrIp": "0.0.0.0/0"
},
{
"IpProtocol": "tcp",
"FromPort": "80",
"ToPort": "80",
"CidrIp": "0.0.0.0/0"
}
],
"VpcId": {
"Ref": "appVpc"
},
"Tags": [
{
"Key": "Name",
"Value": "AppSG"
}
]
}
},
"internalSG": {
"DependsOn": "appSG",
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Allow traffic from appSG",
"SecurityGroupIngress": [
{
"IpProtocol": "-1",
"SourceSecurityGroupId": {
"Ref": "appSG"
}
}
],
"VpcId": {
"Ref": "appVpc"
},
"Tags": [
{
"Key": "Name",
"Value": "appinternalSG"
}
]
}
}
},
"Outputs": {
"appVpcId": {
"Description": "Id for my vpc ",
"Value": {
"Ref": "appVpc"
},
"Export": {
"Name": "appVpcid"
}
},
"appPrivSN1Id": {
"Description": "Id for my private SN1",
"Value": {
"Ref": "appPriv1Subnet"
},
"Export": {
"Name": "appPrivSNID1"
}
},
"appPrivSN2Id": {
"Description": "Id for my subnet 2 private",
"Value": {
"Ref": "appPriv2Subnet"
},
"Export": {
"Name": "appPrivSNID2"
}
},
"appPubSN1Id": {
"Description": "Id for Public subnet 1",
"Value": {
"Ref": "appPubSN1"
},
"Export": {
"Name": "appPubSNID1"
}
},
"appPubSN2Id": {
"Description": "Id for Public subnet 2",
"Value": {
"Ref": "appPubSN2"
},
"Export": {
"Name": "appPubSNID2"
}
},
"externalSgid": {
"Description": "Id for external security group",
"Value": {
"Ref": "appSG"
},
"Export": {
"Name": "appSGID"
}
},
"internalSGId": {
"Description": "Id for internal security group",
"Value": {
"Ref": "internalSG"
},
"Export": {
"Name": "internalSGID"
}
}
}
}

I suspect 10.0.4.0/16 is a typo that was meant to be 10.0.4.0/24.
The reason is that the cidr 10.0.4.0/16, which you have set for Pub2Cidr starts at 10.0.0.0 and ends at 10.0.255.255, which overlaps with 10.0.1.0/24 which starts at 10.0.1.0 and ends at 10.0.1.255.

Related

Cloudformation template to create EMR cluster

I am trying to create EMR-5.30.1 clusters with applications such as Hadoop, livy, Spark, ZooKeeper, and Hive with the help of the CloudFormation template. But the issue is with this template is I am able the cluster with only one application from the above list of applications.
below is the CloudFormation Template
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Best Practice EMR Cluster for Spark or S3 backed Hbase",
"Parameters": {
"EMRClusterName": {
"Description": "Name of the cluster",
"Type": "String",
"Default": "emrcluster"
},
"KeyName": {
"Description": "Must be an existing Keyname",
"Type": "String",
"Default": "keyfilename"
},
"MasterInstanceType": {
"Description": "Instance type to be used for the master instance.",
"Type": "String",
"Default": "m5.xlarge"
},
"CoreInstanceType": {
"Description": "Instance type to be used for core instances.",
"Type": "String",
"Default": "m5.xlarge"
},
"NumberOfCoreInstances": {
"Description": "Must be a valid number",
"Type": "Number",
"Default": 1
},
"SubnetID": {
"Description": "Must be Valid public subnet ID",
"Default": "subnet-ee15b3e0",
"Type": "String"
},
"LogUri": {
"Description": "Must be a valid S3 URL",
"Default": "s3://aws/elasticmapreduce/",
"Type": "String"
},
"S3DataUri": {
"Description": "Must be a valid S3 bucket URL ",
"Default": "s3://aws/elasticmapreduce/",
"Type": "String"
},
"ReleaseLabel": {
"Description": "Must be a valid EMR release version",
"Default": "emr-5.30.1",
"Type": "String"
},
"Applications": {
"Description": "Please select which application will be installed on the cluster this would be either Ganglia and spark, or Ganglia and s3 backed Hbase",
"Type": "String",
"AllowedValues": [
"Spark",
"Hbase",
"Hive",
"Livy",
"ZooKeeper"
]
}
},
"Mappings": {},
"Conditions": {
"Spark": {
"Fn::Equals": [
{
"Ref": "Applications"
},
"Spark"
]
},
"Hbase": {
"Fn::Equals": [
{
"Ref": "Applications"
},
"Hbase"
]
},
"Hive": {
"Fn::Equals": [
{
"Ref": "Applications"
},
"Hive"
]
},
"Livy": {
"Fn::Equals": [
{
"Ref": "Applications"
},
"Livy"
]
},
"ZooKeeper": {
"Fn::Equals": [
{
"Ref": "Applications"
},
"ZooKeeper"
]
}
},
"Resources": {
"EMRCluster": {
"DependsOn": [
"EMRClusterServiceRole",
"EMRClusterinstanceProfileRole",
"EMRClusterinstanceProfile"
],
"Type": "AWS::EMR::Cluster",
"Properties": {
"Applications": [
{
"Name": "Ganglia"
},
{
"Fn::If": [
"Spark",
{
"Name": "Spark"
},
{
"Ref": "AWS::NoValue"
}
]
},
{
"Fn::If": [
"Hbase",
{
"Name": "Hbase"
},
{
"Ref": "AWS::NoValue"
}
]
},
{
"Fn::If": [
"Hive",
{
"Name": "Hive"
},
{
"Ref": "AWS::NoValue"
}
]
},
{
"Fn::If": [
"Livy",
{
"Name": "Livy"
},
{
"Ref": "AWS::NoValue"
}
]
},
{
"Fn::If": [
"ZooKeeper",
{
"Name": "ZooKeeper"
},
{
"Ref": "AWS::NoValue"
}
]
}
],
"Configurations": [
{
"Classification": "hbase-site",
"ConfigurationProperties": {
"hbase.rootdir":{"Ref":"S3DataUri"}
}
},
{
"Classification": "hbase",
"ConfigurationProperties": {
"hbase.emr.storageMode": "s3"
}
}
],
"Instances": {
"Ec2KeyName": {
"Ref": "KeyName"
},
"Ec2SubnetId": {
"Ref": "SubnetID"
},
"MasterInstanceGroup": {
"InstanceCount": 1,
"InstanceType": {
"Ref": "MasterInstanceType"
},
"Market": "ON_DEMAND",
"Name": "Master"
},
"CoreInstanceGroup": {
"InstanceCount": {
"Ref": "NumberOfCoreInstances"
},
"InstanceType": {
"Ref": "CoreInstanceType"
},
"Market": "ON_DEMAND",
"Name": "Core"
},
"TerminationProtected": false
},
"VisibleToAllUsers": true,
"JobFlowRole": {
"Ref": "EMRClusterinstanceProfile"
},
"ReleaseLabel": {
"Ref": "ReleaseLabel"
},
"LogUri": {
"Ref": "LogUri"
},
"Name": {
"Ref": "EMRClusterName"
},
"AutoScalingRole": "EMR_AutoScaling_DefaultRole",
"ServiceRole": {
"Ref": "EMRClusterServiceRole"
}
}
},
"EMRClusterServiceRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"elasticmapreduce.amazonaws.com"
]
},
"Action": [
"sts:AssumeRole"
]
}
]
},
"ManagedPolicyArns": [
"arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceRole"
],
"Path": "/"
}
},
"EMRClusterinstanceProfileRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"ec2.amazonaws.com"
]
},
"Action": [
"sts:AssumeRole"
]
}
]
},
"ManagedPolicyArns": [
"arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceforEC2Role"
],
"Path": "/"
}
},
"EMRClusterinstanceProfile": {
"Type": "AWS::IAM::InstanceProfile",
"Properties": {
"Path": "/",
"Roles": [
{
"Ref": "EMRClusterinstanceProfileRole"
}
]
}
}
},
"Outputs": {}
}
Also, I want to add a bootstrap script in this template as well, Can anyone please help me with the issue.
As per my knoweldge and understanding, Applications in your case should be an array like below, as mentioned in documentation
"Applications" : [ Application, ... ],
In you case, you can list applications like
"Applications" : [
{"Name" : "Spark"},
{"Name" : "Hbase"},
{"Name" : "Hive"},
{"Name" : "Livy"},
{"Name" : "Zookeeper"},
]
For more arguments other than Name to individual application dictionary , see detail here, you can pass Args, Additional_info etc
You can use following way:-
If you set "ReleaseLabel" then there is no need to mention versions of applications
"Applications": [{
"Name": "Hive"
},
{
"Name": "Presto"
},
{
"Name": "Spark"
}
]
For bootstrap:-
"BootstrapActions": [{
"Name": "setup",
"ScriptBootstrapAction": {
"Path": "s3://bucket/key/Bootstrap.sh"
}
}]
Define like this to create all applications at once.
{
"Type": "AWS::EMR::Cluster",
"Properties": {
"Applications": [
{
"Name": "Ganglia"
},
{
"Name": "Spark"
},
{
"Name": "Livy"
},
{
"Name": "ZooKeeper"
},
{
"Name": "JupyterHub"
}
]
}
}

How do I pass secret value from keyvault using Azure ARM Template

I am trying to create Azure Application Gateway with ssl certificate from keyvaults. But didn't find any option to add keyvaults to ARM template with .pfx and .cer files. So I have encoded the certificate contents and added as secret in existing keyvault. Now trying to pass the secrets using ARM template. Validation passed but getting error in Deployment stage. Attached the template and parameters I am using.
Getting Error while deploying the resource
Deployment template validation failed: 'Template parameter JToken type is not valid. Expected 'String, Uri'. Actual 'Object'
"additionalInfo": [
{
"type": "TemplateViolation",
"info": {
"lineNumber": 226,
"linePosition": 33,
"path": "properties.template.parameters.appgwfesslcertsecret"
}
}
]
Updated Template:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"namingSettings": {
"type": "object"
},
"taggingSettings": {
"type": "object"
},
"applicationGatewaySettings": {
"type": "object"
},
"appgwfesslcertsecret": {
"type": "securestring"
},
"appgwbecertsecret": {
"type": "securestring"
}
},
"variables": {
"namePrefix": "[concat(parameters('namingSettings').name.org,'-',parameters('namingSettings').name.cloud,'-',parameters('namingSettings').name.region,'-',parameters('namingSettings').name.businessUnit,'-',parameters('namingSettings').name.account,'-',parameters('namingSettings').name.app,'-',parameters('namingSettings').name.sdlc,'-')]" },
"resources": [
{
"apiVersion": "2018-11-01",
"name": "[concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].name)]",
"type": "Microsoft.Network/applicationGateways",
"location": "[resourceGroup().location]",
"copy": {
"name": "appgwCopy",
"count": "[length(parameters('applicationGatewaySettings').settings)]"
},
"tags": "[parameters('taggingSettings').tags]",
"properties": {
"sku": {
"name": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].applicationGatewaySku]",
"tier": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].applicationGatewayTier]",
"capacity": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].applicationGatewayInstanceCount]"
},
"sslPolicy": {
"policyType": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].policyType]",
"policyName": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].policy]"
},
"copy": [
{
"name": "frontendPorts",
"count": "[length(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].frontendPorts)]",
"input": {
"name": "[concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].frontendPorts[copyIndex('frontendPorts')].name)]",
"properties": {
"port": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].frontendPorts[copyIndex('frontendPorts')].properties.port]"
}
}
},
{
"name": "gatewayIPConfigurations",
"count": "[length(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].gatewayIPConfigurations)]",
"input": {
"name": "[concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].gatewayIPConfigurations[copyIndex('gatewayIPConfigurations')].name)]",
"properties": {
"subnet": {
"id": "[resourceId(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].gatewayIPConfigurations[copyIndex('gatewayIPConfigurations')].properties.subnet.vnetRGName,'microsoft.network/virtualnetworks/subnets', parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].gatewayIPConfigurations[copyIndex('gatewayIPConfigurations')].properties.subnet.vnetName, parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].gatewayIPConfigurations[copyIndex('gatewayIPConfigurations')].properties.subnet.subnetName)]"
}
}
}
},
{
"name": "frontendIPConfigurations",
"count": "[length(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].frontendIPConfigurations)]",
"input": {
"name": "[concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].frontendIPConfigurations[copyIndex('frontendIPConfigurations')].name)]",
"properties": {
"subnet": {
"id": "[resourceId(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].gatewayIPConfigurations[copyIndex('frontendIPConfigurations')].properties.subnet.vnetRGName,'microsoft.network/virtualnetworks/subnets', parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].frontendIPConfigurations[copyIndex('frontendIPConfigurations')].properties.subnet.vnetName, parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].frontendIPConfigurations[copyIndex('frontendIPConfigurations')].properties.subnet.subnetName)]"
}
}
}
},
{
"name": "backendHttpSettingsCollection",
"count": "[length(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].backendHttpSettingsCollection)]",
"input": {
"name": "[concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].backendHttpSettingsCollection[copyIndex('backendHttpSettingsCollection')].name)]",
"properties": {
"port": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].backendHttpSettingsCollection[copyIndex('backendHttpSettingsCollection')].properties.port]",
"protocol": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].backendHttpSettingsCollection[copyIndex('backendHttpSettingsCollection')].properties.protocol]",
"authenticationCertificates": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].backendHttpSettingsCollection[copyIndex('backendHttpSettingsCollection')].properties.authenticationCertificates]"
}
}
},
{
"name": "backendAddressPools",
"count": "[length(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].backendAddressPools)]",
"input": {
"name": "[concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].backendAddressPools[copyIndex('backendAddressPools')].name)]"
}
},
{
"name": "httpListeners",
"count": "[length(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].httpListeners)]",
"input": {
"name": "[concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].httpListeners[copyIndex('httpListeners')].name)]",
"properties": {
"frontendIPConfiguration": {
"id": "[resourceId(resourceGroup().name, 'microsoft.network/applicationGateways/frontendIPConfigurations', concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].name),concat(variables('namePrefix'), parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].httpListeners[copyIndex('httpListeners')].properties.frontendIPConfiguration))]"
},
"frontendPort": {
"id": "[resourceId(resourceGroup().name, 'microsoft.network/applicationGateways/frontendPorts', concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].name),concat(variables('namePrefix'), parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].httpListeners[copyIndex('httpListeners')].properties.frontendPort))]"
},
"protocol": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].httpListeners[copyIndex('httpListeners')].properties.protocol]",
"sslCertificate": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].httpListeners[copyIndex('httpListeners')].properties.sslCertificate]"
}
}
},
{
"name": "requestRoutingRules",
"count": "[length(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].requestRoutingRules)]",
"input": {
"name": "[concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].requestRoutingRules[copyIndex('requestRoutingRules')].name)]",
"properties": {
"httpListener": {
"id": "[resourceId(resourceGroup().name, 'microsoft.network/applicationGateways/httpListeners', concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].name),concat(variables('namePrefix'), parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].requestRoutingRules[copyIndex('requestRoutingRules')].properties.httpListener))]"
},
"backendAddressPool": {
"id": "[resourceId(resourceGroup().name, 'microsoft.network/applicationGateways/backendAddressPools', concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].name),concat(variables('namePrefix'), parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].requestRoutingRules[copyIndex('requestRoutingRules')].properties.backendAddressPool))]"
},
"backendHttpSettings": {
"id": "[resourceId(resourceGroup().name, 'microsoft.network/applicationGateways/backendHttpSettingsCollection', concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].name),concat(variables('namePrefix'), parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].requestRoutingRules[copyIndex('requestRoutingRules')].properties.backendHttpSettings))]"
}
}
}
},
{
"name": "sslCertificates",
"count": "[length(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].sslCertificates)]",
"input": {
"name": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].sslCertificates[copyIndex('sslCertificates')].name]",
"properties": {
"data": "[parameters('appgwfesslcertsecret')]",
"password": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].sslCertificates[copyIndex('sslCertificates')].properties.password]"
}
}
},
{
"name": "authenticationCertificates",
"count": "[length(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].authenticationCertificates)]",
"input": {
"name": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].authenticationCertificates[copyIndex('authenticationCertificates')].name]",
"properties": {
"data": "[parameters('appgwbecertsecret')]"
}
}
}
],
"probes": [],
"webApplicationFirewallConfiguration": {
"enabled": true,
"firewallMode": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].firewallMode]",
"ruleSetType": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].ruleSetType]",
"ruleSetVersion": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].ruleSetVersion]",
"requestBodyCheck": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].requestBodyCheck]",
"maxRequestBodySizeInKb": "[if(parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].requestBodyCheck, parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].maxReqBodySize, json('null'))]",
"fileUploadLimitInMb": "[int(100)]"
},
"enableHttp2": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].enableHTTP2]"
},
"resources": [
{
"type": "providers/diagnosticSettings",
"name": "[concat('Microsoft.Insights/', parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].diagname)]",
"dependsOn": [
"[concat(variables('namePrefix'),parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].name)]"
],
"apiVersion": "2017-05-01-preview",
"properties": {
"name": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].diagname]",
"logs": [
{
"category": "ApplicationGatewayAccessLog",
"enabled": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].enableApplicationGatewayAccessLog]",
"retentionPolicy": {
"days": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].applicationGatewayAccessLogRetentionDays]",
"enabled": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].enableApplicationGatewayAccessLogRetention]"
}
},
{
"category": "ApplicationGatewayPerformanceLog",
"enabled": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].enableApplicationGatewayPerformanceLog]",
"retentionPolicy": {
"days": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].applicationGatewayPerformanceLogRetentionDays]",
"enabled": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].enableApplicationGatewayPerformanceLogRetention]"
}
},
{
"category": "ApplicationGatewayFirewallLog",
"enabled": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].enableApplicationGatewayFirewallLog]",
"retentionPolicy": {
"days": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].applicationGatewayFirewallLogRetentionDays]",
"enabled": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].enableApplicationGatewayFirewallLogRetention]"
}
}
],
"metrics": [
{
"category": "AllMetrics",
"enabled": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].enableAllMetrics]",
"retentionPolicy": {
"enabled": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].enableAllMetricsRetentionPolicy]",
"days": "[parameters('applicationGatewaySettings').settings[copyIndex('appgwCopy')].allMetricsRetentionDays]"
}
}
]
}
}
]
}
],
"outputs": {}
}
Updated Parameter File:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"namingSettings": {
"value": {
"name": {
"app": "demo",
"cloud": "azu",
"region": "eus2",
}
}
},
"taggingSettings": {
"value": {
"tags": {
"AppID": "demo",
"Environment": "nonprod",
}
}
},
"applicationGatewaySettings": {
"value": {
"settings": [
{
"name": "appgw-pcs01",
"applicationGatewaySku": "WAF_Medium",
"applicationGatewayTier": "WAF",
"applicationGatewayInstanceCount": 2,
"policyType": "Predefined",
"policy": "AppGwSslPolicy20170401S",
"publicIP": null,
"firewallMode": "Prevention",
"diagname": "Demo-Appgw",
"ruleSetType": "OWASP",
"ruleSetVersion": "3.0",
"requestBodyCheck": true,
"maxReqBodySize": 10,
"enableHTTP2": false,
"enableApplicationGatewayAccessLog": true,
"applicationGatewayAccessLogRetentionDays": 30,
"enableApplicationGatewayAccessLogRetention": true,
"enableApplicationGatewayPerformanceLog": true,
"applicationGatewayPerformanceLogRetentionDays": 30,
"enableApplicationGatewayPerformanceLogRetention": true,
"enableApplicationGatewayFirewallLog": true,
"applicationGatewayFirewallLogRetentionDays": 30,
"enableApplicationGatewayFirewallLogRetention": true,
"enableAllMetrics": true,
"enableAllMetricsRetentionPolicy": true,
"allMetricsRetentionDays": 30,
"frontendPorts": [
{
"name": "feport-80",
"properties": {
"port": 80
}
},
{
"name": "feport-443",
"properties": {
"port": 443
}
}
],
"gatewayIPConfigurations": [
{
"name": "gwipconfig-pcs01",
"properties": {
"subnet": {
"vnetName": "demo-vnet",
"vnetRGName": "demo",
"subnetName": "demo-subgw"
}
}
}
],
"sslCertificates": [
{
"name": "appgwfesslcert",
"properties": {
"data": null,
"password": "password"
}
}
],
"authenticationCertificates": [
{
"name": "appgwbecert",
"properties": {
"data": null
}
}
],
"frontEndIPConfigurations": [
{
"name": "feipcfg-pcs01",
"properties": {
"subnet": {
"vnetName": "demo-vnet",
"vnetRGName": "demo",
"subnetName": "demo-subgw"
}
}
}
],
"httpListeners": [
{
"name": "httplistener-pcs01",
"properties": {
"frontendIPConfiguration": "feipcfg-pcs01",
"frontendPort": "feport-80",
"protocol": "Http",
"sslCertificate": {}
}
},
{
"name": "httpslistener-pcs01",
"properties": {
"frontendIPConfiguration": "feipcfg-pcs01",
"frontendPort": "feport-443",
"protocol": "Https",
"sslCertificate": {
"id": "/subscriptions/105dcee5-gy46-48e3-9046-265c7379e647/resourceGroups/demo/providers/Microsoft.Network/applicationGateways/azu-eus2-nonprod-appgw-pcs01/sslCertificates/appgwfesslcert"
}
}
}
],
"backendHttpSettingsCollection": [
{
"name": "httpsetcol-default",
"properties": {
"protocol": "Http",
"port": 80,
"authenticationCertificates": []
}
},
{
"name": "httpssetcol-default",
"properties": {
"protocol": "Https",
"port": 443,
"authenticationCertificates": [
{
"id": "/subscriptions/105dcee5-gy46-48e3-9046-265c7379e647/resourceGroups/demo/providers/Microsoft.Network/applicationGateways/azu-eus2-nonprod-appgw-pcs01/authenticationCertificates/appgwbecert"
}
]
}
}
],
"backendAddressPools": [
{
"name": "beap-pcs01"
}
],
"requestRoutingRules": [
{
"name": "httpreqrtrule-pcs01",
"properties": {
"httpListener": "httplistener-pcs01",
"backendAddressPool": "beap-pcs01",
"backendHttpSettings": "httpsetcol-default"
}
},
{
"name": "httpsreqrtrule-pcs01",
"properties": {
"httpListener": "httpslistener-pcs01",
"backendAddressPool": "beap-pcs01",
"backendHttpSettings": "httpssetcol-default"
}
}
]
}
]
}
},
"appgwfesslcertsecret": {
"value": {
"reference": {
"keyVault": {
"id": "/subscriptions/105dcee5-gy46-48e3-9046-265c7379e647/resourceGroups/demo/providers/Microsoft.KeyVault/vaults/demo-kv-new"
},
"secretName": "appgwfesslcert"
}
}
},
"appgwbecertsecret": {
"value": {
"reference": {
"keyVault": {
"id": "/subscriptions/105dcee5-gy46-48e3-9046-265c7379e647/resourceGroups/demo/providers/Microsoft.KeyVault/vaults/demo-kv-new"
},
"secretName": "appgwbecert"
}
}
}
}
}
you can only reference KV secrets in the parameters section of the template (or parameters file). You cannot use it in a random place in the template
https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-tutorial-use-key-vault

Azure GovCloud Template Error

I am using this template enter link description here and I been working through it to convert it from stock to something I can use in the Azure Government Cloud. I am almost complete but I keep getting this last error that I do not know how to rectify. Maybe someone here with more json experience than I do can find this fix simply.
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"uniquePrefix": {
"type": "string",
"metadata": {
"description": "This unique prefix will be used on all the objects created as part of this template."
}
},
"transferVMSize": {
"type": "string",
"defaultValue": "Standard_D4",
"allowedValues": [
"Standard_A4",
"Standard_A7",
"Standard_D4",
"Standard_D14",
"Standard_D2s_v3"
],
"metadata": {
"description": "Size of the VM used to transfer the VM image to various storage accounts."
}
},
"computeVMSize": {
"type": "string",
"defaultValue": "Standard_A1",
"allowedValues": [
"Standard_A1",
"Standard_A2",
"Standard_A3",
"Standard_A4",
"Standard_A5",
"Standard_A6",
"Standard_A7",
"Standard_A8",
"Standard_A9",
"Standard_A10",
"Standard_A11",
"Standard_D1",
"Standard_D2",
"Standard_D3",
"Standard_D3_v2",
"Standard_D4",
"Standard_D4_v2",
"Standard_D5_v2",
"Standard_D11",
"Standard_D12",
"Standard_D12_v2",
"Standard_D13",
"Standard_D13_v2",
"Standard_D14",
"Standard_D14_v2",
"Standard_DS3",
"Standard_DS4",
"Standard_DS12",
"Standard_DS13",
"Standard_DS14",
"Standard_G2",
"Standard_G3",
"Standard_G4",
"Standard_G5",
"Standard_GS2",
"Standard_GS3",
"Standard_GS4",
"Standard_GS5",
"Standard_D2s_v3"
],
"metadata": {
"description": "Size of the VMs to be used for actual computation."
}
},
"computeOSType": {
"type": "string",
"defaultValue": "Linux",
"allowedValues": [
"Linux",
"Windows"
],
"metadata": {
"description": "Compute OS Type"
}
},
"deploymentType": {
"type": "string",
"defaultValue": "VMSS",
"allowedValues": [
"VMSS",
"Single",
"SingleAV"
],
"metadata": {
"description": "This determines whether the VMs will be deployed using scale sets, as individual VMs, or individual VMs in an availability set (maximum 100 for the last option)."
}
},
"numberOfSAs": {
"type": "int",
"metadata": {
"description": "Number of Storage Accounts to upload the custom image to."
}
},
"instanceCountPerSA": {
"type": "int",
"maxValue": 40,
"metadata": {
"description": "Number of VMs per Storage Account."
}
},
"imageLocation": {
"type": "string",
"metadata": {
"description": "URL of the base custom image, in the format of https://accountname.blob.core.windows.net/container/image.vhd."
}
},
"storageAccountKey": {
"type": "securestring",
"metadata": {
"description": "Storage Account key for accessing the base custom image."
}
},
"adminUsername": {
"type": "string",
"metadata": {
"description": "Admin username for the VMs in the deployment."
}
},
"adminPassword": {
"type": "securestring",
"metadata": {
"description": "Admin password for the VMs in the deployment."
}
}
},
"variables": {
"vnetName": "[concat(parameters('uniquePrefix'), 'vnet')]",
"addressPrefix": "10.0.0.0/16",
"subnetName": "subnet",
"subnetPrefix": "10.0.0.0/21",
"transferImagePublisher": "Canonical",
"transferImageOffer": "UbuntuServer",
"ubuntuOSVersion": "16.04-LTS",
"imagePieces": "[split(parameters('imageLocation'),'/')]",
"blobName": "blob.core.usgovcloudapi.net",
"templateLocation": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/301-custom-images-at-scale/",
"sharedResourcesTemplateUri ": "[concat(variables('templateLocation'), 'shared-resources.json')]",
"finalTemplateUri": "[concat(variables('templateLocation'), 'final_')]",
"downloadTemplateURI": "[concat(variables('templateLocation'), 'download.json')]",
"downloadScriptURI": "[concat(variables('templateLocation'), 'download.sh')]",
"uploadTemplateURI": "[concat(variables('templateLocation'), 'upload.json')]",
"uploadScriptURI": "[concat(variables('templateLocation'), 'upload.sh')]",
"vmStorageAccountContainerName": "transfertestsa",
"OSDiskName": "transfertestvm",
"StorageAccountName": "transfertest"
},
"resources": [{
"name": "[concat(parameters('uniquePrefix'), 'base')]",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('sharedResourcesTemplateUri ')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"uniquePrefix": {
"value": "[parameters('uniquePrefix')]"
},
"numberOfSAs": {
"value": "[parameters('numberOfSAs')]"
},
"vnetName": {
"value": "[variables('vnetName')]"
},
"addressPrefix": {
"value": "[variables('addressPrefix')]"
},
"subnetName": {
"value": "[variables('subnetName')]"
},
"subnetPrefix": {
"value": "[variables('subnetPrefix')]"
}
}
}
},
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[concat('transfer', parameters('uniquePrefix'), 'sa')]",
"apiVersion": "2015-05-01-preview",
"location": "[resourceGroup().location]",
"properties": {
"accountType": "Standard_LRS"
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[concat('transfer', parameters('uniquePrefix'), 'ip')]",
"location": "[resourceGroup().location]",
"properties": {
"publicIPAllocationMethod": "Dynamic"
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/networkInterfaces",
"name": "[concat('transfer', parameters('uniquePrefix'), 'nic')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/transfer', parameters('uniquePrefix'), 'ip')]",
"[concat('Microsoft.Resources/deployments/', parameters('uniquePrefix'), 'base')]"
],
"properties": {
"ipConfigurations": [{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', concat('transfer', parameters('uniquePrefix'), 'ip'))]"
},
"subnet": {
"id": "[concat('/subscriptions/', subscription().subscriptionId,'/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Network/virtualNetworks/', variables('vnetName'), '/subnets/', variables('subnetName'))]"
}
}
}]
}
},
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Compute/virtualMachines",
"name": "[concat('transfer', parameters('uniquePrefix'), 'vm')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/transfer', parameters('uniquePrefix'), 'sa')]",
"[concat('Microsoft.Network/networkInterfaces/transfer', parameters('uniquePrefix'), 'nic')]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('transferVMSize')]"
},
"osProfile": {
"computerName": "[concat('transfer', parameters('uniquePrefix'), 'vm')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"publisher": "[variables('transferImagePublisher')]",
"offer": "[variables('transferImageOffer')]",
"sku": "[variables('ubuntuOSVersion')]",
"version": "latest"
},
"osDisk": {
"name": "osdisk",
"vhd": {
"uri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/',variables('vmStorageAccountContainerName'),''), '2015-06-15').primaryEndpoints.blob,'vhds/',variables('OSDiskName'),'-osdisk.vhd')]"
},
"caching": "ReadWrite",
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaces": [{
"id": "[resourceId('Microsoft.Network/networkInterfaces', concat('transfer', parameters('uniquePrefix'), 'nic'))]"
}]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": "true",
"storageUri": "[concat('http://transfer',parameters('uniquePrefix'),'sa.blob.core.usgovcloudapi.net')]"
}
}
}
},
{
"name": "[concat(parameters('uniquePrefix'), 'script0')]",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/transfer', parameters('uniquePrefix'), 'vm')]"
],
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('downloadTemplateURI')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"uniquePrefix": {
"value": "[parameters('uniquePrefix')]"
},
"imageLocation": {
"value": "[parameters('imageLocation')]"
},
"storageAccountKey": {
"value": "[parameters('storageAccountKey')]"
},
"downloadScriptURI": {
"value": "[variables('downloadScriptURI')]"
}
}
}
},
{
"name": "[concat(parameters('uniquePrefix'), 'script', string(add(copyIndex(), 1)))]",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"dependsOn": [
"[concat('Microsoft.Resources/deployments/', parameters('uniquePrefix'), 'script', copyIndex())]"
],
"copy": {
"name": "uploadLoop",
"count": "[parameters('numberOfSAs')]"
},
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('uploadTemplateURI')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"uniquePrefix": {
"value": "[parameters('uniquePrefix')]"
},
"index": {
"value": "[copyIndex()]"
},
"uploadScriptURI": {
"value": "[variables('uploadScriptURI')]"
}
}
}
},
{
"name": "[concat(parameters('uniquePrefix'), 'full')]",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"dependsOn": [
"uploadLoop"
],
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[concat(variables('finalTemplateUri'), parameters('deploymentType'), '.json')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"uniquePrefix": {
"value": "[parameters('uniquePrefix')]"
},
"numberOfSAs": {
"value": "[parameters('numberOfSAs')]"
},
"instanceCountPerSA": {
"value": "[parameters('instanceCountPerSA')]"
},
"vmSize": {
"value": "[parameters('computeVMSize')]"
},
"OSType": {
"value": "[parameters('computeOSType')]"
},
"blobName": {
"value": "[variables('blobName')]"
},
"vnetName": {
"value": "[variables('vnetName')]"
},
"addressPrefix": {
"value": "[variables('addressPrefix')]"
},
"subnetName": {
"value": "[variables('subnetName')]"
},
"subnetPrefix": {
"value": "[variables('subnetPrefix')]"
},
"templateLocation": {
"value": "[variables('templateLocation')]"
},
"adminUsername": {
"value": "[parameters('adminUsername')]"
},
"adminPassword": {
"value": "[parameters('adminPassword')]"
}
}
}
}
]
}
The above is what I am using to launch my template and attached are the parameters that I am inputting and the error message I receive. enter image description hereenter image description here
I fixed the error by forking the script to my own repo and changing every occurrence of the blob reference to gov cloud in all the files needed for that script.

Error creating JSON Unexpected Character Sequence

I've been trying to create a basic json for our testes to throw up a machine a and when required. I got most of it done however I am getting the following errors:
Line 158 Unexpected character sequence in member name
Line 167 A member with the name 'Properties' already exists
I understand 67 needs to be unique, but everytime I change and remove the { it creates more errors.
And unexpected character is the { on line 157, which I'm guessing should be either a string, maybe?
My template is below.
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string"
},
"virtualMachineName": {
"type": "string"
},
"offer": {
"type": "string",
"defaultvalue": "Windows",
"allowedValues": [
"windows",
"centos",
"RHEL"
]
},
"sku": {
"type": "string",
"defaultvalue": "2012-r2-datacenter",
"allowedValues": [
"2012-R2-Datacenter",
"2012-R2",
"68",
"72",
"73",
"74"
]
},
"virtualMachineSize": {
"type": "string",
"defaultvalue": "standard_A0",
"allowedValues": [
"Standard_A0",
"Standard_A1",
"standard_A2"
]
},
"adminUsername": {
"type": "string"
},
"ipaddress": {
"type": "string"
},
"virtualNetworkName": {
"type": "string"
},
"networkInterfaceName": {
"type": "string"
},
"networkSecurityGroupName": {
"type": "string"
},
"adminPassword": {
"type": "securestring"
},
"storageAccountName": {
"type": "string"
},
"diagnosticsStorageAccountName": {
"type": "string"
},
"diagnosticsStorageAccountId": {
"type": "string"
},
"subnetName": {
"type": "string"
},
"ContainerName": {
"type": "string"
},
"autoShutdownStatus": {
"type": "string"
},
"autoShutdownTime": {
"type": "string"
},
"autoShutdownTimeZone": {
"type": "string"
},
"autoShutdownNotificationStatus": {
"type": "string"
}
},
"variables": {
"vnetId": "[resourceId('avset','Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]",
"subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]",
"stdvhdcontainername": "[concat(parameters('Containername'))]",
"vmosidiskname": "[concat(parameters('virtualMachineName'),'-osdisk')]"
},
"resources": [
{
"name": "[parameters('virtualMachineName')]",
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2016-04-30-preview",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName'))]"
],
"properties": {
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "[concat (parameters('diagnosticsStorageAccountName')), ['blob']]"
}
},
"hardwareProfile": {
"vmSize": "[parameters('virtualMachineSize')]"
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaceName'))]"
}
]
},
"osProfile": {
"computerName": "[parameters('virtualMachineName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"offer": "[concat(parameters('offer'))]",
"sku": "[concat(parameters('offer'))]",
"version": "latest"
}
},
"osDisk": {
"vhd": {
"name": "[variables('vmosidiskname')]",
"uri": "[concat('http://', parameters('storageAccountName'), '.blob.core.windows.net/', variables('stdvhdcontainername'),'/', variables('vmosidiskname'), '.vhd')]"
},
"name": "[parameters('virtualMachineName')]"
},
"name": "[concat('shutdown-computevm-', parameters('virtualMachineName'))]",
"type": "Microsoft.DevTestLab/schedules",
"apiVersion": "2017-04-26-preview",
"location": "[parameters('location')]",
"properties": {
"status": "[parameters('autoShutdownStatus')]",
"taskType": "ComputeVmShutdownTask",
"dailyRecurrence": {
"time": "[parameters('autoShutdownTime')]"
},
"timeZoneId": "[parameters('autoShutdownTimeZone')]",
"targetResourceId": "[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachineName'))]",
"notificationSettings": {
"status": "[parameters('autoShutdownNotificationStatus')]",
"timeInMinutes": "30"
},
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]"
]
},
{
"name": "[parameters('networkInterfaceName')]",
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2016-09-01",
"location": "[parameters('location')]"
},
"dependsOn": [
"[concat('Microsoft.Network/networkSecurityGroups/', parameters('networkSecurityGroupName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"subnet": {
"id": "[variables('subnetRef')]"
},
"privateipaddress": "[concat(parameters('ipaddress'))]",
"privateIPAllocationMethod": "static"
}
}
]
}
},
"outputs": [
{
"adminUsername": {
"type": "string",
"value": "[parameters('adminUsername')]"
}
}
]
}
]
}
Any pointers would be greatly appreciated.. thanks for your help :)
Params are below:)
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"value": "westeurope"
},
"virtualMachineName": {
"value": "cent-os-vm2"
},
"virtualMachineSize": {
"value": "Standard_A0"
},
"adminUsername": {
"value": "localadmin"
},
"virtualNetworkName": {
"value": "avset-vnet"
},
"networkInterfaceName": {
"value": "cent-os-vm01652"
},
"networkSecurityGroupName": {
"value": "cent-os-vm01-nsg"
},
"storageAccountName": {
"value": "avsetdisks419"
},
"diagnosticsStorageAccountName": {
"value": "avsetdiag112"
},
"diagnosticsStorageAccountId": {
"value": "avsetdiag117"
},
"subnetName": {
"value": "default"
},
"autoShutdownStatus": {
"value": "Enabled"
},
"autoShutdownTime": {
"value": "19:00"
},
"autoShutdownTimeZone": {
"value": "UTC"
},
"autoShutdownNotificationStatus": {
"value": "Disabled"
},
"ContainerName": {
"value": "vhd"
},
"offer": {
"value": "windows"
},
"sku": {
"value": "2012-R2-Datacenter"
},
"ipaddress": {
"value": "10.0.1.9"
}
}
}
There are many mistakes in your template. The following template should work.
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string"
},
"virtualMachineName": {
"type": "string"
},
"offer": {
"type": "string",
"defaultvalue": "windows",
"allowedValues": [
"windows",
"centos",
"RHEL"
]
},
"sku": {
"type": "string",
"defaultvalue": "2012-R2-Datacenter",
"allowedValues": [
"2012-R2-Datacenter",
"2012-R2",
"68",
"72",
"73",
"74"
]
},
"virtualMachineSize": {
"type": "string",
"defaultvalue": "Standard_A0",
"allowedValues": [
"Standard_A0",
"Standard_A1",
"standard_A2"
]
},
"adminUsername": {
"type": "string"
},
"ipaddress": {
"type": "string"
},
"virtualNetworkName": {
"type": "string"
},
"networkInterfaceName": {
"type": "string"
},
"networkSecurityGroupName": {
"type": "string"
},
"adminPassword": {
"type": "securestring"
},
"storageAccountName": {
"type": "string"
},
"diagnosticsStorageAccountName": {
"type": "string"
},
"diagnosticsStorageAccountId": {
"type": "string"
},
"subnetName": {
"type": "string"
},
"ContainerName": {
"type": "string"
},
"autoShutdownStatus": {
"type": "string"
},
"autoShutdownTime": {
"type": "string"
},
"autoShutdownTimeZone": {
"type": "string"
},
"autoShutdownNotificationStatus": {
"type": "string"
}
},
"variables": {
"vnetId": "[resourceId('avset','Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]",
"subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]",
"stdvhdcontainername": "[concat(parameters('Containername'))]",
"vmosidiskname": "[concat(parameters('virtualMachineName'),'-osdisk')]"
},
"resources": [
{
"name": "[parameters('virtualMachineName')]",
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2016-04-30-preview",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName'))]"
],
"properties": {
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "[concat (parameters('diagnosticsStorageAccountName')), ['blob']]"
}
},
"hardwareProfile": {
"vmSize": "[parameters('virtualMachineSize')]"
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaceName'))]"
}
]
},
"osProfile": {
"computerName": "[parameters('virtualMachineName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"offer": "[concat(parameters('offer'))]",
"sku": "[concat(parameters('offer'))]",
"version": "latest"
}
},
"osDisk": {
"vhd": {
"name": "[variables('vmosidiskname')]",
"uri": "[concat('http://', parameters('storageAccountName'), '.blob.core.windows.net/', variables('stdvhdcontainername'),'/', variables('vmosidiskname'), '.vhd')]"
},
"name": "[parameters('virtualMachineName')]"
}
}
},
{
"name": "[concat('shutdown-computevm-', parameters('virtualMachineName'))]",
"type": "Microsoft.DevTestLab/schedules",
"apiVersion": "2017-04-26-preview",
"location": "[parameters('location')]",
"properties": {
"status": "[parameters('autoShutdownStatus')]",
"taskType": "ComputeVmShutdownTask",
"dailyRecurrence": {
"time": "[parameters('autoShutdownTime')]"
},
"timeZoneId": "[parameters('autoShutdownTimeZone')]",
"targetResourceId": "[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachineName'))]",
"notificationSettings": {
"status": "[parameters('autoShutdownNotificationStatus')]",
"timeInMinutes": "30"
},
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]"
]
}
},
{
"name": "[parameters('networkInterfaceName')]",
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2016-09-01",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/networkSecurityGroups/', parameters('networkSecurityGroupName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"subnet": {
"id": "[variables('subnetRef')]"
},
"privateipaddress": "[concat(parameters('ipaddress'))]",
"privateIPAllocationMethod": "static"
}
}
]
}
}
],
"outputs": {
"adminUsername": {
"type": "string",
"value": "[parameters('adminUsername')]"
}
}
}
In line 162, it lost a ,. Resource Microsoft.Compute/virtualMachines,Microsoft.DevTestLab/schedules,Microsoft.Network/networkInterfaces are in parallel. But in your template, Microsoft.Compute/virtualMachines contains others, so you get error log with the name 'Properties' already exists.
Note: You also need check your default value. Please note that case sensitive.
Update:
Ipconfigurations is wrong, it should like below:
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
},
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
Update 2:
The template.json and parameters.json works for me. Maybe you could modify your template according to this example.

WebServerInstance Encountered unsupported property VpcId

I keep getting this issue in the Webserversinstance.
*Paramaters*
VPCSelection": {
"Description": "VPC",
"Type": "String",
"Default": "vpc-xxxxxxx"
*Webserver Security group*
"Resources": {
"WebServerSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"VpcId": {
"Ref": "VPCSelection"
},
*WebServer Instance*
{
"Resources": {
"WebServerSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"VpcId": {
"Ref": "VPCSelection"
},
When i run this template, i get this issue:
12:45:52 UTC+0000 ROLLBACK_IN_PROGRESS AWS::CloudFormation::Stack Test13 The following resource(s) failed to create: [WebServerInstance]. . Rollback requested by user.
12:45:51 UTC+0000 CREATE_FAILED AWS::EC2::Instance WebServerInstance Encountered unsupported property VpcId
When i remove this VPCid from the webserver instance i get a different error saying: AWS::EC2::Instance WebServerInstance No default VPC for this user
I put this into Bisque and got the below. Does this help?
{
"Resources": {
"WebServerSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Metadata": {
"YadaYada::Bisque::DotnetType": {
"Type": "Bisque.EC2.Networking.SecurityGroup, Bisque.Aws, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
}
},
"Properties": {
"GroupDescription": {
"Ref": "WebServerSecurityGroupGroupDescription"
},
"VpcId": {
"Ref": "VPCSelection"
},
"Tags": [
{
"Key": "Name",
"Value": "WebServerSecurityGroup"
}
]
}
},
"WebServerInstance": {
"Type": "AWS::EC2::Instance",
"Metadata": {
"YadaYada::Bisque::DotnetType": {
"Type": "Bisque.EC2.Instances.Instance, Bisque.Aws, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
},
"AWS::CloudFormation::Init": {
"configSets": {
"Bootstrap": [
"Bootstrap"
]
},
"Bootstrap": {
"services": {
"windows": {
"cfn-hup": {
"ensureRunning": true,
"enabled": true,
"files": [
"c:\\cfn\\hooks.d\\cfn-auto-reloader.conf",
"c:\\cfn\\cfn-hup.conf"
]
}
}
},
"files": {
"c:\\cfn\\hooks.d\\cfn-auto-reloader.conf": {
"content": {
"Fn::Join": [
"\n",
[
"[cfn-auto-reloader-hook]",
"triggers=post.update",
"path=Resources.WebServerInstance.Metadata.AWS::CloudFormation::Init",
{
"Fn::Join": [
"",
[
"action=",
{
"Fn::Join": [
"",
[
"cfn-init.exe -v -c \"",
"Bootstrap",
"\" -s ",
{
"Ref": "AWS::StackId"
},
" -r WebServerInstance --region ",
{
"Ref": "AWS::Region"
}
]
]
}
]
]
}
]
]
}
},
"c:\\cfn\\cfn-hup.conf": {
"content": {
"Fn::Join": [
"\n",
[
"[main]",
{
"Fn::Join": [
"",
[
"stack=",
{
"Ref": "AWS::StackName"
}
]
]
},
{
"Fn::Join": [
"",
[
"region=",
{
"Ref": "AWS::Region"
}
]
]
},
"interval=1",
"verbose=true"
]
]
}
}
}
}
}
},
"Properties": {
"SecurityGroupIds": [
{
"Ref": "WebServerSecurityGroup"
}
],
"Tags": [
{
"Key": "Name",
"Value": "WebServerInstance"
}
],
"ImageId": {
"Ref": "WebServerInstanceImageId"
},
"InstanceType": {
"Ref": "WebServerInstanceInstanceType"
},
"KeyName": {
"Ref": "WebServerInstanceKeyName"
},
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"",
[
"<script>",
{
"Fn::Join": [
"",
[
"cfn-init.exe -v -c \"",
"Bootstrap",
"\" -s ",
{
"Ref": "AWS::StackId"
},
" -r WebServerInstance --region ",
{
"Ref": "AWS::Region"
}
]
]
},
"</script>"
]
]
}
}
}
}
},
"Parameters": {
"VPCSelection": {
"Type": "AWS::EC2::VPC::Id"
},
"WebServerSecurityGroupGroupDescription": {
"Type": "String"
},
"WebServerInstanceImageId": {
"Type": "AWS::EC2::Image::Id"
},
"WebServerInstanceInstanceType": {
"Type": "String",
"Default": "t2.micro",
"AllowedValues": [
"",
"t2.nano",
"t2.micro",
"t2.small",
"t2.medium",
"t2.large",
"t2.xlarge",
"t2.2xlarge",
"m4.large",
"m4.xlarge",
"m4.2xlarge",
"m4.4xlarge",
"m4.10xlarge",
"m3.medium",
"m3.large",
"m3.xlarge",
"m3.2xlarge",
"m1.small",
"m1.medium",
"m1.large",
"m1.xlarge",
"c4.large",
"c4.xlarge",
"c4.2xlarge",
"c4.4xlarge",
"c4.8xlarge",
"c3.large",
"c3.xlarge",
"c3.2xlarge",
"c3.4xlarge",
"c3.8xlarge",
"c1.medium",
"c1.xlarge",
"cc2.8xlarge",
"cc1.4xlarge",
"g2.2xlarge",
"g2.8xlarge",
"cg1.4xlarge",
"r3.large",
"r3.xlarge",
"r3.2xlarge",
"r3.4xlarge",
"r3.8xlarge",
"x1.32xlarge",
"m2.xlarge",
"m2.2xlarge",
"m2.4xlarge",
"cr1.8xlarge",
"d2.xlarge",
"d2.2xlarge",
"d2.4xlarge",
"d2.8xlarge",
"i2.xlarge",
"i2.2xlarge",
"i2.4xlarge",
"i2.8xlarge",
"hi1.4xlarge",
"hs1.8xlarge",
"t1.micro"
]
},
"WebServerInstanceKeyName": {
"Type": "AWS::EC2::KeyPair::KeyName",
"Default": "default"
}
},
"Metadata": {
"AWS::CloudFormation::Interface": {
"Key": "AWS::CloudFormation::Interface",
"ParameterGroups": [
{
"Label": {
"default": "WebServerSecurityGroup Properties"
},
"Parameters": [
"WebServerSecurityGroupGroupDescription"
]
},
{
"Label": {
"default": "WebServerInstance Properties"
},
"Parameters": [
"WebServerInstanceImageId",
"WebServerInstanceInstanceType",
"WebServerInstanceKeyName"
]
}
],
"ParameterLabels": {
"WebServerSecurityGroupGroupDescription": {
"default": "Description"
},
"WebServerInstanceImageId": {
"default": "Image Id (AMI)"
},
"WebServerInstanceInstanceType": {
"default": "Instance Size"
},
"WebServerInstanceKeyName": {
"default": "Key Name"
}
}
}
}
}