Unable to install LAD 3.0 extension - arm-template

I'm trying to install Azure LAD 3.0 agent for this linux vm using ARM template. While enabling the extension, I want to enable the agent and want Metrics to be selected NONE, only syslog should be enabled and routed to the specified storage account. I have followed the https://learn.microsoft.com/en-us/azure/virtual-machines/extensions/diagnostics-linux#public-settings page and almost have all the mandatory fields in the template still cant identify the issue. Based on that doc, You must specify either performanceCounters or syslogEvents or both. You must specify the metrics structure - but this not needed in my case and i have not given performanceCounters which needed for metrics also.
The problem is, it is throwing that error Extension operation Enable failed:'NoneType' object has no attribute 'get_fluentd_syslog_src_config' and not enabling the diagnostics extension. The issue might be with Linux Diagnostic extension schema settings where i'm trying to make modifications but couldn't figure out why exactly it is failing.
NOTE: I'm able to modify the Windows diagnostics extension schema and can enable the agent with the specific logs selected.
Anyone succeeded on this ? below is my resources part.
"resources": [
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2017-12-01",
"name": "[concat(parameters('vmName'), '/Microsoft.Insights.VMDiagnosticSettings')]",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "AzureDiagnostics"
},
"properties": {
"publisher": "Microsoft.Azure.Diagnostics",
"type": "LinuxDiagnostic",
"autoUpgradeMinorVersion": true,
"typeHandlerVersion": "3.0",
"protectedSettings": {
"storageAccountName": "[parameters('existingdiagnosticsStorageAccountName')]",
"storageAccountKey": "[listkeys(variables('accountid'), '2015-05-01-preview').key1]",
"storageAccountEndPoint": "https://core.windows.net"
},
"settings": {
"StorageAccount": "[parameters('existingdiagnosticsStorageAccountName')]",
"ladCfg": {
"diagnosticMonitorConfiguration": {
"eventVolume": "Medium",
"syslogEvents": {
"syslogEventConfiguration": {
"LOG_AUTH": "LOG_DEBUG",
"LOG_AUTHPRIV": "LOG_DEBUG",
"LOG_CRON": "LOG_DEBUG",
"LOG_DAEMON": "LOG_DEBUG",
"LOG_FTP": "LOG_DEBUG",
"LOG_KERN": "LOG_DEBUG",
"LOG_LOCAL0": "LOG_DEBUG",
"LOG_LOCAL1": "LOG_DEBUG",
"LOG_LOCAL2": "LOG_DEBUG",
"LOG_LOCAL3": "LOG_DEBUG",
"LOG_LOCAL4": "LOG_DEBUG",
"LOG_LOCAL5": "LOG_DEBUG",
"LOG_LOCAL6": "LOG_DEBUG",
"LOG_LOCAL7": "LOG_DEBUG",
"LOG_LPR": "LOG_DEBUG",
"LOG_MAIL": "LOG_DEBUG",
"LOG_NEWS": "LOG_DEBUG",
"LOG_SYSLOG": "LOG_DEBUG",
"LOG_USER": "LOG_DEBUG",
"LOG_UUCP": "LOG_DEBUG"
}
}
},
"sampleRateInSeconds": 15
}
}
}
}
]

I'm answering my own question here. I have made some changes in the ARM template and i was able to deploy the extension for Debian based OS.
below is my altered Resources part in the ARM template
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2018-07-01",
"name": "[parameters('storageAccountName')]",
"location": "[resourceGroup().location]",
"sku": {
"name": "Standard_LRS"
},
"kind": "StorageV2"
},
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2017-12-01",
"name": "[concat(parameters('vmName'), '/Microsoft.Insights.VMDiagnosticSettings')]",
"location": "[resourceGroup().location]",
"tags": {
"Creator": "[parameters('tags')]"
},
"properties": {
"publisher": "Microsoft.Azure.Diagnostics",
"type": "LinuxDiagnostic",
"autoUpgradeMinorVersion": true,
"typeHandlerVersion": "3.0",
"protectedSettings": {
"storageAccountName": "[parameters('storageAccountName')]",
"storageAccountSasToken": "[listAccountSas(parameters('storageAccountName'), '2018-07-01', parameters('accountSasProperties')).accountSasToken]"
},
"settings": {
"StorageAccount": "[parameters('storageAccountName')]",
"ladCfg": {
"diagnosticMonitorConfiguration": {
"eventVolume": "Medium",
"metrics": {
"metricAggregation": [],
"resourceId": "[resourceId('Microsoft.Compute/virtualMachines', parameters('vmName'))]"
},
"performanceCounters": {
"performanceCounterConfiguration": []
},
"syslogEvents": {
"syslogEventConfiguration": {
"LOG_AUTH": "LOG_DEBUG",
"LOG_AUTHPRIV": "LOG_DEBUG",
"LOG_CRON": "LOG_DEBUG",
"LOG_DAEMON": "LOG_DEBUG",
"LOG_FTP": "LOG_DEBUG",
"LOG_KERN": "LOG_DEBUG",
"LOG_LOCAL0": "LOG_DEBUG",
"LOG_LOCAL1": "LOG_DEBUG",
"LOG_LOCAL2": "LOG_DEBUG",
"LOG_LOCAL3": "LOG_DEBUG",
"LOG_LOCAL4": "LOG_DEBUG",
"LOG_LOCAL5": "LOG_DEBUG",
"LOG_LOCAL6": "LOG_DEBUG",
"LOG_LOCAL7": "LOG_DEBUG",
"LOG_LPR": "LOG_DEBUG",
"LOG_MAIL": "LOG_DEBUG",
"LOG_NEWS": "LOG_DEBUG",
"LOG_SYSLOG": "LOG_DEBUG",
"LOG_USER": "LOG_DEBUG",
"LOG_UUCP": "LOG_DEBUG"
}
}
},
"sampleRateInSeconds": 15
}
}
}
}
]
}

Related

Can public IP of VMScaleset instance be modified with static IP from a given public IpPrefix?

I have a requirement to update/set public IP address of VMScaleset instances from a given IpPublicPrefix(for customer to whitelist these IPs).
I've tried creating VMScaleset with two instances (with a Virtual Network, SubNet, Network Interface) and PublicIpPrefix but the code suggested from Azure doc is not working at all.
https://learn.microsoft.com/en-us/powershell/module/azurerm.network/set-azurermnetworkinterface?view=azurermps-6.13.0
First issue: below code does not return the Network Interface I created above. Is this bug in Azure API?
Get-AzureRmNetworkInterface -ResourceGroupName "ResourceGroup1" -Name "NetworkInterface1"
It only returns list of Network Interfaces which were created for VM(created not from VMSS), it does not include Network Interface which were created during VMSS creation.
Second Issue: Per some comments here and there, NetworkInterface for VMSS will not display in Azure Portal (search for Network Interfaces) nor AzureRM API then how do we suppose to know and update NIC for a VMSS or its instances?
I have been using AzureRm module 6.13.1
For the first issue, the public IP of the scale set instances is not a separate resource in the Azure portal, we can not use Get-AzureRmNetworkInterface to get the network interface information.
For the second issue, you can create a scale set with public IP per virtual machine by ARM template. You can add a publicIpAddressConfiguration JSON property to the scale set ipConfigurations section.
Note that IpPublicPrefix requires a standard SKU load balancer and public IP address. Here is a working sample.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmSku": {
"type": "string",
"defaultValue": "Standard_A1_v2",
"metadata": {
"description": "Size of VMs in the VM Scale Set."
}
},
"windowsOSVersion": {
"type": "string",
"defaultValue": "2019-Datacenter",
"allowedValues": [
"2008-R2-SP1",
"2012-Datacenter",
"2012-R2-Datacenter",
"2016-Datacenter",
"2019-Datacenter"
],
"metadata": {
"description": "The Windows version for the VM. This will pick a fully patched image of this given Windows version. Allowed values: 2008-R2-SP1, 2012-Datacenter, 2012-R2-Datacenter & 2016-Datacenter, 2019-Datacenter."
}
},
"vmssName": {
"type": "string",
"minLength": 3,
"maxLength": 61,
"metadata": {
"description": "String used as a base for naming resources. Must be 3-61 characters in length and globally unique across Azure. A hash is prepended to this string for some resources, and resource-specific information is appended."
}
},
"instanceCount": {
"type": "int",
"defaultValue": 3,
"minValue": 1,
"maxValue": 100,
"metadata": {
"description": "Number of VM instances (100 or less)."
}
},
"singlePlacementGroup": {
"type": "bool",
"defaultValue": true,
"metadata": {
"description": "When true this limits the scale set to a single placement group, of max size 100 virtual machines. NOTE: If singlePlacementGroup is true, it may be modified to false. However, if singlePlacementGroup is false, it may not be modified to true."
}
},
"adminUsername": {
"type": "string",
"defaultValue": "vmssadmin",
"metadata": {
"description": "Admin username on all VMs."
}
},
"adminPassword": {
"type": "securestring",
"metadata": {
"description": "Admin password on all VMs."
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
},
"platformFaultDomainCount": {
"type": "int",
"defaultValue": 1,
"metadata": {
"description": "Fault Domain count for each placement group."
}
},
"publicIPPrefixes_pubprefix_name": {
"defaultValue": "vmsspublicprefix",
"type": "string"
}
},
"variables": {
"namingInfix": "[toLower(substring(concat(parameters('vmssName'), uniqueString(resourceGroup().id)), 0, 9))]",
"longNamingInfix": "[toLower(parameters('vmssName'))]",
"addressPrefix": "10.0.0.0/16",
"subnetPrefix": "10.0.0.0/24",
"virtualNetworkName": "[concat(variables('namingInfix'), 'vnet')]",
"publicIPAddressName": "[concat(variables('namingInfix'), 'pip')]",
"subnetName": "[concat(variables('namingInfix'), 'subnet')]",
"loadBalancerName": "[concat(variables('namingInfix'), 'lb')]",
"publicIPAddressID": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]",
"lbProbeID": "[resourceId('Microsoft.Network/loadBalancers/probes',variables('loadBalancerName'), 'tcpProbe')]",
"natPoolName": "[concat(variables('namingInfix'), 'natpool')]",
"bePoolName": "[concat(variables('namingInfix'), 'bepool')]",
"lbPoolID": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools',variables('loadBalancerName'),variables('bePoolName'))]",
"natStartPort": 50000,
"natEndPort": 50119,
"natBackendPort": 3389,
"nicName": "[concat(variables('namingInfix'), 'nic')]",
"ipConfigName": "[concat(variables('namingInfix'), 'ipconfig')]",
"frontEndIPConfigID": "[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations',variables('loadBalancerName'),'loadBalancerFrontEnd')]",
"osType": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "[parameters('windowsOSVersion')]",
"version": "latest"
},
"imageReference": "[variables('osType')]"
},
"resources": [
{
"type": "Microsoft.Network/loadBalancers",
"apiVersion": "2020-06-01",
"name": "[variables('loadBalancerName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]"
],
"sku": {
"name": "Standard"
},
"properties": {
"frontendIPConfigurations": [
{
"name": "LoadBalancerFrontEnd",
"properties": {
"publicIPAddress": {
"id": "[variables('publicIPAddressID')]",
"name": "Standard"
}
}
}
],
"backendAddressPools": [
{
"name": "[variables('bePoolName')]"
}
],
"inboundNatPools": [
{
"name": "[variables('natPoolName')]",
"properties": {
"frontendIPConfiguration": {
"id": "[variables('frontEndIPConfigID')]"
},
"protocol": "Tcp",
"frontendPortRangeStart": "[variables('natStartPort')]",
"frontendPortRangeEnd": "[variables('natEndPort')]",
"backendPort": "[variables('natBackendPort')]"
}
}
],
"loadBalancingRules": [
{
"name": "LBRule",
"properties": {
"frontendIPConfiguration": {
"id": "[variables('frontEndIPConfigID')]"
},
"backendAddressPool": {
"id": "[variables('lbPoolID')]"
},
"protocol": "Tcp",
"frontendPort": 80,
"backendPort": 80,
"enableFloatingIP": false,
"idleTimeoutInMinutes": 5,
"probe": {
"id": "[variables('lbProbeID')]"
}
}
}
],
"probes": [
{
"name": "tcpProbe",
"properties": {
"protocol": "Tcp",
"port": 80,
"intervalInSeconds": 5,
"numberOfProbes": 2
}
}
]
}
},
{
"type": "Microsoft.Network/publicIPPrefixes",
"apiVersion": "2020-11-01",
"name": "[parameters('publicIPPrefixes_pubprefix_name')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard",
"tier": "Regional"
},
"properties": {
"prefixLength": 28,
"publicIPAddressVersion": "IPv4",
"ipTags": []
}
},
{
"type": "Microsoft.Compute/virtualMachineScaleSets",
"apiVersion": "2020-06-01",
"name": "[variables('namingInfix')]",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('vmSku')]",
"tier": "Standard",
"capacity": "[parameters('instanceCount')]"
},
"dependsOn": [
"[resourceId('Microsoft.Network/loadBalancers', variables('loadBalancerName'))]",
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]",
"[resourceId('Microsoft.Network/publicIPPrefixes',parameters('publicIPPrefixes_pubprefix_name'))]"
],
"properties": {
"overprovision": true,
"upgradePolicy": {
"mode": "Automatic"
},
"singlePlacementGroup": "[parameters('singlePlacementGroup')]",
"platformFaultDomainCount": "[parameters('platformFaultDomainCount')]",
"virtualMachineProfile": {
"storageProfile": {
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage"
},
"imageReference": "[variables('imageReference')]"
},
"osProfile": {
"computerNamePrefix": "[variables('namingInfix')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "[variables('nicName')]",
"properties": {
"primary": true,
"ipConfigurations": [
{
"name": "[variables('ipConfigName')]",
"properties": {
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]"
},
"loadBalancerBackendAddressPools": [
{
"id": "[variables('lbPoolID')]"
}
],
"loadBalancerInboundNatPools": [
{
"id": "[resourceId('Microsoft.Network/loadBalancers/inboundNatPools', variables('loadBalancerName'), variables('natPoolName'))]"
}
],
"publicipaddressconfiguration": {
"name": "pub1",
"properties": {
"idleTimeoutInMinutes": 15,
"publicIPAddressVersion": "IPv4",
"publicIPPrefix":{
"id": "[resourceId('Microsoft.Network/publicIPPrefixes',parameters('publicIPPrefixes_pubprefix_name'))]"
}
}
}
}
}
]
}
}
]
}
}
}
},
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2020-06-01",
"name": "[variables('publicIPAddressName')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard"
},
"properties": {
"publicIPAllocationMethod": "Static",
"dnsSettings": {
"domainNameLabel": "[variables('longNamingInfix')]"
}
}
},
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2020-06-01",
"name": "[variables('virtualNetworkName')]",
"location": "[parameters('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('addressPrefix')]"
]
},
"subnets": [
{
"name": "[variables('subnetName')]",
"properties": {
"addressPrefix": "[variables('subnetPrefix')]"
}
}
]
}
},
{
"type": "Microsoft.Insights/autoscaleSettings",
"apiVersion": "2015-04-01",
"name": "autoscalehost",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Compute/virtualMachineScaleSets/', variables('namingInfix'))]"
],
"properties": {
"name": "autoscalehost",
"targetResourceUri": "[resourceId('Microsoft.Compute/virtualMachineScaleSets', variables('namingInfix'))]",
"enabled": true,
"profiles": [
{
"name": "Profile1",
"capacity": {
"minimum": "1",
"maximum": "10",
"default": "1"
},
"rules": [
{
"metricTrigger": {
"metricName": "Percentage CPU",
"metricResourceUri": "[resourceId('Microsoft.Compute/virtualMachineScaleSets', variables('namingInfix'))]",
"timeGrain": "PT1M",
"statistic": "Average",
"timeWindow": "PT5M",
"timeAggregation": "Average",
"operator": "GreaterThan",
"threshold": 50
},
"scaleAction": {
"direction": "Increase",
"type": "ChangeCount",
"value": "1",
"cooldown": "PT5M"
}
},
{
"metricTrigger": {
"metricName": "Percentage CPU",
"metricResourceUri": "[resourceId('Microsoft.Compute/virtualMachineScaleSets', variables('namingInfix'))]",
"timeGrain": "PT1M",
"statistic": "Average",
"timeWindow": "PT5M",
"timeAggregation": "Average",
"operator": "LessThan",
"threshold": 30
},
"scaleAction": {
"direction": "Decrease",
"type": "ChangeCount",
"value": "1",
"cooldown": "PT5M"
}
}
]
}
]
}
}
]
}
Also, you can get the specified public IP address of an instance in a virtual machine scale set with the REST API.
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines/{virtualmachineIndex}/networkInterfaces/{networkInterfaceName}/ipconfigurations/{ipConfigurationName}/publicipaddresses/{publicIpAddressName}?api-version=2018-10-01

How to get VM's private IP from the virtual machine scale set using the ARM template?

I created an ARM template with a virtual machine scale set, Now I am stuck in my ARM template development because I couldn't get private IPs of the virtual machine created inside the scale set. Private IPs are required to update Cassandra seeds using extension scripts.
{
"type": "Microsoft.Compute/virtualMachineScaleSets",
"apiVersion": "2020-06-01",
"name": "[parameters('vmName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]",
"Microsoft.Compute/images/myCustomImage"
],
"identity": {
"type": "SystemAssigned"
},
"sku": {
"name": "[parameters('vmSku')]",
"tier": "Standard",
"capacity": "[parameters('instanceCount')]"
},
"properties": {
"overprovision": "false",
"upgradePolicy": {
"mode": "Manual"
},
"virtualMachineProfile": {
"storageProfile": {
"imageReference": {
"id": "[resourceId('Microsoft.Compute/images', 'myCustomImage')]"
}
},
"osProfile": {
"computerNamePrefix": "[parameters('vmName')]",
"customdata": "1",
"adminUsername": "centos",
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"ssh": {
"publicKeys": [
{
"path": "/home/centos/.ssh/authorized_keys",
"keyData": "xxxx"
}
]
}
}
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "[parameters('nicName')]",
"properties": {
"primary": true,
"ipConfigurations": [
{
"name": "[variables('ipConfigName')]",
"properties": {
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworkName'), 'cassandra')]"
}
}
}
]
}
}
]
}
}
}
}
How to get private IPs of VMs created within the scale set?
You can use the function reference to get the NIC resource of the VMSS instances. And the resource id of the instance NICs, look like this:
/subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}/virtualMachines/{instanceId}/networkInterfaces/{nicName}
So you can set the variables for each instance id and then get the private IP addresses, the part of the template looks like this:
"variables": {
"instanceNic-0": "[concat('/subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}/virtualMachines/0/networkInterfaces/', parameters('nicName'))]"
},
"outputs": {
"instanceNic-0-IP": {
"type": "string",
"value": "[reference(variables('instanceNic-0'), '2016-09-01').ipConfigurations[0].properties.privateIPAddress]"
}
}

How I can directly deploy ARM template as solution template in Azure marketplace

I have written code for ARM template which I've customized the parameters and installed the application on the server.
Now I wanted to Deploy this in the Azure marketplace as solution template what I need to do.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"adminUsername": {
"type": "string"
},
"adminPassword": {
"type": "string"
},
"envPrefixName": {
"type": "string",
"metadata": {
"description": "Prefix for the environment (2-5 characters)"
},
"defaultValue": "cust1",
"minLength": 2,
"maxLength": 11
}
},
"variables": {
"scriptURL": " https://raw.githubusercontent.com/rt7055/simpledevbox1/master/simpledevbox.ps1 ",
"VMname": "[parameters('envprefixName')]",
"storageAccountName": "[concat(uniqueString(resourceGroup().id),'storageaccountkatalyst')]",
"virtualNetworkName": "MyVNET",
"vnetAddressRange": "10.0.0.0/16",
"subnetAddressRange": "10.0.0.0/24",
"subnetName": "Subnet",
"subnetRef": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]",
"imagePublisher": "MicrosoftWindowsServer",
"imageOffer": "WindowsServer",
"imageSku": "2012-R2-Datacenter",
"publicIPAddressName": "mypublicIP",
"nicName": "myVMnic"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"apiversion": "2015-06-15",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "[variables('storageAccountName')]"
},
"properties": {
"accountType": "Standard_LRS"
}
},
{
"type": "Microsoft.Network/publicIPAddresses",
"name": "[variables('publicIPAddressName')]",
"location": "[resourceGroup().location]",
"apiVersion": "2018-10-01",
"properties": {
"publicIPAllocationMethod": "Dynamic"
}
},
{
"apiversion": "2017-06-01",
"type": "Microsoft.Network/virtualNetworks",
"name": "[variables('virtualNetworkName')]",
"location": "[resourceGroup().location]",
"tags": {
"displayname": "Virtual Networks"
},
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('vnetAddressRange')]"
]
},
"subnets": [
{
"name": "[variables('subnetName')]",
"properties": {
"addressPrefix": "[variables('subnetAddressRange')]"
}
}
]
}
},
{
"apiVersion": "2017-06-01",
"type": "Microsoft.Network/networkInterfaces",
"name": "[variables('nicName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]",
"[resourceId('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
],
"tags": {
"displayname": " Server Network Interface"
},
"properties": {
"ipConfigurations": [
{
"name": "Ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]"
},
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
]
}
},
{
"apiVersion": "2017-03-30",
"type": "Microsoft.Compute/virtualMachines",
"name": "[parameters('envprefixName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/',variables('storageAccountName'))]",
"[resourceId('Microsoft.Network/networkInterfaces/',variables('nicName'))]"
],
"tags": {
"displayname": "My Virtual Machine"
},
"properties": {
"hardwareProfile": {
"vmSize": "Standard_A1"
},
"osProfile": {
"computerName": "[variables('VMname')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"publisher": "[variables('imagePublisher')]",
"offer": "[variables('imageOffer')]",
"sku": "[variables('imageSku')]",
"version": "latest"
},
"osDisk": {
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "[concat('http://',variables('storageAccountName'),'.blob.core.windows.net')]"
}
}
},
"resources": [
{
"apiVersion": "2017-03-30",
"type": "extensions",
"name": "config-app",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/',variables('VMname'))]"
],
"tags": {
"displayName": "config-app"
},
"properties": {
"publisher": "Microsoft.Compute",
"type": "CustomScriptExtension",
"typeHandlerVersion": "1.9",
"autoUpgradeMinorVersion": true,
"settings": {
"fileUris": [
"[variables('scriptURL')]"
]
},
"protectedSettings": {
"commandToExecute": "[concat('powershell -ExecutionPolicy Unrestricted -File ', './simpledevbox.ps1')]"
}
}
}
]
}
]
}
I want to build a solution template for this or let me know how I can place this to the azure marketplace.
The marketplace is designed for Microsoft and Partners to deploy certified solutions to all Azure customers world-wide. Directions for publishing to the market place can be found here.
If you are looking to store a template just for your organization, you can save it to the portal. Directions can be found here.

Getting facts from an Azure VM with Ansible with Azure

I'm trying to have a single playbook that will create a VM in Azure and also run a playbook on it once it is created.
I can get the VM to be created but as the Public IP doesn't exist before it is created I can't use for the inventory. This is my current yaml:
---
- hosts: localhost
tasks:
- name: Create virtual network
azure_rm_virtualnetwork:
resource_group: az-test
name: az-test-vnet
address_prefixes: "10.43.0.0/16"
- name: Add subnet
azure_rm_subnet:
resource_group: az-test
name: az-test-subnet
address_prefix: "10.43.0.0/24"
virtual_network: az-test-vnet
- name: Create VM
azure_rm_virtualmachine:
resource_group: az-test
name: az-test-vm
vm_size: Standard_DS1_v2
admin_username: az-test
ssh_password_enabled: false
ssh_public_keys:
- path: /home/az-test/.ssh/authorized_keys
key_data: "ssh-rsa xxxx "
image:
offer: CentOS
publisher: OpenLogic
sku: '7.4'
version: latest
#- name: Get facts for all Public IPs within a resource groups
# azure_rm_publicip_facts:
# resource_group: az-test
The last bit there's an Ansible Azure module that should return all public IPs in the resource group but that fails.
Even if I could dynamically retrive the Public IP address, could the playbook even be run on it as ansible-playbook was initially only run on 'localhost' and the Public IP is not in the inventory?
Using latest of everything:
ansible 2.4.3.0
python 2.7
azure-cli-core-2.0.31
Apologies for the messy YAML formatting..
EDIT:
Can see Ansible is gathering facts that I can use but not exactly sure how to reference them?
"ansible_facts": {
"azure_vm": {
"id": "/subscriptions/x/resourceGroups/az-test/providers/Microsoft.Compute/virtualMachines/az-test",
"location": "eastus",
"name": "az-test",
"powerstate": "running",
"properties": {
"hardwareProfile": {
"vmSize": "Standard_DS1_v2"
},
"instanceView": {
"disks": [
{
"name": "az-test.vhd",
"statuses": [
{
"code": "ProvisioningState/succeeded",
"displayStatus": "Provisioning succeeded",
"level": "Info",
"time": "2018-04-16Tx"
}
]
}
],
"extensions": [
{
"name": "OmsAgentForLinux",
"statuses": [
{
"code": "ProvisioningState/succeeded",
"displayStatus": "Provisioning succeeded",
"level": "Info",
"message": "Enable succeeded"
}
],
"type": "Microsoft.EnterpriseCloud.Monitoring.OmsAgentForLinux",
"typeHandlerVersion": "1.4.60.2"
}
],
"statuses": [
{
"code": "ProvisioningState/succeeded",
"displayStatus": "Provisioning succeeded",
"level": "Info",
"time": "2018-04-16Tx"
},
{
"code": "PowerState/running",
"displayStatus": "VM running",
"level": "Info"
}
],
"vmAgent": {
"extensionHandlers": [
{
"status": {
"code": "ProvisioningState/succeeded",
"displayStatus": "Ready",
"level": "Info",
"message": "Plugin enabled"
},
"type": "Microsoft.EnterpriseCloud.Monitoring.OmsAgentForLinux",
"typeHandlerVersion": "1.4.60.2"
}
],
"statuses": [
{
"code": "ProvisioningState/succeeded",
"displayStatus": "Ready",
"level": "Info",
"message": "Guest Agent is running",
"time": "2018-04-16Tx"
}
],
"vmAgentVersion": "2.2.25"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "/subscriptions/x/resourceGroups/az-test/providers/Microsoft.Network/networkInterfaces/az-test01",
"name": "az-test01",
"properties": {
"dnsSettings": {
"appliedDnsServers": [],
"dnsServers": [],
"internalDomainNameSuffix": "x.bx.internal.cloudapp.net"
},
"enableAcceleratedNetworking": false,
"enableIPForwarding": false,
"ipConfigurations": [
{
"etag": "W/\"x\"",
"id": "/subscriptions/x/resourceGroups/az-test/providers/Microsoft.Network/networkInterfaces/az-test01/ipConfigurations/default",
"name": "default",
"properties": {
"primary": true,
"privateIPAddress": "10.43.0.5",
"privateIPAddressVersion": "IPv4",
"privateIPAllocationMethod": "Dynamic",
"provisioningState": "Succeeded",
"publicIPAddress": {
"id": "/subscriptions/x/resourceGroups/az-test/providers/Microsoft.Network/publicIPAddresses/az-test01",
"name": "az-test01",
"properties": {
"idleTimeoutInMinutes": 4,
"ipAddress": "52.x.x.x",
"ipConfiguration": {
"id": "/subscriptions/x/resourceGroups/az-test/providers/Microsoft.Network/networkInterfaces/az-test01/ipConfigurations/default"
},
"provisioningState": "Succeeded",
"publicIPAddressVersion": "IPv4",
"publicIPAllocationMethod": "Static",
"resourceGuid": "x"
}
},
"subnet": {
"id": "/subscriptions/x/resourceGroups/az-test/providers/Microsoft.Network/virtualNetworks/az-test-vnet/subnets/az-test-subnet"
}
}
}
],
"macAddress": "00-0D-3A-1D-E1-8A",
"networkSecurityGroup": {
"id": "/subscriptions/x/resourceGroups/az-test/providers/Microsoft.Network/networkSecurityGroups/az-test01"
},
"primary": true,
"provisioningState": "Succeeded",
"resourceGuid": "x",
"virtualMachine": {
"id": "/subscriptions/x/resourceGroups/az-test/providers/Microsoft.Compute/virtualMachines/az-test"
}
}
}
]
},
"osProfile": {
"adminUsername": "az-test",
"computerName": "az-test",
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"ssh": {
"publicKeys": [
{
"keyData": "ssh-rsa AAx ",
"path": "/home/az-test/.ssh/authorized_keys"
}
]
}
},
"secrets": []
},
"provisioningState": "Succeeded",
"storageProfile": {
"dataDisks": [],
"imageReference": {
"offer": "CentOS",
"publisher": "OpenLogic",
"sku": "7.4",
"version": "7.4.20180118"
},
"osDisk": {
"caching": "ReadOnly",
"createOption": "fromImage",
"diskSizeGB": 30,
"name": "az-test.vhd",
"osType": "Linux",
"vhd": {
"uri": "https://x.blob.core.windows.net/vhds/az-test.vhd"
}
}
},
"vmId": "x"
},
"resources": [
{
"id": "/subscriptions/x/resourceGroups/az-test/providers/Microsoft.Compute/virtualMachines/az-test/extensions/OmsAgentForLinux",
"location": "eastus",
"name": "OmsAgentForLinux",
"properties": {
"autoUpgradeMinorVersion": true,
"provisioningState": "Succeeded",
"publisher": "Microsoft.EnterpriseCloud.Monitoring",
"settings": {
"azureResourceId": "/subscriptions/x/resourcegroups/az-test/providers/microsoft.compute/virtualmachines/az-test",
"stopOnMultipleConnections": true,
"workspaceId": "x"
},
"type": "OmsAgentForLinux",
"typeHandlerVersion": "1.0"
},
"type": "Microsoft.Compute/virtualMachines/extensions"
}
],
"tags": {},
"type": "Microsoft.Compute/virtualMachines"
}
}
The module name should be azure_rm_publicipaddress_facts instead of azure_rm_publicip_facts

Azure ARM template : set point-to-site configuration in a Virtual network Gateway

I'd like to set the 'Address pool' property in the 'point-to-site' section of a Virtual network Gateway created by a template.
Here the setting in Azure portal
Here the template
{
"apiVersion": "2015-06-15",
"name": "[variables('gateway').name]",
"type": "Microsoft.Network/virtualNetworkGateways",
"location": "[parameters('aseLocation')]",
"dependsOn": [
"[variables('virtualNetworkSubnet').name]",
"[variables('publicIpVnGateway').name]"
],
"properties": {
"gatewayType": "Vpn",
"ipConfigurations": [
{
"name": "default",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[resourceId(resourceGroup().name, 'Microsoft.Network/virtualNetworks/subnets', variables('virtualNetwork').name, variables('virtualNetworkSubnet').name)]"
},
"publicIpAddress": {
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Network/publicIPAddresses/', variables('publicIpVnGateway').name)]"
}
}
}
],
"enableBgp": false,
"vpnType": "RouteBased",
"sku": {
"name": "Standard",
"tier": "Standard"
}
}
}
Yes and you can do so using these properties:
"properties": {
"ipConfigurations": [
{
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": ""
},
"publicIPAddress": {
"id": ""
}
},
"name": "vnetGatewayConfig"
}
],
"gatewayType": "VPN",
"vpnType": "RouteBased",
"enableBgp": false,
"activeActive": false,
"vpnClientConfiguration": {
"vpnClientAddressPool": {
"addressPrefixes": [
"<ip_address>"
]
},
"vpnClientProtocols": [
"SSTP",
"IkeV2"
]
},
"sku": {
"name": "<sku>",
"tier": "<sku>",
"capacity": "2"
}
}
By inserting the "vpnClientConfiguration" section you can define the point to site config. Additionally you can add the certificate references here also.

Resources