Skip to content

Instantly share code, notes, and snippets.

@wilfriedwoivre
Last active October 2, 2020 08:45
Show Gist options
  • Select an option

  • Save wilfriedwoivre/7d8acd0414252d0ca9940aed825a4889 to your computer and use it in GitHub Desktop.

Select an option

Save wilfriedwoivre/7d8acd0414252d0ca9940aed825a4889 to your computer and use it in GitHub Desktop.
azure-vm-sep-update
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"adminUserName": {
"type": "string"
},
"adminPassword": {
"type": "securestring"
}
},
"functions": [
],
"variables": {
"vmName": "wintestvm",
"virtualNetworkName": "[concat('vnet-', uniqueString(resourceGroup().name))]",
"automationAccountName": "[concat('aa-', uniqueString(resourceGroup().name))]",
"loaName": "[concat('loa-', uniqueString(resourceGroup().name))]",
"Updates": {
"name": "[concat('Updates', '(', variables('loaName'), ')')]",
"galleryName": "Updates"
}
},
"resources": [
{
"name": "AllowStorageInSubscription",
"type": "Microsoft.Network/serviceEndpointPolicies",
"apiVersion": "2020-04-01",
"location": "westeurope",
"tags": {
},
"properties": {
"serviceEndpointPolicyDefinitions": [
{
"name": "AllowAllSubscriptionStorages",
"properties": {
"service": "Microsoft.Storage",
"serviceResources": [
"[subscription().id]"
]
}
}
]
}
},
{
"name": "[variables('virtualNetworkName')]",
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2019-11-01",
"location": "westeurope",
"dependsOn": [
"AllowStorageInSubscription"
],
"properties": {
"addressSpace": {
"addressPrefixes": [
"10.0.0.0/16"
]
},
"subnets": [
{
"name": "vms-subnet",
"properties": {
"addressPrefix": "10.0.0.0/24",
"serviceEndpoints": [
{
"service": "Microsoft.Storage",
"locations": [
"westeurope"
]
}
],
"serviceEndpointPolicies": [
{
"id": "[resourceId('Microsoft.Network/serviceEndpointPolicies', 'AllowStorageInSubscription')]"
}
]
}
}
]
}
},
{
"name": "[variables('loaName')]",
"type": "Microsoft.OperationalInsights/workspaces",
"apiVersion": "2020-03-01-preview",
"location": "westeurope",
"properties": {
"sku": {
"name": "PerGB2018"
},
"retentionInDays": 30,
"features": {
"searchVersion": 1,
"legacy": 0
}
},
"resources": [
{
"apiVersion": "2015-11-01-preview",
"location": "westeurope",
"name": "[variables('Updates').name]",
"type": "Microsoft.OperationsManagement/solutions",
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.OperationsManagement/solutions/', variables('Updates').name)]",
"dependsOn": [
"[concat('Microsoft.OperationalInsights/workspaces/', variables('loaName'))]"
],
"properties": {
"workspaceResourceId": "[resourceId('Microsoft.OperationalInsights/workspaces/', variables('loaName'))]"
},
"plan": {
"name": "[variables('Updates').name]",
"publisher": "Microsoft",
"promotionCode": "",
"product": "[concat('OMSGallery/', variables('Updates').galleryName)]"
}
}
]
},
{
"name": "[variables('automationAccountName')]",
"type": "Microsoft.Automation/automationAccounts",
"apiVersion": "2018-06-30",
"location": "westeurope",
"dependsOn": [
"[variables('loaName')]"
],
"properties": {
"sku": {
"name": "Basic"
}
}
},
{
"name": "[concat(variables('loaName'), '/' , 'Automation')]",
"apiVersion": "2020-03-01-preview",
"type": "Microsoft.OperationalInsights/workspaces/linkedServices",
"location": "westeurope",
"dependsOn": [
"[concat('Microsoft.OperationalInsights/workspaces/', variables('loaName'))]",
"[concat('Microsoft.Automation/automationAccounts/', variables('automationAccountName'))]"
],
"properties": {
"resourceId": "[resourceId('Microsoft.Automation/automationAccounts/', variables('automationAccountName'))]"
}
},
{
"name": "[concat(variables('vmName'), '-pip')]",
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2019-11-01",
"location": "westeurope",
"tags": {
"displayName": "PublicIPAddress"
},
"properties": {
"publicIPAllocationMethod": "Dynamic"
}
},
{
"name": "[concat(variables('vmName'), '-nic')]",
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2019-11-01",
"location": "westeurope",
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', concat(variables('vmName'), '-pip'))]",
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipConfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', concat(variables('vmName'), '-pip'))]"
},
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'),'vms-subnet')]"
}
}
}
]
}
},
{
"name": "[variables('vmName')]",
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2019-07-01",
"location": "westeurope",
"dependsOn": [
"[resourceId('Microsoft.Network/networkInterfaces', concat(variables('vmName'),'-nic'))]"
],
"tags": {
"displayName": "windowsVM1"
},
"properties": {
"hardwareProfile": {
"vmSize": "Standard_A2_v2"
},
"osProfile": {
"computerName": "[variables('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2016-Datacenter",
"version": "latest"
},
"osDisk": {
"name": "[concat(variables('vmName'), 'osdisk')]",
"caching": "ReadWrite",
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('vmName'), '-nic'))]"
}
]
}
},
"resources": [
{
"type": "extensions",
"name": "Microsoft.EnterpriseCloud.Monitoring",
"apiVersion": "2015-06-15",
"location": "westeurope",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
],
"properties": {
"publisher": "Microsoft.EnterpriseCloud.Monitoring",
"type": "MicrosoftMonitoringAgent",
"typeHandlerVersion": "1.0",
"autoUpgradeMinorVersion": true,
"settings": {
"workspaceId": "[reference(resourceId('Microsoft.OperationalInsights/workspaces/', variables('loaName')), '2015-03-20').customerId]"
},
"protectedSettings": {
"workspaceKey": "[listKeys(resourceId('Microsoft.OperationalInsights/workspaces/', variables('loaName')), '2015-03-20').primarySharedKey]"
}
}
}
]
}
],
"outputs": {
}
}
Get-EventLog -LogName "Operations Manager" -EntryType Error | Where-Object { $_.Message -match "blob.core.windows.net" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment