Skip to content

Instantly share code, notes, and snippets.

View krnese's full-sized avatar
💭
Living the dream

Kristian Nese krnese

💭
Living the dream
View GitHub Profile
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(parameters('vmNameSuffix'), 'VM', copyIndex(), '/OMS')]",
"location": "[resourceGroup().location]",
"copy": {
"name": "[concat(parameters('vmNameSuffix'), 'VM', 'OMS')]",
"count": "[parameters('instancecount')]"
},
"dependsOn": [
@krnese
krnese / search.json
Last active December 20, 2016 08:28
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": ""
},
"resourcegroup": {
"type": "string",
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"subscriptionId": {
"type": "string",
"metadata": {
"description": "Specify the subscription Id where your storage account is located"
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(parameters('vmNameSuffix'), 'VM', copyIndex(), '/OMS')]",
"location": "[resourceGroup().location]",
"copy": {
"name": "[concat(parameters('vmNameSuffix'), 'VM', 'OMS')]",
"count": "[parameters('instancecount')]"
},
"dependsOn": [
# Finding protected and unprotected VMs
$backupVaults = Find-AzureRmResource -ResourceType Microsoft.RecoveryServices/vaults
foreach ($backupvault in $backupVaults)
{
$rsVault = Get-AzureRmRecoveryServicesVault -Name $backupVault.Name -ResourceGroupName $backupVault.ResourceGroupName
Set-AzureRmRecoveryServicesVaultContext -Vault $rsVault
$azureVMs = Get-AzureRmRecoveryServicesBackupContainer -ContainerType AzureVM
# Getting Backup Jobs
# Constructing the BackupJobs collection
$uri = "https://management.azure.com" + $vault.id + "/backupJobs?api-version=2015-11-10"
$restResult = Invoke-RestMethod -method Get -headers $authHeader -uri $URI
$backupJobs = $restResult.value
$backupJobs = $backupJobs.Properties
$resourceGroupName = $vault.id.Split('/')
$resourceGroupName = $resourceGroupName[4]
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"omsAutomationAccountName": {
"type": "string",
"metadata": {
"description": "Specify the name of the automation account you will create"
}
},
# Webhook and runbook details
$WebhookName = 'OMS Alert Remediation ' + [System.Guid]::NewGuid().toString()
$RunbookName = 'ManagedIaaSBackup'
$WorkspaceName = 'AzureScaleWorkspace'
# Create Webhook for Runbook
$Webhook = New-AzureRmAutomationWebhook `
                -Name $WebhookName `
                -IsEnabled $True `
                -ExpiryTime (Get-Date).AddYears(2) `
{
"apiVersion": "2017-05-10",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "[parameters('omsResourceGroup')]",
"name": "enableBackup",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('vmNameSuffix'), 'VM0', '/extensions/', 'OMS')]"
],
"properties": {
"mode": "Incremental",
"copy": {
"name": "modulesCopy",
"count": "[length(variables('assets').psModules)]",
"batchSize": 4,
"mode": "Serial"
}