├── 000-base-automation-resource-templates ├── deploy-certificate │ ├── README.md │ └── deployCertificate.json ├── deploy-compilationjob │ ├── README.MD │ └── deployCompilationjob.json ├── deploy-configuration │ ├── README.md │ └── deployConfiguration.json ├── deploy-connection-example │ ├── README.md │ └── deployConnection.json ├── deploy-credential │ ├── README.md │ └── deployCredential.json ├── deploy-module │ ├── DeployModule.json │ ├── README.md │ └── modules │ │ ├── Hello-WorldModule.zip │ │ └── Hello-WorldModule │ │ ├── Hello-WorldModule.psd1 │ │ └── Hello-WorldModule.psm1 ├── deploy-runbooks │ ├── README.md │ ├── deployDraftRunbook.json │ └── deployPublishedRunbook.json ├── deploy-schedule │ ├── README.md │ └── deployRunbookOnSchedule.json └── deploy-variable │ ├── README.md │ ├── deployEncryptedVariable.json │ └── deployVariable.json ├── 101-get-vm-tutorial ├── DeployThroughARM.ps1 ├── README.md ├── Runbooks │ ├── AzureAlertContext.ps1 │ └── Get-AzureVMTutorial.ps1 ├── azuredeploy-parameters.json └── azuredeploy.json ├── 101-import-and-start-job ├── README.md ├── Runbooks │ └── Hello-World.ps1 ├── azuredeploy-parameters.json └── azuredeploy.json ├── 101-remove-resourcegroups ├── DeployThroughARM.ps1 ├── README.md ├── azuredeploy-parameters.json └── azuredeploy.json ├── 101-sample-automation-resource-templates ├── sample-deploy-certificate │ ├── README.md │ ├── azuredeploy-parameters.json │ └── deployCertificate.json ├── sample-deploy-connection │ ├── README.md │ ├── azuredeploy-parameters.json │ └── deployConnection.json ├── sample-deploy-credential │ ├── README.md │ ├── azuredeploy-parameters.json │ └── deployCredential.json ├── sample-deploy-module │ ├── DeployModule.json │ ├── README.md │ ├── azuredeploy-parameters.json │ └── modules │ │ ├── Hello-WorldModule.zip │ │ └── Hello-WorldModule │ │ ├── Hello-WorldModule.psd1 │ │ └── Hello-WorldModule.psm1 ├── sample-deploy-runbooks │ ├── README.md │ ├── azuredeploy-parameters.json │ ├── deployRunbooks.json │ └── runbooks │ │ ├── DraftRunbook.ps1 │ │ └── PublishedRunbook.ps1 ├── sample-deploy-schedule │ ├── README.md │ ├── azuredeploy-parameters.json │ └── deployRunbookOnSchedule.json └── sample-deploy-variable │ ├── README.md │ ├── azuredeploy-parameters.json │ └── deployVariable.json ├── 101-sample-using-base-automation-templates ├── README.md ├── Runbooks │ └── Say-HelloSample.ps1 ├── azuredeploy-parameters.json └── azuredeploy.json ├── 101-sample-using-single-automation-template ├── README.md ├── Runbooks │ └── Say-HelloSample.ps1 ├── azuredeploy-parameters.json └── azuredeploy.json ├── 102-sample-automation-setup ├── Configurations │ └── SimpleConfig.ps1 ├── README.md ├── Runbooks │ └── SampleRunbook.ps1 ├── azuredeploy-parameters.json ├── azuredeploy.json └── deployThroughARM.ps1 ├── 200-connect-azure-vm ├── README.md ├── Runbooks │ └── Connect-AzureVM.ps1 └── azuredeploy.json ├── 200-copy-file-to-azure-vm ├── README.md └── azuredeploy.json ├── 201-Deploy-And-Compile-DSC-Configuration-Credentials ├── Configurations │ ├── Modules │ │ ├── xActiveDirectory.zip │ │ └── xComputerManagement.zip │ └── dscDomainJoin.ps1 ├── README.md ├── azuredeploy-parameters.json ├── azuredeploy.json └── deployThroughARM.ps1 ├── 201-Deploy-And-Compile-DSC-Configuration-using-base-templates ├── Configurations │ └── webrolefull.ps1 ├── README.md ├── azuredeploy-parameters.json ├── azuredeploy.json └── deployThroughARM.ps1 ├── 201-Deploy-And-Compile-DSC-Configuration ├── Configurations │ └── webrolefull.ps1 ├── README.md ├── azuredeploy-parameters.json ├── azuredeploy.json └── deployThroughARM.ps1 ├── 201-deploy-dsc-resources-and-configuration ├── Configurations │ └── myTimezone.ps1 ├── README.md ├── azuredeploy-parameters.json ├── azuredeploy.json └── deployThroughARM.ps1 ├── 201-start-azure-vm-graphical-base-templates ├── README.md └── deployAutomationResources.json ├── 201-start-azure-vm-graphical ├── README.md └── azuredeploy.json ├── 201-stop-azure-vm-graphical ├── README.md └── azuredeploy.json ├── LICENSE ├── README.md ├── deploy-vm-with-dsc-configuration ├── README.md ├── azuredeploy.json └── linked-templates │ ├── Windows2016Server.json │ └── dscagent.json ├── managed-vm ├── README.md ├── azuredeploy.json ├── azuredeploy.parameters.json ├── dsc-configurations │ └── HybridWorkerConfig.ps1 └── linked-templates │ ├── Windows2016Server.json │ ├── dscagent.json │ ├── hybridworkerwithdsc.json │ ├── linkedworkspaceaccount.json │ ├── monitoringagent.json │ ├── scheduleUpdateDeployment.json │ └── solution.json └── onboardSolution └── onboardautomationsolutions.json /000-base-automation-resource-templates/deploy-certificate/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Automation certificate 3 | 4 | This template creates a certificate in an existing Automation account. This certificate is not password protected. 5 | 6 | 7 | ## Parameter details 8 | 9 | | Name | Type | Details | 10 | | ------------- |:-------------:| -----------------------------------------------------------------:| 11 | | accountName | string | The name of the Automation account to deploy the certificate to. | 12 | | certificateName | string | The name of the certificate. | 13 | | base64Value | securestring | The base 64 value for the certificate. | 14 | | thumbprint | securestring | The thumbprint for the certificate. | 15 | 16 | ## How to call this template from your template 17 | 18 | Copy and paste the following section into the resources block in your parent template. Make sure the values of **name** in the **variables('name')** or **parameters('name')** match the names you have specified your template. 19 | 20 | certificateTemplate = "https://raw.githubusercontent.com/azureautomation/automation-packs/master/000-base-automation-resource-templates/deploy-certificate/deployCertificate.json" 21 | 22 | 23 | ```json 24 | { 25 | "apiVersion": "2015-01-01", 26 | "name": "nestedTemplateCertificate", 27 | "type": "Microsoft.Resources/deployments", 28 | "dependsOn": [ 29 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 30 | ], 31 | "properties": { 32 | "mode": "incremental", 33 | "templateLink": { 34 | "uri": "[variables('certificateTemplate')]", 35 | "contentVersion": "1.0" 36 | }, 37 | "parameters": { 38 | "accountName": { 39 | "value": "[parameters('accountName')]" 40 | }, 41 | "certificateName": { 42 | "value": "[parameters('certificateName')]" 43 | }, 44 | "base64Value": { 45 | "value": "[parameters('base64Value')]" 46 | }, 47 | "thumbprint": { 48 | "value": "[parameters('thumbprint')]" 49 | } 50 | } 51 | } 52 | } 53 | 54 | ``` 55 | -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-certificate/deployCertificate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01-preview#", 3 | "contentVersion": "1.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Azure Automation account to deploy the certificate in." 9 | } 10 | }, 11 | "certificateName": { 12 | "type": "string", 13 | "metadata": { 14 | "description": "The name of the certificate." 15 | } 16 | }, 17 | "base64Value": { 18 | "type": "securestring", 19 | "metadata": { 20 | "description": "The base 64 value for the certificate." 21 | } 22 | }, 23 | "thumbprint": { 24 | "type": "securestring", 25 | "metadata": { 26 | "description": "The thumprint value for the certificate." 27 | } 28 | } 29 | }, 30 | "variables": { 31 | 32 | }, 33 | "resources": [ 34 | { 35 | "name": "[concat(parameters('accountName'), '/', parameters('certificateName'))]", 36 | "type": "microsoft.automation/automationAccounts/certificates", 37 | "apiVersion": "2015-01-01-preview", 38 | "tags": { }, 39 | "properties": { 40 | "base64Value": "[parameters('base64Value')]", 41 | "thumbprint": "[parameters('thumbprint')]" 42 | } 43 | } 44 | ], 45 | 46 | 47 | "outputs": { } 48 | } 49 | -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-compilationjob/README.MD: -------------------------------------------------------------------------------- 1 | # Deploy a DSC configuration conmpilation job to an Automation Account 2 | 3 | This sample shows how to deploy a compilation job to Azure Automation. 4 | 5 | ## Parameter details 6 | 7 | | Name | Type | Details | 8 | | ------------- |:-------------:| ---------------------------------------------------------------------------------: | 9 | | accountName | string | The name of the Automation account to deploy the DSC configuration to. | 10 | | location | string | The region the Automaiton account is located in. | 11 | | configurationName | string | The name for the DSC configuration. The name must match the name in the URI. | 12 | | jobId | string | The URI for the DSC configuration. | | 13 | 14 | ## How to call this template from your template 15 | 16 | Copy and paste the following section into the resources block in your parent template. Make sure the values of **name** in the **variables('name')** or **parameters('name')** match the names you have specified your template. 17 | 18 | configurationTemplate = "https://raw.githubusercontent.com/azureautomation/automation-packs/master/000-base-automation-resource-templates/deploy-compilationjob/deployCompilationjob.json" 19 | 20 | ```json 21 | { 22 | "apiVersion": "2015-01-01", 23 | "name": "nestedTemplateCompilationjob", 24 | "type": "Microsoft.Resources/deployments", 25 | "dependsOn": [ 26 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 27 | ], 28 | "properties": { 29 | "mode": "incremental", 30 | "templateLink": { 31 | "uri": "[variables('compilationjobTemplate')]", 32 | "contentVersion": "1.0" 33 | }, 34 | "parameters": { 35 | "accountName": { 36 | "value": "[parameters('accountName')]" 37 | }, 38 | "location": { 39 | "value": "[parameters('regionId')]" 40 | }, 41 | "configurationName": { 42 | "value": "[variables('configurationName')]" 43 | }, 44 | "jobId":{ 45 | "value": "[parameters('jobId')]" 46 | } 47 | } 48 | } 49 | } 50 | ] 51 | } 52 | 53 | ``` -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-compilationjob/deployCompilationjob.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01-preview#", 3 | "contentVersion": "1.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Azure Automation account to deploy the configuration in." 9 | } 10 | }, 11 | "location": { 12 | "type": "string", 13 | "metadata": { 14 | "description": "The location of the Azure Automation account." 15 | } 16 | }, 17 | "configurationName": { 18 | "type": "string", 19 | "metadata": { 20 | "description": "The name of the DSC configuration. The name must match the configuration name in the script" 21 | } 22 | }, 23 | "jobId": { 24 | "type": "string", 25 | "metadata": { 26 | "description": "the job id to compile the configuration" 27 | } 28 | } 29 | }, 30 | "variables": {}, 31 | "resources": [ 32 | { 33 | "name": "[concat(parameters('accountName'), '/', parameters('jobId'))]", 34 | "type": "Microsoft.Automation/AutomationAccounts/Compilationjobs", 35 | "apiVersion": "2015-01-01-preview", 36 | "location": "parameters('location')]", 37 | "tags": {}, 38 | "properties": { 39 | "configuration": { 40 | "name": "[parameters('configurationName')]" 41 | } 42 | } 43 | } 44 | ], 45 | "outputs": {} 46 | } -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-configuration/README.md: -------------------------------------------------------------------------------- 1 | # Deploy a DSC configuration to an Automation Account 2 | 3 | This sample shows how to deploy a DSC configuration to Azure Automation. 4 | **Note** that DSC configurations can only be imported in a 'published' state during preview 5 | 6 | ## Parameter details 7 | 8 | | Name | Type | Details | 9 | | ------------- |:-------------:| ---------------------------------------------------------------------------------: | 10 | | accountName | string | The name of the Automation account to deploy the DSC configuration to. | 11 | | regionId | string | The region the Automaiton account is located in. | 12 | | configurationName | string | The name for the DSC configuration. The name must match the name in the URI. | 13 | | configurationURI | string | The URI for the DSC configuration. | 14 | | configurationDescription | string | The DSC configuration description. | 15 | 16 | ## How to call this template from your template 17 | 18 | Copy and paste the following section into the resources block in your parent template. Make sure the values of **name** in the **variables('name')** or **parameters('name')** match the names you have specified your template. 19 | 20 | configurationTemplate = "https://raw.githubusercontent.com/azureautomation/automation-packs/master/000-base-automation-resource-templates/deploy-configuration/deployConfiguration.json" 21 | 22 | ```json 23 | { 24 | "apiVersion": "2015-01-01", 25 | "name": "nestedDSCconfiguration", 26 | "type": "Microsoft.Resources/deployments", 27 | "dependsOn": [ 28 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 29 | ], 30 | "properties": { 31 | "mode": "incremental", 32 | "templateLink": { 33 | "uri": "[variables('configurationTemplate')]", 34 | "contentVersion": "1.0" 35 | }, 36 | "parameters": { 37 | "accountName": { 38 | "value": "[parameters('accountName')]" 39 | }, 40 | "location": { 41 | "value": "[parameters('regionId')]" 42 | }, 43 | "configurationName": { 44 | "value": "[variables('configurationName')]" 45 | }, 46 | "configurationDescription": { 47 | "value": "[variables('configurationDescription')]" 48 | }, 49 | "configurationURI": { 50 | "value": "[variables('configurationURI')]" 51 | } 52 | } 53 | } 54 | } 55 | 56 | ``` -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-configuration/deployConfiguration.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01-preview#", 3 | "contentVersion": "1.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Azure Automation account to deploy the configuration in." 9 | } 10 | }, 11 | "location": { 12 | "type": "string", 13 | "metadata": { 14 | "description": "The location of the Azure Automation account." 15 | } 16 | }, 17 | "configurationName": { 18 | "type": "string", 19 | "metadata": { 20 | "description": "The name of the DSC configuration. The name must match the configuration name in the script" 21 | } 22 | }, 23 | "configurationDescription": { 24 | "type": "string", 25 | "metadata": { 26 | "description": "The description of the DSC configuration." 27 | } 28 | }, 29 | "configurationURI": { 30 | "type": "string", 31 | "metadata": { 32 | "description": "The URI for the DSC configuration." 33 | } 34 | } 35 | }, 36 | "variables": { 37 | "dscOverwrite": "true" 38 | }, 39 | "resources": [ 40 | { 41 | "name": "[concat(parameters('accountName'), '/', parameters('configurationName'))]", 42 | "type": "Microsoft.Automation/AutomationAccounts/Configurations", 43 | "apiVersion": "2015-01-01-preview", 44 | "location": "[parameters('Location')]", 45 | "tags": {}, 46 | "properties": { 47 | "logVerbose": "false", 48 | "description": "[parameters('configurationDescription')]", 49 | "state": "Published", 50 | "overwrite": "[variables('dscOverwrite')]", 51 | "Source": { 52 | "type": "uri", 53 | "Value": "[parameters('configurationURI')]" 54 | } 55 | } 56 | } 57 | ], 58 | 59 | "outputs": {} 60 | } -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-connection-example/README.md: -------------------------------------------------------------------------------- 1 | # Create an Automation connection 2 | 3 | This sample shows how to deploy an Azure Automation connection asset. This template provides an example of how to deploy a connection for the Azure module. Depending on your connection, the parameters will differ. 4 | 5 | 6 | 7 | ## Parameter details 8 | 9 | | Name | Type | Details | 10 | | ------------- |:-------------:| -----------------------------------------------------------------:| 11 | | accountName | string | The name of the Automation account to deploy the connection to. | 12 | | connectionName | string | The name of the connection. | 13 | | connectionCertificateName | string | The certificate name for the connection. | 14 | | connectionSubscriptionId | string | The subscription ID for the connection. | 15 | 16 | 17 | ## How to call this template from your template 18 | 19 | Copy and paste the following section into the resources block in your parent template. Make sure the values of **name** in the **variables('name')** or **parameters('name')** match the names you have specified your template. 20 | 21 | connectionTemplate = "https://raw.githubusercontent.com/azureautomation/automation-packs/master/000-base-automation-resource-templates/deploy-connection-example/deployConnection.json" 22 | 23 | 24 | ```json 25 | { 26 | "apiVersion": "2015-01-01", 27 | "name": "nestedTemplateconnection", 28 | "type": "Microsoft.Resources/deployments", 29 | "dependsOn": [ 30 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 31 | ], 32 | "properties": { 33 | "mode": "incremental", 34 | "templateLink": { 35 | "uri": "[variables('connectionTemplate')]", 36 | "contentVersion": "1.0" 37 | }, 38 | "parameters": { 39 | "accountName": { 40 | "value": "[parameters('accountName')]" 41 | }, 42 | "connectionName": { 43 | "value": "[parameters('connectionName')]" 44 | }, 45 | "connectionCertificateName": { 46 | "value": "[parameters('connectionCertificateName')]" 47 | }, 48 | "connectionSubscriptionId": { 49 | "value": "[parameters('connectionSubscriptionId')]" 50 | } 51 | } 52 | } 53 | } 54 | 55 | ``` 56 | -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-connection-example/deployConnection.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01-preview#", 3 | "contentVersion": "1.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Azure Automation account to deploy the connection to." 9 | } 10 | }, 11 | "connectionName": { 12 | "type": "string", 13 | "metadata": { 14 | "description": "The name of the Azure Automation connection asset. The connection type must be deployed before you can deploy the connection. In this case, we are using Azure since that is created for all users." 15 | } 16 | }, 17 | "connectionCertificateName": { 18 | "type": "string", 19 | "metadata": { 20 | "description": "The name of the certificate used for Azure auth." 21 | } 22 | }, 23 | "connectionSubscriptionId": { 24 | "type": "string", 25 | "metadata": { 26 | "description": "The ID of the Azure subscription you want to connect to." 27 | } 28 | } 29 | }, 30 | "variables": { 31 | 32 | }, 33 | 34 | "resources": [ 35 | 36 | { 37 | "name": "[concat(parameters('accountName'), '/', parameters('connectionName'))]", 38 | "type": "microsoft.automation/automationAccounts/connections", 39 | "apiVersion": "2015-01-01-preview", 40 | "tags": { }, 41 | "properties": { 42 | "name": "[parameters('connectionName')]", 43 | "description": "Dummy Azure connection", 44 | "isGlobal": false, 45 | "connectionType": { 46 | "name": "Azure" 47 | }, 48 | "fieldDefinitionValues": { 49 | "AutomationCertificateName": "[parameters('connectionCertificateName')]", 50 | "SubscriptionID": "[parameters('connectionSubscriptionId')]" 51 | } 52 | } 53 | 54 | } 55 | ], 56 | 57 | "outputs": { } 58 | } -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-credential/README.md: -------------------------------------------------------------------------------- 1 | # Create an Automation credential 2 | 3 | This sample shows how to deploy an Azure Automation credential asset. The credential contains the username and password that you provide. 4 | 5 | 6 | ## Parameter details 7 | 8 | | Name | Type | Details | 9 | | ------------- |:-------------:| -----------------------------------------------------------------:| 10 | | accountName | string | The name of the Automation account to deploy the credential to. | 11 | | credentialName | string | The name of the credential. | 12 | | userName | string | The user name for the credential. | 13 | | password | securestring | The password for the credential. | 14 | 15 | 16 | ## How to call this template from your template 17 | 18 | Copy and paste the following section into the resources block in your parent template. Make sure the values of **name** in the **variables('name')** or **parameters('name')** match the names you have specified your template. 19 | 20 | credentialTemplate = "https://raw.githubusercontent.com/azureautomation/automation-packs/master/000-base-automation-resource-templates/deploy-credential/deployCredential.json" 21 | 22 | ```json 23 | { 24 | "apiVersion": "2015-01-01", 25 | "name": "nestedTemplateCredential", 26 | "type": "Microsoft.Resources/deployments", 27 | "dependsOn": [ 28 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 29 | ], 30 | "properties": { 31 | "mode": "incremental", 32 | "templateLink": { 33 | "uri": "[variables('credentialTemplate')]", 34 | "contentVersion": "1.0" 35 | }, 36 | "parameters": { 37 | "accountName": { 38 | "value": "[parameters('accountName')]" 39 | }, 40 | "credentialName": { 41 | "value": "[parameters('credentialName')]" 42 | }, 43 | "userName": { 44 | "value": "[parameters('userName')]" 45 | }, 46 | "password": { 47 | "value": "[parameters('password')]" 48 | } 49 | } 50 | } 51 | } 52 | 53 | ``` 54 | -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-credential/deployCredential.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01-preview#", 3 | "contentVersion": "1.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Azure Automation account to deploy the credential to." 9 | } 10 | }, 11 | "credentialName": { 12 | "type": "string", 13 | "metadata": { 14 | "description": "The name of the credential to deploy." 15 | } 16 | }, 17 | "userName": { 18 | "type": "string", 19 | "metadata": { 20 | "description": "The username for the Azure Automation credential." 21 | } 22 | }, 23 | "password": { 24 | "type": "secureString", 25 | "metadata": { 26 | "description": "The password for the Azure Automation credential." 27 | } 28 | } 29 | }, 30 | "variables": { 31 | 32 | }, 33 | 34 | "resources": [ 35 | { 36 | "name": "[concat(parameters('accountName'), '/', parameters('credentialName'))]", 37 | "type": "microsoft.automation/automationAccounts/credentials", 38 | "apiVersion": "2015-01-01-preview", 39 | "tags": { }, 40 | "properties": { 41 | "userName": "[parameters('userName')]", 42 | "password": "[parameters('password')]" 43 | } 44 | } 45 | ], 46 | 47 | "outputs": {} 48 | } -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-module/DeployModule.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01#", 3 | "contentVersion": "1.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Automation account to deploy the module to." 9 | } 10 | }, 11 | "moduleName": { 12 | "type": "string", 13 | "metadata": { 14 | "description": "The name of the module to deploy. This must be the same name as the .zip foldername in the URI below." 15 | } 16 | }, 17 | "moduleUri": { 18 | "type": "string", 19 | "metadata": { 20 | "description": "The URL for the module zip file to upload to Azure Automation." 21 | } 22 | } 23 | 24 | }, 25 | "variables": { 26 | 27 | }, 28 | "resources": [ 29 | { 30 | "name": "[concat(parameters('accountName'), '/', parameters('moduleName'))]", 31 | "type": "microsoft.automation/automationAccounts/modules", 32 | "apiVersion": "2015-01-01-preview", 33 | "tags": { }, 34 | "properties": { 35 | "contentLink": { 36 | "uri": "[parameters('moduleUri')]" 37 | } 38 | } 39 | } 40 | 41 | ], 42 | 43 | 44 | "outputs": { 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-module/README.md: -------------------------------------------------------------------------------- 1 | # Deploy a module to an Automation Account 2 | 3 | This sample shows how to deploy a module to Azure Automation. To deploy your own module update the name & the URL. The URL for the module must contain the zipped module folder. 4 | To learn about authoring modules for Automation see: [Authoring Integration Modules](http://azure.microsoft.com/blog/2014/12/15/authoring-integration-modules-for-azure-automation/) 5 | 6 | 7 | ## Parameter details 8 | 9 | | Name | Type | Details | 10 | | ------------- |:-------------:| -----------------------------------------------------------------:| 11 | | accountName | string | The name of the Automation account to deploy the module to. | 12 | | moduleName | string | The name of the module. | 13 | | moduleUri | string | The user name for the module. | 14 | 15 | 16 | ## How to call this template from your template 17 | 18 | Copy and paste the following section into the resources block in your parent template. Make sure the values of **name** in the **variables('name')** or **parameters('name')** match the names you have specified your template. 19 | 20 | moduleTemplate = "https://raw.githubusercontent.com/azureautomation/automation-packs/master/000-base-automation-resource-templates/deploy-module/DeployModule.json" 21 | 22 | ```json 23 | { 24 | "apiVersion": "2015-01-01", 25 | "name": "nestedTemplateModule", 26 | "type": "Microsoft.Resources/deployments", 27 | "dependsOn": [ 28 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 29 | ], 30 | "properties": { 31 | "mode": "incremental", 32 | "templateLink": { 33 | "uri": "[variables('moduleTemplate')]", 34 | "contentVersion": "1.0" 35 | }, 36 | "parameters": { 37 | "accountName": { 38 | "value": "[parameters('accountName')]" 39 | }, 40 | "moduleName": { 41 | "value": "[parameters('moduleName')]" 42 | }, 43 | "moduleUri": { 44 | "value": "[parameters('moduleUri')]" 45 | } 46 | } 47 | } 48 | } 49 | 50 | ``` -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-module/modules/Hello-WorldModule.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/azureautomation/automation-packs/c03d72f994e74385091f6e631cfd906bfcba0073/000-base-automation-resource-templates/deploy-module/modules/Hello-WorldModule.zip -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-module/modules/Hello-WorldModule/Hello-WorldModule.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/azureautomation/automation-packs/c03d72f994e74385091f6e631cfd906bfcba0073/000-base-automation-resource-templates/deploy-module/modules/Hello-WorldModule/Hello-WorldModule.psd1 -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-module/modules/Hello-WorldModule/Hello-WorldModule.psm1: -------------------------------------------------------------------------------- 1 |  2 | function Say-Hello 3 | { 4 | param( 5 | [Parameter(Mandatory=$True)] 6 | [ValidateNotNullOrEmpty()] 7 | [string] 8 | $Name 9 | ) 10 | 11 | Write-Output "Hello $Name" 12 | 13 | } 14 | 15 | Export-ModuleMember * -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-runbooks/README.md: -------------------------------------------------------------------------------- 1 | # Deploy a runbook to an Automation Account 2 | 3 | This sample shows how to deploy a runbook to Azure Automation. You can create a runbook in draft state or in published state. Update the URL in the templateLink URI to point to either the published or draft template depending on how 4 | you want to publish this runbook. Note you cannot schedule or run jobs on runbooks that only contain a draft (New) version. 5 | 6 | 7 | ## Parameter details 8 | 9 | | Name | Type | Details | 10 | | ------------- |:-------------:| ---------------------------------------------------------------------------------: | 11 | | accountName | string | The name of the Automation account to deploy the runbook to. | 12 | | regionId | string | The region the Automaiton account is located in. | 13 | | runbookName | string | The name for the runbook. The name must match the name in the URI. | 14 | | runbookURI | string | The URI for the runbook. | 15 | | runbookType | string | The type of runbook. Runbooks can be Graph, PowerShell scripts, or PowerShell Workflows. | 16 | | projectSourceLocation | string | The link back to the original source project. A tag is generated with this value to help you locate the original project.| 17 | | runbookDescription | string | The runbook description. | 18 | 19 | ## How to call this template from your template 20 | 21 | Copy and paste the following section into the resources block in your parent template. Make sure the values of **name** in the **variables('name')** or **parameters('name')** match the names you have specified your template 22 | and how they are specified (are they stored in a variable or parameter). 23 | 24 | For published use runbookTemplate = "https://raw.githubusercontent.com/azureautomation/automation-packs/master/000-base-automation-resource-templates/deploy-runbooks/deployPublishedRunbook.json" 25 | For draft use runbookTemplate = "https://raw.githubusercontent.com/azureautomation/automation-packs/master/000-base-automation-resource-templates/deploy-runbooks/deployDraftRunbook.json" 26 | 27 | 28 | ```json 29 | { 30 | "apiVersion": "2015-01-01", 31 | "name": "nestedTemplateRunbook", 32 | "type": "Microsoft.Resources/deployments", 33 | "dependsOn": [ 34 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 35 | ], 36 | "properties": { 37 | "mode": "incremental", 38 | "templateLink": { 39 | "uri": "[variables('runbookTemplate')]", 40 | "contentVersion": "1.0" 41 | }, 42 | "parameters": { 43 | "accountName": { 44 | "value": "[parameters('accountName')]" 45 | }, 46 | "regionId": { 47 | "value": "[parameters('regionId')]" 48 | }, 49 | "runbookName": { 50 | "value": "[variables('runbookName')]" 51 | }, 52 | "runbookUri": { 53 | "value": "[variables('runbookUri')]" 54 | }, 55 | "runbookType": { 56 | "value": "[variables('runbookType')]" 57 | }, 58 | "runbookDescription": { 59 | "value": "[variables('runbookDescription')]" 60 | } 61 | } 62 | } 63 | } 64 | 65 | ``` -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-runbooks/deployDraftRunbook.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01#", 3 | "contentVersion": "1.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Automation account to use. If this account exists, check the SKU and tags to make sure they match the exisitng account." 9 | } 10 | }, 11 | "regionId": { 12 | "type": "string", 13 | "allowedValues": [ 14 | "Japan East", 15 | "East US 2", 16 | "West Europe", 17 | "Southeast Asia", 18 | "South Central US" 19 | ], 20 | "metadata": { 21 | "description": "The region the Automaiton account is located in." 22 | } 23 | }, 24 | "runbookName": { 25 | "type": "string", 26 | "metadata": { 27 | "description": "The name for the runbook. The name must match the name in the URI." 28 | } 29 | }, 30 | "runbookURI": { 31 | "type": "string", 32 | "metadata": { 33 | "description": "The URI for the runbook. " 34 | } 35 | }, 36 | "runbookType": { 37 | "type": "string", 38 | "allowedValues": [ 39 | "Graph", 40 | "Script" 41 | ], 42 | "metadata": { 43 | "description": "The type of runbook" 44 | } 45 | }, 46 | "runbookDescription": { 47 | "type": "string", 48 | "metadata": { 49 | "description": "The description of the runbook." 50 | } 51 | } 52 | 53 | }, 54 | "variables": { 55 | 56 | }, 57 | 58 | "resources": [ 59 | 60 | { 61 | "name": "[concat(parameters('accountName'), '/', parameters('runbookName'))]", 62 | "type": "microsoft.automation/automationAccounts/runbooks", 63 | "apiVersion": "2015-01-01-preview", 64 | "location": "[parameters('regionId')]", 65 | "tags": { 66 | }, 67 | "properties": { 68 | "runbookType": "[parameters('runbookType')]", 69 | "logProgress": "false", 70 | "logVerbose": "false", 71 | "description": "[parameters('runbookDescription')]", 72 | "draft": { 73 | "draftContentLink": { 74 | "uri": "[parameters('runbookURI')]", 75 | "version": "1.0.0.0" 76 | } 77 | } 78 | } 79 | } 80 | 81 | ], 82 | 83 | "outputs": { 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-runbooks/deployPublishedRunbook.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01#", 3 | "contentVersion": "1.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Automation account to use. If this account exists, check the SKU and tags to make sure they match the exisitng account." 9 | } 10 | }, 11 | "regionId": { 12 | "type": "string", 13 | "allowedValues": [ 14 | "Japan East", 15 | "East US 2", 16 | "West Europe", 17 | "Southeast Asia", 18 | "South Central US" 19 | ], 20 | "metadata": { 21 | "description": "The region the Automaiton account is located in." 22 | } 23 | }, 24 | "runbookName": { 25 | "type": "string", 26 | "metadata": { 27 | "description": "The name for the runbook. The name must match the name in the URI." 28 | } 29 | }, 30 | "runbookURI": { 31 | "type": "string", 32 | "metadata": { 33 | "description": "The URI for the runbook. " 34 | } 35 | }, 36 | "runbookType": { 37 | "type": "string", 38 | "allowedValues": [ 39 | "Graph", 40 | "Script" 41 | ], 42 | "metadata": { 43 | "description": "The type of runbook" 44 | } 45 | }, 46 | "runbookDescription": { 47 | "type": "string", 48 | "metadata": { 49 | "description": "The description of the runbook." 50 | } 51 | } 52 | 53 | }, 54 | "variables": { 55 | 56 | }, 57 | 58 | "resources": [ 59 | 60 | { 61 | "name": "[concat(parameters('accountName'), '/', parameters('runbookName'))]", 62 | "type": "Microsoft.Automation/automationAccounts/runbooks", 63 | "apiVersion": "2015-01-01-preview", 64 | "location": "[parameters('regionId')]", 65 | "tags": { 66 | }, 67 | "properties": { 68 | "runbookType": "Script", 69 | "logProgress": "false", 70 | "logVerbose": "false", 71 | "description": "[parameters('runbookDescription')]", 72 | "publishContentLink": { 73 | "uri": "[parameters('runbookURI')]", 74 | "version": "1.0.0.0" 75 | } 76 | 77 | } 78 | } 79 | 80 | ], 81 | 82 | "outputs": { 83 | } 84 | } 85 | 86 | -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-schedule/README.md: -------------------------------------------------------------------------------- 1 | # Create an Automation schedule and associate it with a runbook, 2 | 3 | This sample shows how to deploy an Azure Automation schedule. 4 | 5 | 6 | ## Parameter details 7 | 8 | | Name | Type | Details | 9 | | ------------- |:-------------:| -----------------------------------------------------------------: | 10 | | accountName | string | The name of the Automation account to deploy the schedule to. | 11 | | scheduleName | string | The name of the schedule. | 12 | | runbookName | string | he name of the runbook to associate the schedule with. | 13 | | startTime | securestring | The time to start the schedule on. This is a datetime in Automation. | 14 | | frequency | string | The frequency of the schedule. | 15 | | interval | securestring | The interval for the schedule to repeat on. | 16 | | jobScheduleGuid | string | The GUID for the job schedule. This identifier links the schedule to the runbook. | 17 | 18 | 19 | 20 | ## How to call this template from your template 21 | 22 | Copy and paste the following section into the resources block in your parent template. Make sure the values of **name** in the **variables('name')** or **parameters('name')** match the names you have specified your template. 23 | 24 | scheduleTemplate = https://raw.githubusercontent.com/azureautomation/automation-packs/master/000-base-automation-resource-templates/deploy-schedule/deployRunbookOnSchedule.json 25 | 26 | ```json 27 | { 28 | "apiVersion": "2015-01-01", 29 | "name": "nestedTemplateschedule", 30 | "type": "Microsoft.Resources/deployments", 31 | "dependsOn": [ 32 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 33 | ], 34 | "properties": { 35 | "mode": "incremental", 36 | "templateLink": { 37 | "uri": "[variables('scheduleTemplate')]", 38 | "contentVersion": "1.0" 39 | }, 40 | "parameters": { 41 | "accountName": { 42 | "value": "[parameters('accountName')]" 43 | }, 44 | "scheduleName": { 45 | "value": "[parameters('scheduleName')]" 46 | }, 47 | "runbookName": { 48 | "value": "[parameters('runbookName')]" 49 | }, 50 | "startTime": { 51 | "value": "[parameters('startTime')]" 52 | }, 53 | "frequency": { 54 | "value": "[parameters('frequency')]" 55 | }, 56 | "interval": { 57 | "value": "[parameters('interval')]" 58 | }, 59 | "jobScheduleGuid": { 60 | "value": "[parameters('jobScheduleGuid')]" 61 | } 62 | } 63 | } 64 | } 65 | 66 | ``` 67 | -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-schedule/deployRunbookOnSchedule.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01#", 3 | "contentVersion": "1.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Automation account to use. If this account exists, check the SKU and tags to make sure they match the exisitng account." 9 | } 10 | }, 11 | "scheduleName": { 12 | "type": "string", 13 | "metadata": { 14 | "description": "The name of the schedule." 15 | } 16 | }, 17 | "runbookName": { 18 | "type": "string", 19 | "metadata": { 20 | "description": "The name of the runbook to associate the schedule with." 21 | } 22 | }, 23 | "startTime": { 24 | "type": "string", 25 | "defaultValue": "12/30/2015 12:00:00", 26 | "metadata": { 27 | "description": "The time to start the schedule on. This is a datetime in Automation." 28 | } 29 | }, 30 | "frequency": { 31 | "type": "string", 32 | "allowedValues": [ 33 | "onetime", 34 | "hour", 35 | "day" 36 | ], 37 | "metadata": { 38 | "description": "The frequency of the schedule." 39 | } 40 | }, 41 | "interval": { 42 | "type": "int", 43 | "metadata": { 44 | "description": "The interval for the schedule to repeat on. " 45 | } 46 | }, 47 | "jobScheduleGuid": { 48 | "type": "string", 49 | "metadata": { 50 | "description": "The GUID for the job schedule. This identifier links the schedule to the runbook." 51 | } 52 | } 53 | }, 54 | "variables": { 55 | 56 | }, 57 | "resources": [ 58 | { 59 | "name": "[concat(parameters('accountName'), '/', parameters('scheduleName'))]", 60 | "type": "microsoft.automation/automationAccounts/schedules", 61 | "apiVersion": "2015-01-01-preview", 62 | "tags": { }, 63 | "properties": { 64 | "description": "My schedule description", 65 | "startTime": "[parameters('startTime')]", 66 | "isEnabled": "true", 67 | "interval": "[parameters('interval')]", 68 | "frequency": "[parameters('frequency')]" 69 | } 70 | }, 71 | 72 | { 73 | "name": "[concat(parameters('accountName'), '/', parameters('jobScheduleGuid'))]", 74 | "type": "microsoft.automation/automationAccounts/jobSchedules", 75 | "apiVersion": "2015-01-01-preview", 76 | "dependsOn": [ 77 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'), '/schedules/', parameters('scheduleName'))]" 78 | ], 79 | "tags": { }, 80 | "properties": { 81 | "schedule": { 82 | "name": "[parameters('scheduleName')]" 83 | }, 84 | "runbook": { 85 | "name": "[ parameters('runbookName')]" 86 | } 87 | } 88 | } 89 | 90 | 91 | ], 92 | "outputs": { 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-variable/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Automation variable 3 | 4 | This template creates a variable in an existing Automation account. You can deploy an unencrypted variable or an encyrpted variable. Update the variableTemplate in the template Link URI to deploy the type of variable that you 5 | want. 6 | 7 | 8 | ## Parameter details 9 | 10 | | Name | Type | Details | 11 | | ------------- |:-------------: | ----------------------------------------------------------------:| 12 | | accountName | string | The name of the Automation account to deploy the variable to. | 13 | | variableName | string | The name of the variable. | 14 | | variableType | string | The type of variable. | 15 | | variableValue | string or securestring | The value of the variable. | 16 | 17 | ## How to call this template from your template 18 | 19 | Copy and paste the following section into the resources block in your parent template. Make sure the values of **name** in the **variables('name')** or **parameters('name')** match the names you have specified your template. 20 | 21 | Unencrypted value for variableTemplate = "https://raw.githubusercontent.com/azureautomation/automation-packs/master/000-base-automation-resource-templates/deploy-variable/deployVariable.json" 22 | 23 | Encrypted value for variableTemplate = "https://raw.githubusercontent.com/azureautomation/automation-packs/master/000-base-automation-resource-templates/deploy-variable/deployEncryptedVariable.json" 24 | 25 | ```json 26 | { 27 | "apiVersion": "2015-01-01", 28 | "name": "nestedTemplatevariable", 29 | "type": "Microsoft.Resources/deployments", 30 | "dependsOn": [ 31 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 32 | ], 33 | "properties": { 34 | "mode": "incremental", 35 | "templateLink": { 36 | "uri": "[variables('variableTemplate')]", 37 | "contentVersion": "1.0" 38 | }, 39 | "parameters": { 40 | "accountName": { 41 | "value": "[parameters('accountName')]" 42 | }, 43 | "variableName": { 44 | "value": "[parameters('variableName')]" 45 | }, 46 | "variableType": { 47 | "value": "[parameters('variableType')]" 48 | }, 49 | "variableValue": { 50 | "value": "[parameters('variableValue')]" 51 | } 52 | } 53 | } 54 | } 55 | 56 | ``` 57 | -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-variable/deployEncryptedVariable.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01-preview#", 3 | "contentVersion": "1.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Azure Automation account to deploy to." 9 | } 10 | }, 11 | "variableName": { 12 | "type": "string", 13 | "metadata": { 14 | "description": "The name of the variable" 15 | } 16 | }, 17 | "variableType": { 18 | "type": "string", 19 | "defaultValue" : "string", 20 | "allowedValues": [ 21 | "string", 22 | "integer", 23 | "dateTime", 24 | "boolean" 25 | ], 26 | "metadata": { 27 | "description": "The variable type." 28 | } 29 | }, 30 | "variableValue": { 31 | "type": "securestring", 32 | "metadata": { 33 | "description": "The value for the variable. Make sure the value for the variable matches the type selected." 34 | } 35 | } 36 | }, 37 | "variables": { 38 | 39 | }, 40 | "resources": [ 41 | 42 | { 43 | "name": "[concat(parameters('accountName'), '/', parameters('variableName')) ]", 44 | "type" : "microsoft.automation/automationAccounts/variables", 45 | "apiVersion": "2015-01-01-preview", 46 | "location": "[parameters('regionId')]", 47 | "tags": { }, 48 | "properties": { 49 | "description": "", 50 | "isEncrypted": 1, 51 | "type": "[parameters('variableType')]", 52 | "value": "[concat('\"', parameters('variableValue'),'\"')]" 53 | } 54 | } 55 | ], 56 | 57 | "outputs": {} 58 | } -------------------------------------------------------------------------------- /000-base-automation-resource-templates/deploy-variable/deployVariable.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01-preview#", 3 | "contentVersion": "1.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Azure Automation account to deploy to." 9 | } 10 | }, 11 | "variableName": { 12 | "type": "string", 13 | "metadata": { 14 | "description": "The name of the variable" 15 | } 16 | }, 17 | "variableType": { 18 | "type": "string", 19 | "allowedValues": [ 20 | "string", 21 | "integer", 22 | "dateTime", 23 | "boolean" 24 | ], 25 | "metadata": { 26 | "description": "The variable type." 27 | } 28 | }, 29 | "variableValue": { 30 | "type": "string", 31 | "metadata": { 32 | "description": "The value for the variable. Make sure the value for the variable matches the type selected." 33 | } 34 | } 35 | }, 36 | "variables": { 37 | 38 | }, 39 | "resources": [ 40 | 41 | { 42 | "name": "[concat(parameters('accountName'), '/', parameters('variableName')) ]", 43 | "type" : "microsoft.automation/automationAccounts/variables", 44 | "apiVersion": "2015-01-01-preview", 45 | "tags": { }, 46 | "properties": { 47 | "description": "", 48 | "isEncrypted": 0, 49 | "type": "[parameters('variableType')]", 50 | "value": "[concat('\"', parameters('variableValue'),'\"')]" 51 | } 52 | } 53 | ], 54 | 55 | "outputs": {} 56 | } -------------------------------------------------------------------------------- /101-get-vm-tutorial/DeployThroughARM.ps1: -------------------------------------------------------------------------------- 1 |  2 | #Connect to your Azure account 3 | Add-AzureRmAccount 4 | 5 | #Select your subscription if you have more than one 6 | #Select-AzureRmSubscription -SubscriptionId "Your subcription ID here" 7 | 8 | #Create a GUID for the job 9 | $JobGUID = [System.Guid]::NewGuid().toString() 10 | 11 | #Set the parameter values for the template 12 | $Params = @{ 13 | "accountName" = "MyAccount2" ; 14 | "regionId" = "Japan East"; 15 | "userName" = "Your UserName"; 16 | "password" = "Your password"; 17 | } 18 | 19 | $TemplateURI = "https://raw.githubusercontent.com/azureautomation/automation-packs/master/101-get-vm-tutorial/azuredeploy.json" 20 | New-AzureRMResourceGroupDeployment -TemplateParameterObject $Params -ResourceGroupName "bethgroup1" -TemplateUri $TemplateURI 21 | -------------------------------------------------------------------------------- /101-get-vm-tutorial/README.md: -------------------------------------------------------------------------------- 1 | # Create VM tutorial runbook, Automation credential, and start a job 2 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fazureautomation%2Fautomation-packs%2Fmaster%2F101-get-vm-tutorial%2Fazuredeploy.json) 3 | 4 | 5 | This sample shows how you can deploy a runbook, a credential the runbook relies on, and how to start a job through an Azure Resource Manager template. 6 | 7 | It contains a sample script, Deploy-ThroughARM, that you can use to get you started with the deployment from PowerShell. 8 | 9 | ##Resources Deployed 10 | ###Automation Account 11 | This is the account that will contain your runbook and credentials. If you want to deploy to an existing account, make sure that the Resource Group, region, tags, and SKU in the template are all the same as your existing account, otherwise the properties will be overwritten. 12 | 13 | ###Runbook 14 | The runbook provides an example of how you can authenticate to Azure and use Azure cmdlets in a runbook. It uses an Azure AD organizational ID to connect to Azure. It then prints out the first 10 VMs in your account. 15 | 16 | ###Credential 17 | The credential should contain the username and password of the Azure AD organizational ID to connect to Azure. To learn about how to create this user, see [Get set up to automate Azure]("http://aka.ms/getsetuptoautomate") and check out this blog post [Authenticating to Azure using Active Directory]("http://azure.microsoft.com/blog/2014/08/27/azure-automation-authenticating-to-azure-using-azure-active-directory/"). 18 | 19 | ###Job 20 | A job will be triggered once the other resources are deployed. The job needs a unique GUID as the jobId. You can use this to identify the job later in your script and to retrieve the job output. -------------------------------------------------------------------------------- /101-get-vm-tutorial/Runbooks/AzureAlertContext.ps1: -------------------------------------------------------------------------------- 1 | workflow AzureAlertContext 2 | { 3 | 4 | param ( 5 | [object]$WebhookData 6 | ) 7 | 8 | # If runbook was called from Webhook, WebhookData will not be null. 9 | if ($WebhookData -ne $null) { 10 | 11 | # Collect properties of WebhookData. 12 | $WebhookName = $WebhookData.WebhookName 13 | $WebhookHeaders = $WebhookData.RequestHeader 14 | $WebhookBody = $WebhookData.RequestBody 15 | 16 | # Collect individual headers. 17 | $From = $WebhookHeaders.From 18 | Write-Output "Runbook started from webhook $WebhookName by $From." 19 | 20 | # Display data passed through. 21 | $Data = (ConvertFrom-Json -InputObject $WebhookBody) 22 | Write-Output $Data 23 | } 24 | else { 25 | Write-Error "Runbook meant to be started only from webhook." 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /101-get-vm-tutorial/Runbooks/Get-AzureVMTutorial.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .DESCRIPTION 3 | An example runbook which prints out the first 10 Azure VMs in your subscription (ordered alphabetically). 4 | For more information about how this runbook authenticates to your Azure subscription, see our documentation here: http://aka.ms/fxu3mn 5 | 6 | .NOTES 7 | AUTHOR: Azure Automation Team 8 | LASTEDIT: Mar 27, 2015 9 | #> 10 | workflow Get-AzureVMTutorial 11 | { 12 | #The name of the Automation Credential Asset this runbook will use to authenticate to Azure. 13 | $CredentialAssetName = 'DefaultAzureCredential' 14 | 15 | #Get the credential with the above name from the Automation Asset store 16 | $Cred = Get-AutomationPSCredential -Name $CredentialAssetName 17 | if(!$Cred) { 18 | Throw "Could not find an Automation Credential Asset named '${CredentialAssetName}'. Make sure you have created one in this Automation Account." 19 | } 20 | 21 | #Connect to your Azure Account 22 | $Account = Add-AzureAccount -Credential $Cred 23 | if(!$Account) { 24 | Throw "Could not authenticate to Azure using the credential asset '${CredentialAssetName}'. Make sure the user name and password are correct." 25 | } 26 | 27 | #TODO (optional): pick the right subscription to use. Without this line, the default subscription for your Azure Account will be used. 28 | #Select-AzureSubscription -SubscriptionName "TODO: your Azure subscription name here" 29 | 30 | #Get all the VMs you have in your Azure subscription 31 | $VMs = Get-AzureVM 32 | 33 | #Print out up to 10 of those VMs 34 | if(!$VMs) { 35 | Write-Output "No VMs were found in your subscription." 36 | } else { 37 | Write-Output $VMs[0..9] 38 | } 39 | } -------------------------------------------------------------------------------- /101-get-vm-tutorial/azuredeploy-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "accountName": { 3 | "value": "MyAutomationAccount" 4 | }, 5 | "jobId": { 6 | "value": "e6abf1fd-6311-4442-ac1a-22aae3cacdae" 7 | }, 8 | "regionId": { 9 | "value": "East US 2" 10 | }, 11 | "userName": { 12 | "value": "MyAzureADUser" 13 | }, 14 | "password": { 15 | "value": "MyAzureADPassword" 16 | } 17 | } -------------------------------------------------------------------------------- /101-get-vm-tutorial/azuredeploy.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01-preview#", 3 | "contentVersion": "1.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Azure Automation account to deploy to." 9 | } 10 | }, 11 | "regionId": { 12 | "type": "string", 13 | "allowedValues": [ 14 | "Japan East", 15 | "East US 2", 16 | "West Europe", 17 | "Southeast Asia", 18 | "South Central US" 19 | ], 20 | "metadata": { 21 | "description": "The region to deploy the Automation account in." 22 | } 23 | }, 24 | "userName": { 25 | "type": "string", 26 | "metadata": { 27 | "description": "The username for the Azure Automation credential." 28 | } 29 | }, 30 | "password": { 31 | "type": "securestring", 32 | "metadata": { 33 | "description": "The password for the Azure Automation credential." 34 | } 35 | }, 36 | "jobId": { 37 | "type": "string", 38 | "metadata": { 39 | "description": "The GUID for the runbook job to be started." 40 | } 41 | } 42 | }, 43 | "variables": { 44 | "runbookName": "Get-AzureVMTutorial", 45 | "scriptUri": "https://raw.githubusercontent.com/azureautomation/automation-packs/master/101-get-vm-tutorial/Runbooks/Get-AzureVMTutorial.ps1", 46 | "runbookDescription": "Authenticates to Azure and lists all the Azure V1 VMs", 47 | "credentialName": "DefaultAzureCredential", 48 | "sku": "Free" 49 | }, 50 | "resources": [ 51 | { 52 | "name": "[parameters('accountName')]", 53 | "type": "Microsoft.Automation/automationAccounts", 54 | "apiVersion": "2015-01-01-preview", 55 | "location": "[parameters('regionId')]", 56 | "dependsOn": [], 57 | "tags": {}, 58 | "properties": { 59 | "sku": { 60 | "name": "[variables('sku')]" 61 | } 62 | }, 63 | "resources": [ 64 | { 65 | "name": "[variables('runbookName')]", 66 | "type": "runbooks", 67 | "apiVersion": "2015-01-01-preview", 68 | "location": "[parameters('regionId')]", 69 | "dependsOn": [ 70 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 71 | ], 72 | "tags": {}, 73 | "properties": { 74 | "runbookType": "Script", 75 | "logProgress": "false", 76 | "logVerbose": "false", 77 | "description": "[variables('runbookDescription')]", 78 | "publishContentLink": { 79 | "uri": "[variables('scriptUri')]", 80 | "version": "1.0.0.0" 81 | } 82 | } 83 | }, 84 | { 85 | "name": "[variables('credentialName')]", 86 | "type": "credentials", 87 | "apiVersion": "2015-01-01-preview", 88 | "location": "[parameters('regionId')]", 89 | "dependsOn": [ 90 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 91 | ], 92 | "tags": {}, 93 | "properties": { 94 | "userName": "[parameters('userName')]", 95 | "password": "[parameters('password')]" 96 | } 97 | }, 98 | { 99 | "name": "[parameters('jobId')]", 100 | "type": "jobs", 101 | "apiVersion": "2015-01-01-preview", 102 | "location": "[parameters('regionId')]", 103 | "dependsOn": [ 104 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]", 105 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'), '/runbooks/',variables('runbookName'))]" 106 | ], 107 | "tags": { 108 | "key": "value" 109 | }, 110 | "properties": { 111 | "runbook": { 112 | "name": "[variables('runbookName')]" 113 | } 114 | } 115 | } 116 | ] 117 | } 118 | ], 119 | "outputs": {} 120 | } -------------------------------------------------------------------------------- /101-import-and-start-job/README.md: -------------------------------------------------------------------------------- 1 | # Import a runbook, and start a job using parameters 2 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fazureautomation%2Fautomation-packs%2Fmaster%2F101-import-and-start-job%2Fazuredeploy.json) 3 | 4 | This sample shows how you can deploy a runbook, a credential the runbook and start a job with parameters through an Azure Resource Manager template. 5 | 6 | ## Resources Deployed 7 | 8 | ### Automation Account 9 | 10 | This is the account that will contain your runbook and credentials. If you want to deploy to an existing account, make sure that the Resource Group, region, tags, and SKU in the template are all the same as your existing account, otherwise the properties will be overwritten. 11 | 12 | ### Runbook 13 | 14 | The runbook is a simple hello world PowerShell script that takes in a json string of name:value parameters that is converted to a PowerShell object and then writes out hello. 15 | 16 | ### Job 17 | 18 | A job will be triggered once the other resources are deployed. The job needs a unique GUID as the jobId. This is determined by getting a unique guid based on the resource group and deployment name, subscription, and runbook name using [guid(subscription().subscriptionId, resourceGroup().id, deployment().name, parameters('runbookName'))]. If you redeploy this template then you should give a different name for the deployment to ensure a new job gets created. -------------------------------------------------------------------------------- /101-import-and-start-job/Runbooks/Hello-World.ps1: -------------------------------------------------------------------------------- 1 | param ( 2 | [Parameter(Mandatory=$False)] 3 | $JsonParameterList = '{"Name":"World"}' 4 | ) 5 | $ErrorActionPreference = 'stop' 6 | $Params = ConvertFrom-Json $JsonParameterList 7 | 8 | Write-Output ("Hello " + $Params.Name) -------------------------------------------------------------------------------- /101-import-and-start-job/azuredeploy-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "accountName": { 3 | "value": "ContosoAccountEamon1" 4 | }, 5 | "runbookUri": { 6 | "value": "https://raw.githubusercontent.com/azureautomation/automation-packs/master/101-import-and-start-job/Runbooks/Hello-World.ps1" 7 | }, 8 | "runbookName": { 9 | "value": "Hello-World" 10 | }, 11 | "runbookParameters": { 12 | "value": "'{\"Name\": \"Automation\"}'" 13 | }, 14 | "regionId": { 15 | "value": "West Central US" 16 | } 17 | } -------------------------------------------------------------------------------- /101-import-and-start-job/azuredeploy.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Azure Automation account to deploy to." 9 | } 10 | }, 11 | "regionId": { 12 | "type": "string", 13 | "allowedValues": [ 14 | "Japan East", 15 | "East US 2", 16 | "West Europe", 17 | "Southeast Asia", 18 | "South Central US", 19 | "West Central US", 20 | "Canada Central", 21 | "Brazil South", 22 | "North Europe", 23 | "UK South", 24 | "Austrialia Southeast" 25 | ], 26 | "metadata": { 27 | "description": "The region to deploy the Automation account in." 28 | } 29 | }, 30 | "runbookUri": { 31 | "type": "string", 32 | "defaultValue": "https://raw.githubusercontent.com/azureautomation/automation-packs/master/101-import-and-start-job/Runbooks/Hello-World.ps1", 33 | "metadata": { 34 | "description": "The Uri of the runbook to import into the account" 35 | } 36 | }, 37 | "runbookName": { 38 | "type": "string", 39 | "defaultValue": "Hello-World", 40 | "metadata": { 41 | "description": "The name of the runbook to start." 42 | } 43 | }, 44 | "runbookParameters": { 45 | "type": "string", 46 | "defaultValue": "'{\"Name\": \"Automation\"}'", 47 | "metadata": { 48 | "description": "Parameters for the runbook in json format. Example '{\"Name\": \"Automation\"}'" 49 | } 50 | } 51 | }, 52 | "variables": { 53 | "sku": "Basic" 54 | }, 55 | "resources": [ 56 | { 57 | "name": "[parameters('accountName')]", 58 | "type": "Microsoft.Automation/automationAccounts", 59 | "apiVersion": "2015-10-31", 60 | "location": "[parameters('regionId')]", 61 | "dependsOn": [], 62 | "tags": {}, 63 | "properties": { 64 | "sku": { 65 | "name": "[variables('sku')]" 66 | } 67 | }, 68 | "resources": [ 69 | { 70 | "name": "[parameters('runbookName')]", 71 | "type": "runbooks", 72 | "apiVersion": "2015-10-31", 73 | "location": "[parameters('regionId')]", 74 | "dependsOn": [ 75 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 76 | ], 77 | "tags": {}, 78 | "properties": { 79 | "runbookType": "PowerShell", 80 | "logProgress": false, 81 | "logVerbose": false, 82 | "description": "", 83 | "publishContentLink": { 84 | "uri": "[parameters('runbookUri')]", 85 | "version": "1.0.0.0" 86 | } 87 | } 88 | }, 89 | { 90 | "name": "[guid(subscription().subscriptionId, resourceGroup().id, deployment().name, parameters('runbookName'))]" , 91 | "type": "jobs", 92 | "apiVersion": "2015-10-31", 93 | "location": "[parameters('regionId')]", 94 | "dependsOn": [ 95 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]", 96 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'), '/runbooks/',parameters('runbookName'))]" 97 | ], 98 | "tags": { 99 | "key": "value" 100 | }, 101 | "properties": { 102 | "runbook": { 103 | "name": "[parameters('runbookName')]" 104 | }, 105 | "parameters":{ 106 | "JsonParameterList":"[parameters('runbookParameters')]" 107 | } 108 | } 109 | } 110 | ] 111 | } 112 | ], 113 | "outputs": {} 114 | } -------------------------------------------------------------------------------- /101-remove-resourcegroups/DeployThroughARM.ps1: -------------------------------------------------------------------------------- 1 |  2 | #Connect to your Azure account 3 | Add-AzureRmAccount 4 | 5 | #Select your subscription if you have more than one 6 | #Select-AzureRmSubscription -SubscriptionId "Your subcription ID here" 7 | 8 | #Create a GUID for the job 9 | $JobGUID = [System.Guid]::NewGuid().toString() 10 | 11 | #Set the parameter values for the template 12 | $Params = @{ 13 | "accountName" = "MyAccount2" ; 14 | "regionId" = "Japan East"; 15 | "userName" = "Your UserName"; 16 | "password" = "Your password"; 17 | } 18 | 19 | $TemplateURI = "https://raw.githubusercontent.com/azureautomation/automation-packs/master/101-remove-resourcegroups/azuredeploy.json" 20 | New-AzureRMResourceGroupDeployment -TemplateParameterObject $Params -ResourceGroupName "AzureAutomationRG" -TemplateUri $TemplateURI 21 | -------------------------------------------------------------------------------- /101-remove-resourcegroups/README.md: -------------------------------------------------------------------------------- 1 | # Remove ResourceGroups runbook and Automation credential 2 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fazureautomation%2Fautomation-packs%2Fmaster%2F101-remove-resourcegroups%2Fazuredeploy.json) 3 | 4 | This deploys the Remove-ResourceGroups runbook to an Azure Automation account (or a new one will be created for you) and a credential the runbook relies on. 5 | 6 | ## Resources Deployed 7 | 8 | ### Automation Account 9 | This is the account that will contain your runbook and credentials. If you want to deploy to an existing account, make sure that the Resource Group, region, tags, and SKU in the template are all the same as your existing account, otherwise the properties will be overwritten. 10 | 11 | ###Runbook 12 | This runbook connects to Azure and removes all resource groups which match the name filter. You can run across multiple subscriptions, delete all resource groups, or run in preview mode. 13 | 14 | ###Credential 15 | The credential should contain the username and password of the Azure AD organizational ID to connect to Azure. To learn about how to create this user, see [Get set up to automate Azure]("http://aka.ms/getsetuptoautomate") and check out this blog post [Authenticating to Azure using Active Directory]("http://azure.microsoft.com/blog/2014/08/27/azure-automation-authenticating-to-azure-using-azure-active-directory/"). -------------------------------------------------------------------------------- /101-remove-resourcegroups/azuredeploy-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "accountName": { 3 | "value": "MyAutomationAccount" 4 | }, 5 | "regionId": { 6 | "value": "East US 2" 7 | }, 8 | "userName": { 9 | "value": "MyAzureADUser" 10 | }, 11 | "password": { 12 | "value": "MyAzureADPassword" 13 | } 14 | } -------------------------------------------------------------------------------- /101-remove-resourcegroups/azuredeploy.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Azure Automation account to deploy to." 9 | } 10 | }, 11 | "password": { 12 | "type": "securestring", 13 | "metadata": { 14 | "description": "The password for the Azure Automation credential." 15 | } 16 | }, 17 | "regionId": { 18 | "type": "string", 19 | "allowedValues": [ 20 | "Japan East", 21 | "East US 2", 22 | "West Europe", 23 | "Southeast Asia", 24 | "South Central US" 25 | ], 26 | "metadata": { 27 | "description": "The region to deploy the Automation account in." 28 | } 29 | }, 30 | "userName": { 31 | "type": "string", 32 | "metadata": { 33 | "description": "The username for the Azure Automation credential." 34 | } 35 | } 36 | }, 37 | "variables": { 38 | "runbookName": "Remove-ResourceGroups", 39 | "scriptUri": "https://raw.githubusercontent.com/azureautomation/runbooks/master/Utility/Remove-ResourceGroups.ps1", 40 | "runbookDescription": "Connects to Azure and removes all resource groups which match the name filter.", 41 | "credentialName": "DefaultAzureCredential", 42 | "sku": "Free" 43 | }, 44 | "resources": [ 45 | { 46 | "name": "[parameters('accountName')]", 47 | "type": "Microsoft.Automation/automationAccounts", 48 | "apiVersion": "2015-10-31", 49 | "location": "[parameters('regionId')]", 50 | "dependsOn": [], 51 | "tags": {}, 52 | "properties": { 53 | "sku": { 54 | "name": "[variables('sku')]" 55 | } 56 | }, 57 | "resources": [ 58 | { 59 | "name": "[variables('runbookName')]", 60 | "type": "runbooks", 61 | "apiVersion": "2015-10-31", 62 | "location": "[parameters('regionId')]", 63 | "dependsOn": [ 64 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 65 | ], 66 | "tags": {}, 67 | "properties": { 68 | "runbookType": "Script", 69 | "logProgress": "false", 70 | "logVerbose": "false", 71 | "description": "[variables('runbookDescription')]", 72 | "publishContentLink": { 73 | "uri": "[variables('scriptUri')]", 74 | "version": "1.0.0.0" 75 | } 76 | } 77 | }, 78 | { 79 | "name": "[variables('credentialName')]", 80 | "type": "credentials", 81 | "apiVersion": "2015-10-31", 82 | "location": "[parameters('regionId')]", 83 | "dependsOn": [ 84 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 85 | ], 86 | "tags": {}, 87 | "properties": { 88 | "userName": "[parameters('userName')]", 89 | "password": "[parameters('password')]" 90 | } 91 | } 92 | ] 93 | } 94 | ], 95 | "outputs": {} 96 | } -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-certificate/README.md: -------------------------------------------------------------------------------- 1 | # Create an Automation certificate 2 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fazureautomation%2Fautomation-packs%2Fmaster%2F101-sample-deploy-automation-resources%2Fsample-deploy-certificate%2FdeployCertificate.json) 3 | 4 | 5 | This sample shows how to deploy an Azure Automation certificate asset. 6 | 7 | ##Resources Deployed 8 | ###Automation Account 9 | This is the account that will contain your certificate. 10 | 11 | If you want to deploy to an existing account, make sure that the Resource Group, region, tags, and pricing tier in the template are all the same as the account you want to deploy the certificate in. 12 | 13 | ###Certificate 14 | The certificate to deploy to Azure Automation. 15 | 16 | -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-certificate/azuredeploy-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "accountName": { 3 | "value": "MyAutomationAccount" 4 | }, 5 | "regionId": { 6 | "value": "East US 2" 7 | }, 8 | "pricingTier":{ 9 | "value":"Free" 10 | }, 11 | "certName": { 12 | "value": "MyCert" 13 | }, 14 | "base64Value": { 15 | "value":"insertBase64CertificateValueHere" 16 | }, 17 | "thumbprint": { 18 | "value": "insertThumbprintHere" 19 | } 20 | } -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-certificate/deployCertificate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01-preview#", 3 | "contentVersion": "1.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Azure Automation account to deploy to." 9 | } 10 | }, 11 | "regionId": { 12 | "type": "string", 13 | "allowedValues": [ 14 | "Japan East", 15 | "East US 2", 16 | "West Europe", 17 | "Southeast Asia", 18 | "South Central US" 19 | ], 20 | "metadata": { 21 | "description": "The region to deploy the Automation account in." 22 | } 23 | }, 24 | "pricingTier": { 25 | "type": "string", 26 | "allowedValues": [ 27 | "Free", 28 | "Basic" 29 | ], 30 | "metadata": { 31 | "description": "The pricing tier for the account." 32 | } 33 | }, 34 | "certName": { 35 | "type": "string", 36 | "metadata": { 37 | "description": "The name of the certificate." 38 | } 39 | }, 40 | "base64Value": { 41 | "type": "securestring", 42 | "metadata": { 43 | "description": "The base 64 value for the certificate." 44 | } 45 | }, 46 | "thumbprint": { 47 | "type": "securestring", 48 | "metadata": { 49 | "description": "The thumprint value for the certificate." 50 | } 51 | } 52 | }, 53 | "variables": { 54 | 55 | }, 56 | "resources": [ 57 | { 58 | "name": "[parameters('accountName')]", 59 | "type": "Microsoft.Automation/automationAccounts", 60 | "apiVersion": "2015-01-01-preview", 61 | "location": "[parameters('regionId')]", 62 | "dependsOn": [ ], 63 | "tags": { }, 64 | "properties": { 65 | "sku": { 66 | "name": "[parameters('pricingTier')]" 67 | } 68 | }, 69 | "resources": [ 70 | { 71 | "name": "[parameters('certName')]", 72 | "type": "certificates", 73 | "apiVersion": "2015-01-01-preview", 74 | "location": "[parameters('regionId')]", 75 | "dependsOn": [ 76 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 77 | ], 78 | "tags": { 79 | }, 80 | "properties": { 81 | "base64Value": "[parameters('base64Value')]", 82 | "thumbprint": "[parameters('thumbprint')]" 83 | } 84 | } 85 | ] 86 | } 87 | ], 88 | "outputs": { } 89 | } -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-connection/README.md: -------------------------------------------------------------------------------- 1 | # Create an Automation connection 2 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fazureautomation%2Fautomation-packs%2Fmaster%2F101-sample-deploy-automation-resources%2Fsample-deploy-connection%2FdeployConnection.json) 3 | 4 | 5 | This sample shows how to deploy an Azure Automation connection asset of type Azure. 6 | 7 | You must have a connection type created to be able to create a connect asset. To do this, you should include an Automation connection file in the module it is used with. This [blog](http://azure.microsoft.com/blog/2014/12/15/authoring-integration-modules-for-azure-automation/) talks more about creating your own modules and how to create a connection for your module. Since the Azure module has a connection file defined, you can create a connection of this type without having your own module. 8 | 9 | ##Resources Deployed 10 | ###Automation Account 11 | This is the account that will contain your connection asset. 12 | 13 | If you want to deploy to an existing account, make sure that the Resource Group, region, tags, and pricing tier in the template are all the same as the account you want to deploy the variable in. 14 | 15 | ###Connection 16 | The connection to deploy to Azure Automation. This particular connection will have the Azure connection properties (subscription ID, and certificate name). 17 | 18 | -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-connection/azuredeploy-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "accountName": { 3 | "value": "MyAutomationAccount" 4 | }, 5 | "regionId": { 6 | "value": "East US 2" 7 | }, 8 | "pricingTier":{ 9 | "value":"Free" 10 | }, 11 | "variableName": { 12 | "value": "MyVariableName" 13 | }, 14 | "variableValue": { 15 | "value": "MyStringValue" 16 | } 17 | } -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-connection/deployConnection.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01-preview#", 3 | "contentVersion": "1.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Azure Automation account to deploy to." 9 | } 10 | }, 11 | "regionId": { 12 | "type": "string", 13 | "allowedValues": [ 14 | "Japan East", 15 | "East US 2", 16 | "West Europe", 17 | "Southeast Asia", 18 | "South Central US" 19 | ], 20 | "metadata": { 21 | "description": "The region to deploy the Automation account in." 22 | } 23 | }, 24 | "pricingTier": { 25 | "type": "string", 26 | "allowedValues": [ 27 | "Free", 28 | "Basic" 29 | ], 30 | "metadata": { 31 | "description": "The pricing tier for the account." 32 | } 33 | }, 34 | "connectionName": { 35 | "type": "string", 36 | "metadata": { 37 | "description": "The name of the Azure Automation connection asset. The connection type must be deployed before you can deploy the connection. In this case, we are using Azure since that is created for all users." 38 | } 39 | }, 40 | "connectionCertificateName": { 41 | "type": "string", 42 | "metadata": { 43 | "description": "The name of the certificate used for Azure auth." 44 | } 45 | }, 46 | "connectionSubscriptionId": { 47 | "type": "string", 48 | "metadata": { 49 | "description": "The ID of the Azure subscription you want to connect to." 50 | } 51 | } 52 | }, 53 | "variables": { 54 | 55 | }, 56 | "resources": [ 57 | { 58 | "name": "[parameters('accountName')]", 59 | "type": "Microsoft.Automation/automationAccounts", 60 | "apiVersion": "2015-01-01-preview", 61 | "location": "[parameters('regionId')]", 62 | "dependsOn": [ ], 63 | "tags": { }, 64 | "properties": { 65 | "sku": { 66 | "name": "[parameters('pricingTier')]" 67 | } 68 | }, 69 | "resources": [ 70 | 71 | { 72 | "name": "[parameters('connectionName')]", 73 | "type": "connections", 74 | "apiVersion": "2015-01-01-preview", 75 | "location": "[parameters('regionId')]", 76 | "dependsOn": [ 77 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 78 | ], 79 | "tags": { 80 | }, 81 | "properties": { 82 | "name": "[parameters('connectionName')]", 83 | "description": "Dummy Azure connection", 84 | "isGlobal": false, 85 | "connectionType": { 86 | "name": "Azure" 87 | }, 88 | "fieldDefinitionValues": { 89 | "AutomationCertificateName": "[parameters('connectionCertificateName')]", 90 | "SubscriptionID": "[parameters('connectionSubscriptionId')]" 91 | } 92 | } 93 | 94 | } 95 | ] 96 | } 97 | ], 98 | "outputs": { } 99 | } -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-credential/README.md: -------------------------------------------------------------------------------- 1 | # Create an Automation credential 2 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fazureautomation%2Fautomation-packs%2Fmaster%2F101-sample-deploy-automation-resources%2Fsample-deploy-credential%2FdeployCredential.json) 3 | 4 | 5 | This sample shows how to deploy an Azure Automation credential asset. 6 | 7 | ##Resources Deployed 8 | ###Automation Account 9 | This is the account that will contain your credential. 10 | 11 | If you want to deploy to an existing account, make sure that the Resource Group, region, tags, and SKU in the template are all the same as the account you want to deploy the credential in. 12 | 13 | ###Credential 14 | The credential contains the username and password that you provide. 15 | 16 | -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-credential/azuredeploy-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "accountName": { 3 | "value": "MyAutomationAccount" 4 | }, 5 | "regionId": { 6 | "value": "East US 2" 7 | }, 8 | "pricingTier":{ 9 | "value":"Free" 10 | }, 11 | "credentialName": { 12 | "value": "DefaultAzureCredential" 13 | }, 14 | "userName": { 15 | "value": "MyAzureADUser" 16 | }, 17 | "password": { 18 | "value": "MyAzureADPassword" 19 | } 20 | } -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-credential/deployCredential.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01-preview#", 3 | "contentVersion": "1.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Azure Automation account to deploy to." 9 | } 10 | }, 11 | "regionId": { 12 | "type": "string", 13 | "allowedValues": [ 14 | "Japan East", 15 | "East US 2", 16 | "West Europe", 17 | "Southeast Asia", 18 | "South Central US" 19 | ], 20 | "metadata": { 21 | "description": "The region to deploy the Automation account in." 22 | } 23 | }, 24 | "pricingTier": { 25 | "type": "string", 26 | "allowedValues": [ 27 | "Free", 28 | "Basic" 29 | ], 30 | "metadata": { 31 | "description": "The pricing tier for the account." 32 | } 33 | }, 34 | "credentialName": { 35 | "type": "string", 36 | "metadata": { 37 | "description": "The name of the credential to deploy." 38 | } 39 | }, 40 | "userName": { 41 | "type": "string", 42 | "metadata": { 43 | "description": "The username for the Azure Automation credential." 44 | } 45 | }, 46 | "password": { 47 | "type": "secureString", 48 | "metadata": { 49 | "description": "The password for the Azure Automation credential." 50 | } 51 | } 52 | }, 53 | "variables": { 54 | 55 | }, 56 | "resources": [ 57 | { 58 | "name": "[parameters('accountName')]", 59 | "type": "Microsoft.Automation/automationAccounts", 60 | "apiVersion": "2015-01-01-preview", 61 | "location": "[parameters('regionId')]", 62 | "dependsOn": [], 63 | "tags": {}, 64 | "properties": { 65 | "sku": { 66 | "name": "[parameters('pricingTier')]" 67 | } 68 | }, 69 | "resources": [ 70 | { 71 | "name": "[parameters('credentialName')]", 72 | "type": "credentials", 73 | "apiVersion": "2015-01-01-preview", 74 | "location": "[parameters('regionId')]", 75 | "dependsOn": [ 76 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 77 | ], 78 | "tags": {}, 79 | "properties": { 80 | "userName": "[parameters('userName')]", 81 | "password": "[parameters('password')]" 82 | } 83 | } 84 | ] 85 | } 86 | ], 87 | "outputs": {} 88 | } -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-module/DeployModule.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01#", 3 | "contentVersion": "1.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Automation account to use. If this account exists, check the SKU and tags to make sure they match the exisitng account." 9 | } 10 | }, 11 | "location": { 12 | "type": "string", 13 | "allowedValues": [ 14 | "Japan East", 15 | "East US 2", 16 | "West Europe", 17 | "Southeast Asia", 18 | "South Central US" 19 | ], 20 | "metadata": { 21 | "description": "The region to deploy the Automation account in." 22 | } 23 | }, 24 | "moduleName": { 25 | "type": "string", 26 | "defaultValue": "Hello-WorldModule", 27 | "metadata": { 28 | "description": "The name of the module to deploy. This must be the same name as the .zip foldername." 29 | } 30 | }, 31 | "moduleUri": { 32 | "type": "string", 33 | "defaultValue": "https://github.com/azureautomation/automation-packs/raw/7c2a7c901099b384a05e17261d3c6b4192e841b4/101-sample-automation-resource-templates/sample-deploy-module/modules/Hello-WorldModule.zip", 34 | "metadata": { 35 | "description": "The URL for the module zip file to upload to Azure Automation. To learn about authoring modules for Automation see: http://azure.microsoft.com/blog/2014/12/15/authoring-integration-modules-for-azure-automation/" 36 | } 37 | } 38 | 39 | }, 40 | "variables": { 41 | 42 | }, 43 | "resources": [ 44 | { 45 | "name": "[parameters('accountName')]", 46 | "type": "Microsoft.Automation/automationAccounts", 47 | "apiVersion": "2015-01-01-preview", 48 | "location": "[parameters('location')]", 49 | "dependsOn": [ 50 | ], 51 | "tags": { 52 | "key": "value" 53 | }, 54 | "properties": { 55 | "comment": "Resource defined structure", 56 | "sku": { 57 | "name": "Free" 58 | } 59 | }, 60 | "resources": [ 61 | { 62 | "name": "[parameters('moduleName')]", 63 | "type": "modules", 64 | "apiVersion": "2015-01-01-preview", 65 | "location": "[parameters('location')]", 66 | "dependsOn": [ 67 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 68 | ], 69 | "tags": { 70 | }, 71 | "properties": { 72 | "contentLink": { 73 | "uri": "[parameters('moduleUri')]" 74 | } 75 | } 76 | } 77 | 78 | ] 79 | } 80 | ], 81 | 82 | "outputs": { 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-module/README.md: -------------------------------------------------------------------------------- 1 | # Deploy a module to an Automation Account 2 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fazureautomation%2Fautomation-packs%2Fmaster%2F101-sample-deploy-automation-resources%2Fsample-deploy-module%2FDeployModule.json) 3 | 4 | 5 | This sample shows how to deploy a module to Azure Automation. 6 | 7 | ##Resources Deployed 8 | ###Automation Account 9 | This is the account that will contain the module you are deploying. 10 | 11 | If you want to deploy to an existing account, make sure that the region, tags, and SKU in the template are all the same as your existing account, otherwise the properties will be overwritten. 12 | 13 | ###Module 14 | The default values for the module deployed in this template is a hello world sample used to show how you can deploy a module. 15 | 16 | To deploy your own module with this template, modify the following parameters: 17 | 18 | - **moduleName**: this parameter contains the name of the module to deploy 19 | - **moduleUri**: the URL for the module zip file to upload to Azure Automation. To learn about authoring modules for Automation see: [Authoring Integration Modules](http://azure.microsoft.com/blog/2014/12/15/authoring-integration-modules-for-azure-automation/) -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-module/azuredeploy-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "accountName": { 3 | "value": "MyAutomationAccount" 4 | }, 5 | "location": { 6 | "value": "Japan East" 7 | } 8 | } -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-module/modules/Hello-WorldModule.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/azureautomation/automation-packs/c03d72f994e74385091f6e631cfd906bfcba0073/101-sample-automation-resource-templates/sample-deploy-module/modules/Hello-WorldModule.zip -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-module/modules/Hello-WorldModule/Hello-WorldModule.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/azureautomation/automation-packs/c03d72f994e74385091f6e631cfd906bfcba0073/101-sample-automation-resource-templates/sample-deploy-module/modules/Hello-WorldModule/Hello-WorldModule.psd1 -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-module/modules/Hello-WorldModule/Hello-WorldModule.psm1: -------------------------------------------------------------------------------- 1 |  2 | function Say-Hello 3 | { 4 | param( 5 | [Parameter(Mandatory=$True)] 6 | [ValidateNotNullOrEmpty()] 7 | [string] 8 | $Name 9 | ) 10 | 11 | Write-Output "Hello $Name" 12 | 13 | } 14 | 15 | Export-ModuleMember * -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-runbooks/README.md: -------------------------------------------------------------------------------- 1 | # Creates three runbooks 2 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fazureautomation%2Fautomation-packs%2Fmaster%2F101-sample-deploy-automation-resources%2Fsample-deploy-runbooks%2FdeployRunbooks.json) 3 | 4 | 5 | This sample shows how you can deploy a runbook in its 3 different states: empty draft, draft with content, and published runbook. 6 | 7 | ##Resources Deployed 8 | ###Automation Account 9 | This is the account that will contain your runbooks. 10 | 11 | If you want to deploy to an existing account, make sure that the tags, and SKU (pricing tier) in the template are all the same as your existing account, otherwise the properties will be overwritten. 12 | 13 | ###Runbook 1 - Blank runbook 14 | This creates a runbook stub with the name specified in the parameter files. This runbook is created as a graphical runbook. 15 | 16 | ###Runbook 2 - Runbook created in draft mode 17 | This creates a PowerShell Workflow runbook in draft mode. The runbook that is deployed in this case is called DraftRunbook. 18 | ###Runbook 3 - Runbook created in published mode 19 | This creates a PowerShell runbook in published mode. The runbook that is deployed in this case is called PublishedRunbook. 20 | 21 | ###Aditional notes 22 | Note that the optional hash value for runbook #2 and #3 is removed from the deployment template. If you would like to use a hash value, convert your runbook to binary and use the SHA 256 algorithm against the binary file to generate a hash value. 23 | 24 | Example deployment template snippet: 25 | 26 | "publishContentLink": { 27 | "uri": "http://mystorageaccount/MyRunbook.ps1", 28 | "version": "1.0.0.0", 29 | "hash": { 30 | "algorithm": "sha256", 31 | "value": "6E7753DAB302EAD767F5A2CF6A950C496EDE541EAC108D45B62762D7B53495F0" 32 | } 33 | } -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-runbooks/azuredeploy-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "accountName": { 3 | "value": "MyAutomationAccount" 4 | }, 5 | "location": { 6 | "value": "Japan East" 7 | }, 8 | "pricingTier": { 9 | "value": "Free" 10 | }, 11 | "blankRunbokName": { 12 | "value": "Hello-BlankRunbook" 13 | } 14 | } -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-runbooks/runbooks/DraftRunbook.ps1: -------------------------------------------------------------------------------- 1 | <#PSScriptInfo 2 | … metadata used by us… 3 | #> 4 | Param() 5 | 6 | Function Test-FunctionFromScript_Script-WithDependencies2 { Get-Date } 7 | 8 | 9 | workflow DraftRunbook { 10 | 11 | Write-Output "I am a draft" 12 | 13 | } 14 | -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-runbooks/runbooks/PublishedRunbook.ps1: -------------------------------------------------------------------------------- 1 | workflow PublishedRunbook { 2 | Write-Output "I am a published runbook" 3 | } -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-schedule/README.md: -------------------------------------------------------------------------------- 1 | # Creates a Write-HelloWorld runbook and a schedule for it 2 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fazureautomation%2Fautomation-packs%2Fmaster%2F101-sample-deploy-automation-resources%2Fsample-deploy-schedule%2FdeployRunbookOnSchedule.json) 3 | 4 | 5 | This sample shows how to create an Azure Automation schedule and associate it with a runbook. 6 | 7 | ##Resources Deployed 8 | ###Automation Account 9 | This is the account that will contain your runbook and schedule. 10 | 11 | If you want to deploy to an existing account, make sure that the tags, and pricing tier in the template are all the same as your existing account. 12 | 13 | ###Runbook: Write-HelloWorld 14 | Creates a published version of Write-HelloWorld. The schedule will be linked to this runbook. 15 | 16 | ###Schedule 17 | Creates a schedule with the name, time, and frequency of your choice. 18 | 19 | ###Job Schedule 20 | Links the Write-HelloWorld runbook to the schedule created above. 21 | -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-schedule/azuredeploy-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "accountName": { 3 | "value": "MyAutomationAccount" 4 | }, 5 | "location": { 6 | "value": "Japan East" 7 | }, 8 | "pricingTier": { 9 | "value": "Free" 10 | }, 11 | "scheduleName": { 12 | "value": "Daily Schedule at 12" 13 | }, 14 | "startDate": { 15 | "value": "12/30/2015 12:00:00" 16 | }, 17 | "frequency": { 18 | "value":"day" 19 | }, 20 | "jobScheduleGuid": { 21 | "value":"74bb2655-3e42-4784-b7bb-c12f298a8a32" 22 | } 23 | } -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-variable/README.md: -------------------------------------------------------------------------------- 1 | # Create an Automation variable 2 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fazureautomation%2Fautomation-packs%2Fmaster%2F101-sample-automation-resource-templates%2Fsample-deploy-variable%2FdeployVariable.json) 3 | 4 | 5 | This sample shows how to deploy an Azure Automation variable asset of type string. 6 | 7 | ##Resources Deployed 8 | ###Automation Account 9 | This is the account that will contain your variable. 10 | 11 | If you want to deploy to an existing account, make sure that the Resource Group, region, tags, and pricing tier in the template are all the same as the account you want to deploy the variable in. 12 | 13 | ###Variable 14 | The string variable to deploy to Azure Automation. 15 | 16 | -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-variable/azuredeploy-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "accountName": { 3 | "value": "MyAutomationAccount" 4 | }, 5 | "regionId": { 6 | "value": "East US 2" 7 | }, 8 | "pricingTier":{ 9 | "value":"Free" 10 | }, 11 | "variableName": { 12 | "value": "MyVariableName" 13 | }, 14 | "variableValue": { 15 | "value": "MyStringValue" 16 | } 17 | } -------------------------------------------------------------------------------- /101-sample-automation-resource-templates/sample-deploy-variable/deployVariable.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01-preview#", 3 | "contentVersion": "1.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Azure Automation account to deploy to." 9 | } 10 | }, 11 | "regionId": { 12 | "type": "string", 13 | "allowedValues": [ 14 | "Japan East", 15 | "East US 2", 16 | "West Europe", 17 | "Southeast Asia", 18 | "South Central US" 19 | ], 20 | "metadata": { 21 | "description": "The region to deploy the Automation account in." 22 | } 23 | }, 24 | "pricingTier": { 25 | "type": "string", 26 | "allowedValues": [ 27 | "Free", 28 | "Basic" 29 | ], 30 | "metadata": { 31 | "description": "The pricing tier for the account." 32 | } 33 | }, 34 | "variableName": { 35 | "type": "string", 36 | "metadata": { 37 | "description": "The name of the variable" 38 | } 39 | }, 40 | "variableValue": { 41 | "type": "string", 42 | "metadata": { 43 | "description": "The value for the variable. In this case, a string value." 44 | } 45 | } 46 | }, 47 | "variables": { 48 | 49 | }, 50 | "resources": [ 51 | { 52 | "name": "[parameters('accountName')]", 53 | "type": "Microsoft.Automation/automationAccounts", 54 | "apiVersion": "2015-01-01-preview", 55 | "location": "[parameters('regionId')]", 56 | "dependsOn": [ ], 57 | "tags": { }, 58 | "properties": { 59 | "sku": { 60 | "name": "[parameters('pricingTier')]" 61 | } 62 | }, 63 | "resources": [ 64 | 65 | { 66 | "name": "[parameters('variableName')]", 67 | "type": "variables", 68 | "apiVersion": "2015-01-01-preview", 69 | "location": "[parameters('regionId')]", 70 | "dependsOn": [ 71 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 72 | ], 73 | "tags": { 74 | }, 75 | "properties": { 76 | "description": "Some description", 77 | "isEncrypted": 0, 78 | "type": "string", 79 | "value": "[concat('\"', parameters('variableValue'),'\"')]" 80 | } 81 | } 82 | ] 83 | } 84 | ], 85 | "outputs": {} 86 | } -------------------------------------------------------------------------------- /101-sample-using-base-automation-templates/README.md: -------------------------------------------------------------------------------- 1 | # Hello World Example 2 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fazureautomation%2Fautomation-packs%2Fmaster%2F000-sample-using-base-automation-templates%2Fazuredeploy.json) 3 | 4 | This sample shows how you can deploy a runbook, a module that the runbook needs, and create an assign a schedule to the runbook. 5 | 6 | This version of the sample shows how to use nested deployment templates to deploy each resource needed. It calls the templates provided by the Automation team for the Automation account, runbook, and schedule. 7 | 8 | 9 | ## Resources Deployed 10 | 11 | ### Automation Account 12 | 13 | This is the account that will contain your runbook, module and schedule. If you want to deploy to an existing account, make sure that the Resource Group, region, tags, and SKU in the template are all the same as your existing account, otherwise the properties will be overwritten. 14 | 15 | ### Runbook 16 | 17 | This runbook writes "Hello $Name" to the output stream. 18 | 19 | ### Module 20 | The module is deployed from the sample-deploy-module in https://github.com/azureautomation/automation-packs/tree/master/101-sample-deploy-automation-resources/sample-deploy-modules. 21 | 22 | ### Schedule (and link to runbook) 23 | A schedule is deployed and linked to the runbook. 24 | 25 | To associated the schedule with a runbook, you need a GUID. You can use [System.Guid]::NewGuid() or $JobGUID = (New-Guid).Guid (in PowerShell 5.0) to generate this. -------------------------------------------------------------------------------- /101-sample-using-base-automation-templates/Runbooks/Say-HelloSample.ps1: -------------------------------------------------------------------------------- 1 | <#PSScriptInfo 2 | 3 | .Version 1.0 4 | .Author elcooper 5 | .CompanyName Microsoft Corporation 6 | .Copyright (c) 2015 Microsoft Corporation. All rights reserved. 7 | .Tags Tag1 Tag2 8 | .LicenseUri https://contoso.com/License 9 | .ProjectUri https://github.com/azureautomation/automation-packs/tree/master/000-sample-using-base-automation-templates 10 | .IconUri https://contoso.com/MyScriptIcon 11 | .ExternalModuleDependencies Hello-WorldModule 12 | .RequiredScripts 13 | .ReleaseNotes 14 |      contoso script now supports following features 15 |      Feature 1 16 |        17 | #> 18 | workflow Say-HelloSample { 19 | param ( [string] $Name ) 20 | 21 | 22 | Say-Hello -Name $Name 23 | 24 | } -------------------------------------------------------------------------------- /101-sample-using-base-automation-templates/azuredeploy-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "accountName": { 3 | "value": "MyAutomationAccount" 4 | }, 5 | "regionId": { 6 | "value": "East US 2" 7 | }, 8 | "pricingTier": { 9 | "value": "Basic" 10 | }, 11 | "scheduleName": { 12 | "value": "MySchedule" 13 | }, 14 | "startTime": { 15 | "value": "12/30/2015 12:00:00" 16 | }, 17 | "frequency": { 18 | "value": "hour" 19 | }, 20 | "interval": { 21 | "value": "3" 22 | }, 23 | "jobScheduleGuid": { 24 | "value": "e6abf1fd-6311-4442-ac1a-22aae3cacdae" 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /101-sample-using-single-automation-template/README.md: -------------------------------------------------------------------------------- 1 | # Hello World Example 2 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fazureautomation%2Fautomation-packs%2Fmaster%2F000-sample-using-single-automation-template%2Fazuredeploy.json) 3 | 4 | This sample shows how you can deploy a runbook, a module that the runbook needs, and create an assign a schedule to the runbook. 5 | 6 | 7 | ##Resources Deployed 8 | 9 | ###Automation Account 10 | 11 | This is the account that will contain your runbook, module and schedule. If you want to deploy to an existing account, make sure that the Resource Group, region, tags, and SKU in the template are all the same as your existing account, otherwise the properties will be overwritten. 12 | 13 | ###Runbook 14 | 15 | This runbook writes "Hello $Name" to the output stream. 16 | 17 | ###Module 18 | 19 | The module is deployed from the sample-deploy-module in https://github.com/azureautomation/automation-packs/tree/master/101-sample-deploy-automation-resources/sample-deploy-modules. 20 | 21 | ###Schedule 22 | A schedule is deployed and linked to the runbook. 23 | 24 | To associated the schedule with a runbook, you need a GUID. You can use [System.Guid]::NewGuid() or $JobGUID = (New-Guid).Guid (in PowerShell 5.0) to generate this. -------------------------------------------------------------------------------- /101-sample-using-single-automation-template/Runbooks/Say-HelloSample.ps1: -------------------------------------------------------------------------------- 1 | <#PSScriptInfo 2 | 3 | .Version 1.0 4 | .Author elcooper 5 | .CompanyName Microsoft Corporation 6 | .Copyright (c) 2015 Microsoft Corporation. All rights reserved. 7 | .Tags Tag1 Tag2 8 | .LicenseUri https://contoso.com/License 9 | .ProjectUri https://github.com/azureautomation/automation-packs/tree/master/000-sample-using-single-automation-template 10 | .IconUri https://contoso.com/MyScriptIcon 11 | .ExternalModuleDependencies Hello-WorldModule 12 | .RequiredScripts 13 | .ReleaseNotes 14 |      contoso script now supports following features 15 |      Feature 1 16 |        17 | #> 18 | 19 | workflow Say-HelloSample { 20 | param ( [string] $Name ) 21 | 22 | 23 | Say-Hello -Name $Name 24 | 25 | } -------------------------------------------------------------------------------- /101-sample-using-single-automation-template/azuredeploy-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "accountName": { 3 | "value": "MyAutomationAccount" 4 | }, 5 | "regionId": { 6 | "value": "East US 2" 7 | }, 8 | "pricingTier": { 9 | "value": "Basic" 10 | }, 11 | "scheduleName": { 12 | "value": "MySchedule" 13 | }, 14 | "startTime": { 15 | "value": "12/30/2015 12:00:00" 16 | }, 17 | "frequency": { 18 | "value": "hour" 19 | }, 20 | "interval": { 21 | "value": "3" 22 | }, 23 | "jobScheduleGuid": { 24 | "value": "e6abf1fd-6311-4442-ac1a-22aae3cacdae" 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /102-sample-automation-setup/Configurations/SimpleConfig.ps1: -------------------------------------------------------------------------------- 1 | Configuration SimpleConfig { 2 | 3 | Node "webserver" { 4 | 5 | WindowsFeature IIS { 6 | Ensure="Present" 7 | Name= "Web-Server" 8 | } 9 | 10 | } 11 | 12 | Node "ICauseFailures" { 13 | 14 | WindowsFeature Yikes { 15 | Ensure="Present" 16 | Name= "Weeeeeeeb-Server" 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /102-sample-automation-setup/README.md: -------------------------------------------------------------------------------- 1 | # Create a sample automation environment 2 | 3 | This sample deploys in a new resource group, an Azure VM and an automation account to manage that Azure VM. This includes a runbook that runs on a schedule against the VM, and the VM is also onboarded as a DSC node for configuration management by Azure Automation DSC. This is meant to make it very easy to get started testing out Azure Automation's capabilities without having to go through the work of setting up Azure Automation's various features yourself. 4 | 5 | It contains a script, deployThroughARM, that you can use to easily deploy the sample through Azure Resource Manager: 6 | `.\deployThroughARM.ps1` 7 | 8 | The script references the content in this GitHub repository, so all you need to download to run the script is the script itself. Download [here](https://raw.githubusercontent.com/azureautomation/automation-packs/master/102-sample-automation-setup/deployThroughARM.ps1). 9 | 10 | Note: You must have the [Azure Resource Manager cmdlets v1.0 (or later)](https://azure.microsoft.com/en-us/documentation/articles/powershell-azure-resource-manager/) installed for the script to work. 11 | -------------------------------------------------------------------------------- /102-sample-automation-setup/Runbooks/SampleRunbook.ps1: -------------------------------------------------------------------------------- 1 | param( 2 | [string] $VMName, 3 | [int] $VMPort, 4 | [boolean] $VMUseSSL 5 | ) 6 | 7 | $VMCredential = Get-AutomationPSCredential -Name "MyVMCredential" 8 | 9 | Invoke-Command -ScriptBlock { 10 | Write-Verbose ("Successfully remoted to " + $env:COMPUTERNAME) 11 | 12 | ## what to do?? 13 | 14 | } -ComputerName $VMName -Port $VMPort -Credential $VMCredential -UseSsl:$VMUseSSL -SessionOption (New-PSSessionOption –SkipCACheck –SkipCNCheck –SkipRevocationCheck) -------------------------------------------------------------------------------- /102-sample-automation-setup/azuredeploy-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "accountName": { 3 | "value": "MyAutomationAccount" 4 | }, 5 | "regionId": { 6 | "value": "southcentralus" 7 | } 8 | } -------------------------------------------------------------------------------- /102-sample-automation-setup/deployThroughARM.ps1: -------------------------------------------------------------------------------- 1 | #Connect to your Azure account 2 | Login-AzureRmAccount 3 | 4 | #Select your subscription if you have more than one 5 | #Select-AzureSubscription -SubscriptionName "My Subscription Name" 6 | 7 | $ResourceGroupName = "SampleAutomationResourceGroup" 8 | $AutomationAccountName = [System.Guid]::NewGuid().toString() 9 | $Location = "southcentralus" 10 | 11 | New-AzureRmResourceGroup -Name $ResourceGroupName -Location $Location 12 | New-AzureRmAutomationAccount -ResourceGroupName $ResourceGroupName -Name $AutomationAccountName -Location $Location -Plan Free 13 | 14 | $RegistrationInfo = Get-AzureRmAutomationRegistrationInfo -ResourceGroupName $ResourceGroupName -AutomationAccountName $AutomationAccountName 15 | 16 | #Set the parameter values for the template 17 | $Params = @{ 18 | accountName = $AutomationAccountName 19 | regionId = $Location 20 | registrationKey = $RegistrationInfo.PrimaryKey 21 | registrationUrl = $RegistrationInfo.Endpoint 22 | dscCompilationJobId = [System.Guid]::NewGuid().toString() 23 | runbookJobId = [System.Guid]::NewGuid().toString() 24 | jobScheduleId = [System.Guid]::NewGuid().toString() 25 | timestamp = (Get-Date).toString() 26 | } 27 | 28 | $TemplateURI = 'https://raw.githubusercontent.com/azureautomation/automation-packs/master/102-sample-automation-setup/azuredeploy.json' 29 | 30 | New-AzureRmResourceGroupDeployment -ResourceGroupName $ResourceGroupName -TemplateParameterObject $Params -TemplateUri $TemplateURI 31 | -------------------------------------------------------------------------------- /200-connect-azure-vm/README.md: -------------------------------------------------------------------------------- 1 | # Connect to an Azure Virtual Machine 2 | 3 | 4 | [![Deploy Runbook to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fazureautomation%2Fautomation-packs%2Fmaster%2F200-connect-azure-vm%2FdeployRunbookAndCredential.json) 5 | 6 | This runbook sets up a connection to an Azure virtual machine (classic). It requires the Azure virtual machine to have the Windows Remote Management service enabled, which is the default. It sets up a connection to the Azure subscription and then imports the certificate used for the Azure VM so remote PowerShell calls can be made to it. 7 | 8 | It uses the Azure Service Management module. 9 | 10 | 11 | 12 | # Resources deployed 13 | 14 | 15 | ## Automation Account 16 | 17 | This is the account that will contain your credentials. If you want to deploy to an existing account, make sure that the Resource Group, region, tags, and pricing tier in the template are all the same as your existing account, otherwise the properties will be overwritten. 18 | 19 | ## Runbook 20 | Connect-AzureVM runbook is deployed to draft state. 21 | 22 | ## Credential 23 | The credential should contain the username and password of the Azure AD organizational ID to connect to Azure. To learn about how to create this user, see [Get Set Up to Automate Azure]("http://aka.ms/getsetuptoautomate") and check out this blog post [Authenticating to Azure using Active Directory]("http://azure.microsoft.com/blog/2014/08/27/azure-automation-authenticating-to-azure-using-azure-active-directory/"). 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /200-connect-azure-vm/Runbooks/Connect-AzureVM.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Sets up the connection to an Azure VM 4 | 5 | .DESCRIPTION 6 | This runbook sets up a connection to an Azure virtual machine. It requires the Azure virtual machine to 7 | have the Windows Remote Management service enabled, which is the default. It sets up a connection to the Azure 8 | subscription and then imports the certificate used for the Azure VM so remote PowerShell calls can be made to it. 9 | 10 | .PARAMETER AzureSubscriptionName 11 | Name of the Azure subscription to connect to 12 | 13 | .PARAMETER AzureOrgIdCredential 14 | A credential containing an Org Id username / password with access to this Azure subscription. 15 | 16 | If invoking this runbook inline from within another runbook, pass a PSCredential for this parameter. 17 | 18 | If starting this runbook using Start-AzureAutomationRunbook, or via the Azure portal UI, pass as a string the 19 | name of an Azure Automation PSCredential asset instead. Azure Automation will automatically grab the asset with 20 | that name and pass it into the runbook. 21 | 22 | .PARAMETER ServiceName 23 | Name of the cloud service where the VM is located. 24 | 25 | .PARAMETER VMName 26 | Name of the virtual machine that you want to connect to 27 | 28 | .EXAMPLE 29 | Connect-AzureVM -AzureSubscriptionName "Visual Studio Ultimate with MSDN" -ServiceName "Finance" -VMName "WebServer01" -AzureOrgIdCredential $cred 30 | 31 | .NOTES 32 | AUTHOR: System Center Automation Team 33 | LASTEDIT: Dec 18, 2014 34 | #> 35 | workflow Connect-AzureVM 36 | { 37 | [OutputType([System.Uri])] 38 | 39 | Param 40 | ( 41 | [parameter(Mandatory=$true)] 42 | [String] 43 | $AzureSubscriptionName, 44 | 45 | [parameter(Mandatory=$true)] 46 | [PSCredential] 47 | $AzureOrgIdCredential, 48 | 49 | [parameter(Mandatory=$true)] 50 | [String] 51 | $ServiceName, 52 | 53 | [parameter(Mandatory=$true)] 54 | [String] 55 | $VMName 56 | ) 57 | 58 | Add-AzureAccount -Credential $AzureOrgIdCredential | Write-Verbose 59 | 60 | # Select the Azure subscription we will be working against 61 | Select-AzureSubscription -SubscriptionName $AzureSubscriptionName | Write-Verbose 62 | 63 | InlineScript { 64 | # Get the Azure certificate for remoting into this VM 65 | $winRMCert = (Get-AzureVM -ServiceName $Using:ServiceName -Name $Using:VMName | select -ExpandProperty vm).DefaultWinRMCertificateThumbprint 66 | $AzureX509cert = Get-AzureCertificate -ServiceName $Using:ServiceName -Thumbprint $winRMCert -ThumbprintAlgorithm sha1 67 | 68 | # Add the VM certificate into the LocalMachine 69 | if ((Test-Path Cert:\LocalMachine\Root\$winRMCert) -eq $false) 70 | { 71 | Write-Progress "VM certificate is not in local machine certificate store - adding it" 72 | $certByteArray = [System.Convert]::fromBase64String($AzureX509cert.Data) 73 | $CertToImport = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList (,$certByteArray) 74 | $store = New-Object System.Security.Cryptography.X509Certificates.X509Store "Root", "LocalMachine" 75 | $store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite) 76 | $store.Add($CertToImport) 77 | $store.Close() 78 | } 79 | 80 | # Return the WinRM Uri so that it can be used to connect to this VM 81 | Get-AzureWinRMUri -ServiceName $Using:ServiceName -Name $Using:VMName 82 | } 83 | } -------------------------------------------------------------------------------- /200-connect-azure-vm/azuredeploy.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01-preview#", 3 | "contentVersion": "1.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Azure Automation account to deploy to." 9 | } 10 | }, 11 | "regionId": { 12 | "type": "string", 13 | "allowedValues": [ 14 | "Japan East", 15 | "East US 2", 16 | "West Europe", 17 | "Southeast Asia", 18 | "South Central US" 19 | ], 20 | "metadata": { 21 | "description": "The region to deploy the Automation account in." 22 | } 23 | }, 24 | "userName": { 25 | "type": "string", 26 | "metadata": { 27 | "description": "The username for the Azure Automation credential used to authenticate to Azure." 28 | } 29 | }, 30 | "password": { 31 | "type": "securestring", 32 | "metadata": { 33 | "description": "The password for the Azure Automation credential." 34 | } 35 | } 36 | }, 37 | "variables": { 38 | "pricingTier": "Free", 39 | "runbookName": "Connect-AzureVM", 40 | "scriptUri": "https://gallery.technet.microsoft.com/scriptcenter/Connect-to-an-Azure-85f0782c/file/131573/1/Connect-AzureVM.ps1", 41 | "runbookDescription": "Sets up a connection to an Azure Virtual Machine", 42 | "credentialName": "DefaultAzureCredential" 43 | 44 | }, 45 | "resources": [ 46 | { 47 | "name": "[parameters('accountName')]", 48 | "type": "Microsoft.Automation/automationAccounts", 49 | "apiVersion": "2015-01-01-preview", 50 | "location": "[parameters('regionId')]", 51 | "dependsOn": [ ], 52 | "tags": { }, 53 | "properties": { 54 | "sku": { 55 | "name": "[variables('pricingTier')]" 56 | } 57 | }, 58 | "resources": [ 59 | { 60 | "name": "[variables('runbookName')]", 61 | "type": "runbooks", 62 | "apiVersion": "2015-01-01-preview", 63 | "location": "[parameters('regionId')]", 64 | "dependsOn": [ 65 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 66 | ], 67 | "tags": { 68 | }, 69 | "properties": { 70 | "runbookType": "Script", 71 | "logProgress": "false", 72 | "logVerbose": "false", 73 | "description": "[variables('runbookDescription')]", 74 | "draft": { 75 | "draftContentLink": { 76 | "uri": "[variables('scriptUri')]", 77 | "version": "1.0.0.0" 78 | } 79 | } 80 | } 81 | }, 82 | { 83 | "name": "[variables('credentialName')]", 84 | "type": "credentials", 85 | "apiVersion": "2015-01-01-preview", 86 | "location": "[parameters('regionId')]", 87 | "dependsOn": [ 88 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 89 | ], 90 | "tags": { }, 91 | "properties": { 92 | "userName": "[parameters('userName')]", 93 | "password": "[parameters('password')]" 94 | } 95 | } 96 | ] 97 | } 98 | ], 99 | "outputs": {} 100 | } -------------------------------------------------------------------------------- /200-copy-file-to-azure-vm/README.md: -------------------------------------------------------------------------------- 1 | # Copy file to an Azure Virtual Machine 2 | [![Deploy Runbook to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fazureautomation%2Fautomation-packs%2Fmaster%2F200-copy-file-to-azure-vm%2Fazuredeploy.json) 3 | 4 | 5 | This Azure Automation runbook copies a file from the local runbook host to an Azure virtual machine (classic). This runbook is intended to run after a file is copied to the local host so ensure that you have copied the file to the runbook host before calling this. 6 | 7 | #Resources deployed 8 | 9 | - Automation account 10 | - Runbook: Connect-AzureVM (Child runbook) 11 | - Runbook: Copy-ItemToAzureVM 12 | - Credential 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /201-Deploy-And-Compile-DSC-Configuration-Credentials/Configurations/Modules/xActiveDirectory.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/azureautomation/automation-packs/c03d72f994e74385091f6e631cfd906bfcba0073/201-Deploy-And-Compile-DSC-Configuration-Credentials/Configurations/Modules/xActiveDirectory.zip -------------------------------------------------------------------------------- /201-Deploy-And-Compile-DSC-Configuration-Credentials/Configurations/Modules/xComputerManagement.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/azureautomation/automation-packs/c03d72f994e74385091f6e631cfd906bfcba0073/201-Deploy-And-Compile-DSC-Configuration-Credentials/Configurations/Modules/xComputerManagement.zip -------------------------------------------------------------------------------- /201-Deploy-And-Compile-DSC-Configuration-Credentials/Configurations/dscDomainJoin.ps1: -------------------------------------------------------------------------------- 1 | Configuration dscDomainJoin 2 | { 3 | param( 4 | [Int]$RetryCount = 20, 5 | [Int]$RetryIntervalSec = 30 6 | ) 7 | 8 | Import-DscResource -ModuleName PSDesiredStateConfiguration 9 | Import-DscResource -ModuleName xComputerManagement 10 | Import-DscResource -ModuleName xActiveDirectory 11 | 12 | $domainName = Get-AutomationVariable -Name 'domainName' 13 | $domainCreds = Get-AutomationPSCredential -Name 'domainCreds' 14 | 15 | Node $AllNodes.NodeName 16 | { 17 | WindowsFeature ADPowershell 18 | { 19 | Name = "RSAT-AD-PowerShell" 20 | Ensure = "Present" 21 | } 22 | 23 | xWaitForADDomain WaitForDomain 24 | { 25 | DomainName = $domainName 26 | DomainUserCredential= $domainCreds 27 | RetryCount = $RetryCount 28 | RetryIntervalSec = $RetryIntervalSec 29 | DependsOn = "[WindowsFeature]ADPowershell" 30 | } 31 | 32 | xComputer DomainJoin 33 | { 34 | Name = $Node.NodeName 35 | DomainName = $domainName 36 | Credential = $domainCreds 37 | DependsOn = "[xWaitForADDomain]WaitForDomain" 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /201-Deploy-And-Compile-DSC-Configuration-Credentials/README.md: -------------------------------------------------------------------------------- 1 | # Copy a DSC Configuration to Azure Automation and compile 2 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3a%2f%2fraw.githubusercontent.com%2fbdanse%2fautomation-packs%2fmaster%2f201-Deploy-And-Compile-DSC-Configuration-Credentials%2fazuredeploy.json) 3 | 4 | This DSC configuration compiles a node configuration to join a ADDS domain. 5 | 6 | Once the DSC configuration is published and compiled it can be consumed by any registered DSC node. 7 | 8 | #Requirements 9 | A DSC configuration is made available in the folder Configurations. 10 | a guid for the jobId parameter, you can create a guid using PowerShell: 11 | ``` PowerShell 12 | #PowerShell < v5 13 | [System.Guid]::NewGuid() 14 | 15 | #PowerShell v5 16 | $JobGUID = (New-Guid).Guid 17 | 18 | ``` 19 | 20 | #Known limitations 21 | - I had an issue using a DSC Configuration link containing spaces 22 | - Configurations can only be deployed as 'Published' during the preview 23 | - Quotation marks around userName from credential asset 24 | - Quotation marks around variableValue from variable asset 25 | 26 | #Resources deployed 27 | 28 | - Automation account 29 | - Variable asset "domainName" 30 | - Credential asset "domainCreds" 31 | - Assets are used during compilation 32 | 33 | ``` PowerShell 34 | $domainName = Get-AutomationVariable -Name 'domainName' 35 | $domainCreds = Get-AutomationPSCredential -Name 'domainCreds' 36 | ``` 37 | - Upload module xComputerManagement 38 | - Upload module xActiveDirectory 39 | - DSC Configuration: dscDomainJoin, configure with a nodename per node. Since computername is used. 40 | reference the DSc configuration as dscDomainJoin.SRV001, dscDomainJoin.SRV002, etc. 41 | 42 | 43 | ``` PowerShell 44 | Configuration dscDomainJoin 45 | { 46 | param( 47 | [Int]$RetryCount = 20, 48 | [Int]$RetryIntervalSec = 30 49 | ) 50 | 51 | Import-DscResource -ModuleName PSDesiredStateConfiguration 52 | Import-DscResource -ModuleName xComputerManagement 53 | Import-DscResource -ModuleName xActiveDirectory 54 | 55 | $domainName = Get-AutomationVariable -Name 'domainName' 56 | $domainCreds = Get-AutomationPSCredential -Name 'domainCreds' 57 | 58 | Node $AllNodes.NodeName 59 | { 60 | WindowsFeature ADPowershell 61 | { 62 | Name = "RSAT-AD-PowerShell" 63 | Ensure = "Present" 64 | } 65 | 66 | xWaitForADDomain WaitForDomain 67 | { 68 | DomainName = $domainName 69 | DomainUserCredential= $domainCreds 70 | RetryCount = $RetryCount 71 | RetryIntervalSec = $RetryIntervalSec 72 | DependsOn = "[WindowsFeature]ADPowershell" 73 | } 74 | 75 | xComputer DomainJoin 76 | { 77 | Name = $Node.NodeName 78 | DomainName = $domainName 79 | Credential = $domainCreds 80 | DependsOn = "[xWaitForADDomain]WaitForDomain" 81 | } 82 | } 83 | } 84 | 85 | 86 | ``` 87 | -------------------------------------------------------------------------------- /201-Deploy-And-Compile-DSC-Configuration-Credentials/azuredeploy-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "accountName": { 3 | "value": "MyAutomationAccount" 4 | }, 5 | "regionId": { 6 | "value": "East US 2" 7 | }, 8 | "credentialName": { 9 | "value": "domainCreds" 10 | 11 | }, 12 | "userName": { 13 | "value": "\"DOMAIN\\Account\"" 14 | }, 15 | "password": { 16 | "value": "secret" 17 | }, 18 | "variableName": { 19 | "value": "domainName" 20 | 21 | }, 22 | "variableType": { 23 | "value": "string" 24 | }, 25 | "variableValue": { 26 | "value": "\"DOMAIN.LOCAL\"" 27 | }, 28 | "configurationName": { 29 | "value": "dscDomainJoin" 30 | }, 31 | "configurationURI": { 32 | "value": "https://raw.githubusercontent.com/bdanse/azure/master/201-Deploy-And-Compile-DSC-Configuration-Credentials/Configurations/dscDomainJoin.ps1" 33 | }, 34 | "configurationDescription": { 35 | "value": "Configuration for Domain Join with credentials support through ConfigurationData" 36 | }, 37 | "jobId": { 38 | "value": "d1770d07-3105-45bd-a43e-4dd4a00d9b5e" 39 | }, 40 | "jobConfigurationData": { 41 | "type": "{\"AllNodes\":[{\"NodeName\":\"*\",\"PSDscAllowPlainTextPassword\":true},{\"NodeName\":\"SRV001\"},{\"NodeName\":\"SRV002\"}]}" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /201-Deploy-And-Compile-DSC-Configuration-Credentials/deployThroughARM.ps1: -------------------------------------------------------------------------------- 1 | 2 | #Connect to your Azure account 3 | #Add-AzureAccount 4 | 5 | #Select your subscription if you have more than one 6 | #Select-AzureSubscription -SubscriptionName "My Subscription Name" 7 | 8 | #Create a GUID for the job 9 | $JobGUID = [System.Guid]::NewGuid().toString() 10 | 11 | #DSC ConfigurationData 12 | $ConfigurationData = @{ 13 | AllNodes = @( 14 | @{ 15 | NodeName = "*"; 16 | PSDscAllowPlainTextPassword = $true 17 | }, 18 | @{ 19 | NodeName = "SRV001" 20 | }, 21 | @{ 22 | NodeName = "SRV002" 23 | } 24 | ) 25 | } 26 | 27 | #Use Azure resource Manager to deploy template 28 | Switch-AzureMode -Name AzureResourceManager 29 | 30 | #Set the parameter values for the template 31 | $Params = @{ 32 | accountName = 'MyAutomationAccount' 33 | regionId = 'East US 2' 34 | credentialName = 'domainCreds' 35 | userName = '"DOMAIN\Account"' 36 | password = 'secret' 37 | variableName = 'domainName' 38 | variableType = 'string' 39 | variableValue = '"DOMAIN.LOCAL"' 40 | configurationName = 'dscDomainJoin' 41 | configurationURI = 'https://raw.githubusercontent.com/bdanse/automation-packs/master/201-Deploy-And-Compile-DSC-Configuration-Credentials/Configurations/dscDomainJoin.ps1' 42 | configurationDescription = 'Configuration for Domain Join with credentials support through ConfigurationData' 43 | jobId = $JobGUID 44 | jobConfigurationData = ($ConfigurationData | ConvertTo-Json -Compress).ToString() 45 | 46 | } 47 | 48 | 49 | $TemplateURI = "https://raw.githubusercontent.com/bdanse/automation-packs/master/201-Deploy-And-Compile-DSC-Configuration-Credentials/azuredeploy.json" 50 | 51 | New-AzureResourceGroupDeployment -TemplateParameterObject $Params -ResourceGroupName "resourcgroup01" -TemplateUri $TemplateURI 52 | 53 | 54 | -------------------------------------------------------------------------------- /201-Deploy-And-Compile-DSC-Configuration-using-base-templates/Configurations/webrolefull.ps1: -------------------------------------------------------------------------------- 1 | Configuration webrolefull { 2 | 3 | $features = @( 4 | @{Name = "Web-Server"; Ensure = "Present"}, 5 | @{Name = "Web-WebServer"; Ensure = "Present"}, 6 | @{Name = "Web-Common-http"; Ensure = "Present"}, 7 | @{Name = "Web-Default-Doc"; Ensure = "Present"}, 8 | @{Name = "Web-Dir-Browsing"; Ensure = "Present"}, 9 | @{Name = "Web-Http-Errors"; Ensure = "Present"}, 10 | @{Name = "Web-Static-Content"; Ensure = "Present"}, 11 | @{Name = "Web-Health"; Ensure = "Present"}, 12 | @{Name = "Web-Http-Logging"; Ensure = "Present"}, 13 | @{Name = "Web-Performance"; Ensure = "Present"}, 14 | @{Name = "Web-Stat-Compression"; Ensure = "Present"}, 15 | @{Name = "Web-Dyn-Compression"; Ensure = "Present"}, 16 | @{Name = "Web-Security"; Ensure = "Present"}, 17 | @{Name = "Web-Filtering"; Ensure = "Present"}, 18 | @{Name = "Web-Basic-Auth"; Ensure = "Present"}, 19 | @{Name = "Web-Windows-Auth"; Ensure = "Present"}, 20 | @{Name = "Web-App-Dev"; Ensure = "Present"}, 21 | @{Name = "Web-Net-Ext45"; Ensure = "Present"}, 22 | @{Name = "Web-Asp-Net45"; Ensure = "Present"}, 23 | @{Name = "Web-ISAPI-Ext"; Ensure = "Present"}, 24 | @{Name = "Web-ISAPI-Filter"; Ensure = "Present"}, 25 | @{Name = "Web-Ftp-Server"; Ensure = "Present"}, 26 | @{Name = "Web-Mgmt-Tools"; Ensure = "Present"}, 27 | @{Name = "Web-Mgmt-Console"; Ensure = "Present"} 28 | ) 29 | 30 | node full { 31 | 32 | foreach ($feature in $features){ 33 | WindowsFeature ($feature.Name) { 34 | Name = $feature.Name 35 | Ensure = $feature.Ensure 36 | } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /201-Deploy-And-Compile-DSC-Configuration-using-base-templates/README.md: -------------------------------------------------------------------------------- 1 | # Deploy a simple DSC Configuration using nested templates 2 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3a%2f%2fraw.githubusercontent.com%2fazureautomation%2fautomation-packs%2fmaster%2f201-deploy-and-compile-DSC-configuration-using-base-templates%2fazuredeploy.json) 3 | 4 | This sample demonstrates how to deploy a DSC configuration and compile the configuration. 5 | It uses nested deployment templates for the configuration and its compilation job. 6 | 7 | ## Resources Deployed 8 | 9 | ### Automation Account 10 | 11 | This is the account that will contain your DSC configuration. 12 | If you want to deploy to an existing account, make sure that the Resource Group, region, tags, and SKU in the template are all the same as your existing account, otherwise the properties will be overwritten. 13 | 14 | ### Configuration 15 | 16 | The configuration installs all web server windows features 17 | reference the DSC configuration as webrolefull.Full 18 | 19 | ``` PowerShell 20 | Configuration webrolefull { 21 | 22 | $features = @( 23 | @{Name = "Web-Server"; Ensure = "Present"}, 24 | @{Name = "Web-WebServer"; Ensure = "Present"}, 25 | @{Name = "Web-Common-http"; Ensure = "Present"}, 26 | @{Name = "Web-Default-Doc"; Ensure = "Present"}, 27 | @{Name = "Web-Dir-Browsing"; Ensure = "Present"}, 28 | @{Name = "Web-Http-Errors"; Ensure = "Present"}, 29 | @{Name = "Web-Static-Content"; Ensure = "Present"}, 30 | @{Name = "Web-Health"; Ensure = "Present"}, 31 | @{Name = "Web-Http-Logging"; Ensure = "Present"}, 32 | @{Name = "Web-Performance"; Ensure = "Present"}, 33 | @{Name = "Web-Stat-Compression"; Ensure = "Present"}, 34 | @{Name = "Web-Dyn-Compression"; Ensure = "Present"}, 35 | @{Name = "Web-Security"; Ensure = "Present"}, 36 | @{Name = "Web-Filtering"; Ensure = "Present"}, 37 | @{Name = "Web-Basic-Auth"; Ensure = "Present"}, 38 | @{Name = "Web-Windows-Auth"; Ensure = "Present"}, 39 | @{Name = "Web-App-Dev"; Ensure = "Present"}, 40 | @{Name = "Web-Net-Ext45"; Ensure = "Present"}, 41 | @{Name = "Web-Asp-Net45"; Ensure = "Present"}, 42 | @{Name = "Web-ISAPI-Ext"; Ensure = "Present"}, 43 | @{Name = "Web-ISAPI-Filter"; Ensure = "Present"}, 44 | @{Name = "Web-Ftp-Server"; Ensure = "Present"}, 45 | @{Name = "Web-Mgmt-Tools"; Ensure = "Present"}, 46 | @{Name = "Web-Mgmt-Console"; Ensure = "Present"} 47 | ) 48 | 49 | node full { 50 | 51 | foreach ($feature in $features){ 52 | WindowsFeature ($feature.Name) { 53 | Name = $feature.Name 54 | Ensure = $feature.Ensure 55 | } 56 | } 57 | } 58 | } 59 | 60 | ``` 61 | ### Compilation job 62 | the compilation job is linked to the configuration deployed to Azure automation. It makes sure the configuration gets compiled. 63 | You will need a GUID to start the job. 64 | You can use PowerShell to create a GUID. 65 | ``` PowerShell 66 | #PowerShell < v5 67 | [System.Guid]::NewGuid() 68 | 69 | #PowerShell v5 70 | $JobGUID = (New-Guid).Guid 71 | 72 | ``` 73 | 74 | #Known limitations 75 | - I had an issue using a DSC Configuration link containing spaces 76 | - Configurations can only be deployed as 'Published' during the preview -------------------------------------------------------------------------------- /201-Deploy-And-Compile-DSC-Configuration-using-base-templates/azuredeploy-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "accountName": { 3 | "value": "MyAutomationAccount" 4 | }, 5 | "regionId": { 6 | "value": "East US 2" 7 | }, 8 | "jobId": { 9 | "value": "5a04bafa-40fd-4f7d-a142-ffd67a8206dc" 10 | } 11 | } -------------------------------------------------------------------------------- /201-Deploy-And-Compile-DSC-Configuration-using-base-templates/deployThroughARM.ps1: -------------------------------------------------------------------------------- 1 | 2 | #Connect to your Azure account 3 | Add-AzureAccount 4 | 5 | #Select your subscription if you have more than one 6 | #Select-AzureSubscription -SubscriptionName "My Subscription Name" 7 | 8 | #Create a GUID for the job 9 | $JobGUID = [System.Guid]::NewGuid().toString() 10 | 11 | #Use Azure resource Manager to deploy template 12 | Switch-AzureMode -Name AzureResourceManager 13 | 14 | #Set the parameter values for the template 15 | $Params = @{ 16 | 'accountName' = 'MyAutomationAccount' 17 | 'regionId' = 'East US 2' 18 | 'configurationName' = 'webrolefull' 19 | 'configurationURI' = 'https://raw.githubusercontent.com/azureautomation/automation-packs/master/201-deploy-and-compile-DSC-configuration-using-base-templates/Configurations/webrolefull.ps1' 20 | 'configurationDescription' = 'This webserver configuration contains all elements to install a full blown webserver' 21 | 'jobId' = $JobGUID 22 | 23 | } 24 | 25 | $TemplateURI = "https://raw.githubusercontent.com/azureautomation/automation-packs/master/201-Deploy-And-Compile-DSC-Configuration-using-base-templates/azuredeploy.json" 26 | 27 | New-AzureResourceGroupDeployment -TemplateParameterObject $Params -ResourceGroupName "MyResourceGroup" -TemplateUri $TemplateURI -------------------------------------------------------------------------------- /201-Deploy-And-Compile-DSC-Configuration/Configurations/webrolefull.ps1: -------------------------------------------------------------------------------- 1 | Configuration webrolefull { 2 | 3 | $features = @( 4 | @{Name = "Web-Server"; Ensure = "Present"}, 5 | @{Name = "Web-WebServer"; Ensure = "Present"}, 6 | @{Name = "Web-Common-http"; Ensure = "Present"}, 7 | @{Name = "Web-Default-Doc"; Ensure = "Present"}, 8 | @{Name = "Web-Dir-Browsing"; Ensure = "Present"}, 9 | @{Name = "Web-Http-Errors"; Ensure = "Present"}, 10 | @{Name = "Web-Static-Content"; Ensure = "Present"}, 11 | @{Name = "Web-Health"; Ensure = "Present"}, 12 | @{Name = "Web-Http-Logging"; Ensure = "Present"}, 13 | @{Name = "Web-Performance"; Ensure = "Present"}, 14 | @{Name = "Web-Stat-Compression"; Ensure = "Present"}, 15 | @{Name = "Web-Dyn-Compression"; Ensure = "Present"}, 16 | @{Name = "Web-Security"; Ensure = "Present"}, 17 | @{Name = "Web-Filtering"; Ensure = "Present"}, 18 | @{Name = "Web-Basic-Auth"; Ensure = "Present"}, 19 | @{Name = "Web-Windows-Auth"; Ensure = "Present"}, 20 | @{Name = "Web-App-Dev"; Ensure = "Present"}, 21 | @{Name = "Web-Net-Ext45"; Ensure = "Present"}, 22 | @{Name = "Web-Asp-Net45"; Ensure = "Present"}, 23 | @{Name = "Web-ISAPI-Ext"; Ensure = "Present"}, 24 | @{Name = "Web-ISAPI-Filter"; Ensure = "Present"}, 25 | @{Name = "Web-Ftp-Server"; Ensure = "Present"}, 26 | @{Name = "Web-Mgmt-Tools"; Ensure = "Present"}, 27 | @{Name = "Web-Mgmt-Console"; Ensure = "Present"} 28 | ) 29 | 30 | node full { 31 | 32 | foreach ($feature in $features){ 33 | WindowsFeature ($feature.Name) { 34 | Name = $feature.Name 35 | Ensure = $feature.Ensure 36 | } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /201-Deploy-And-Compile-DSC-Configuration/README.md: -------------------------------------------------------------------------------- 1 | # Copy a DSC Configuration to Azure Automation and compile 2 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3a%2f%2fraw.githubusercontent.com%2fazureautomation%2fautomation-packs%2fmaster%2f201-Deploy-And-Compile-DSC-Configuration%2fazuredeploy.json) 3 | 4 | This DSC configuration installs a full blown webserver. 5 | The configuration file gets imported and compiled. 6 | Once the DSC configuration is published and compiled it can be consumed by any registered DSC node. 7 | 8 | #Requirements 9 | A DSC configuration is made available in the folder Configurations. 10 | a guid for the jobId parameter, you can create a guid using PowerShell: 11 | ``` PowerShell 12 | #PowerShell < v5 13 | [System.Guid]::NewGuid() 14 | 15 | #PowerShell v5 16 | $JobGUID = (New-Guid).Guid 17 | 18 | ``` 19 | 20 | #Known limitations 21 | - I had an issue using a DSC Configuration link containing spaces 22 | - Configurations can only be deployed as 'Published' during the preview 23 | 24 | #Resources deployed 25 | 26 | - Automation account 27 | - DSC Configuration: webrolefull, with a node named 'Full' 28 | reference the DSc configuration as webrolefull.Full 29 | 30 | ``` PowerShell 31 | Configuration webrolefull { 32 | 33 | $features = @( 34 | @{Name = "Web-Server"; Ensure = "Present"}, 35 | @{Name = "Web-WebServer"; Ensure = "Present"}, 36 | @{Name = "Web-Common-http"; Ensure = "Present"}, 37 | @{Name = "Web-Default-Doc"; Ensure = "Present"}, 38 | @{Name = "Web-Dir-Browsing"; Ensure = "Present"}, 39 | @{Name = "Web-Http-Errors"; Ensure = "Present"}, 40 | @{Name = "Web-Static-Content"; Ensure = "Present"}, 41 | @{Name = "Web-Health"; Ensure = "Present"}, 42 | @{Name = "Web-Http-Logging"; Ensure = "Present"}, 43 | @{Name = "Web-Performance"; Ensure = "Present"}, 44 | @{Name = "Web-Stat-Compression"; Ensure = "Present"}, 45 | @{Name = "Web-Dyn-Compression"; Ensure = "Present"}, 46 | @{Name = "Web-Security"; Ensure = "Present"}, 47 | @{Name = "Web-Filtering"; Ensure = "Present"}, 48 | @{Name = "Web-Basic-Auth"; Ensure = "Present"}, 49 | @{Name = "Web-Windows-Auth"; Ensure = "Present"}, 50 | @{Name = "Web-App-Dev"; Ensure = "Present"}, 51 | @{Name = "Web-Net-Ext45"; Ensure = "Present"}, 52 | @{Name = "Web-Asp-Net45"; Ensure = "Present"}, 53 | @{Name = "Web-ISAPI-Ext"; Ensure = "Present"}, 54 | @{Name = "Web-ISAPI-Filter"; Ensure = "Present"}, 55 | @{Name = "Web-Ftp-Server"; Ensure = "Present"}, 56 | @{Name = "Web-Mgmt-Tools"; Ensure = "Present"}, 57 | @{Name = "Web-Mgmt-Console"; Ensure = "Present"} 58 | ) 59 | 60 | node full { 61 | 62 | foreach ($feature in $features){ 63 | WindowsFeature ($feature.Name) { 64 | Name = $feature.Name 65 | Ensure = $feature.Ensure 66 | } 67 | } 68 | } 69 | } 70 | 71 | ``` -------------------------------------------------------------------------------- /201-Deploy-And-Compile-DSC-Configuration/azuredeploy-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "accountName": { 3 | "value": "MyAutomationAccount" 4 | }, 5 | "regionId": { 6 | "value": "East US 2" 7 | }, 8 | "configurationName": { 9 | "value": "webrolefull" 10 | }, 11 | "configurationURI": { 12 | "value": "https://raw.githubusercontent.com/azureautomation/automation-packs/master/201-deploy-and-compile-DSC-configuration/Configurations/webrolefull.ps1" 13 | }, 14 | "configurationDescription": { 15 | "value": "This webserver configuration contains all elements to install a full blown webserver." 16 | }, 17 | "jobId": { 18 | "value": "ee98ff68-ea26-4926-bd02-beb81febb2f9" 19 | } 20 | } -------------------------------------------------------------------------------- /201-Deploy-And-Compile-DSC-Configuration/azuredeploy.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01#", 3 | "contentVersion": "1.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "defaultValue": "MyAutomationAccount", 8 | "metadata": { 9 | "description": "The name of the Automation account to use. If this account exists, check the SKU and tags to make sure they match the exisitng account." 10 | } 11 | }, 12 | "regionId": { 13 | "type": "string", 14 | "defaultValue": "East US 2", 15 | "allowedValues": [ 16 | "Japan East", 17 | "East US 2", 18 | "West Europe", 19 | "Southeast Asia", 20 | "South Central US" 21 | ], 22 | "metadata": { 23 | "description": "The region the Automation account is located in." 24 | } 25 | }, 26 | "configurationName": { 27 | "type": "string", 28 | "defaultValue": "webrolefull", 29 | "metadata": { 30 | "description": "The name of the DSC Configuration. The name must match the name in the URI." 31 | } 32 | }, 33 | "configurationURI": { 34 | "type": "string", 35 | "defaultValue": "https://raw.githubusercontent.com/azureautomation/automation-packs/master/201-Deploy-And-Compile-DSC-Configuration/Configurations/webrolefull.ps1", 36 | 37 | "metadata": { 38 | "description": "The URI for the DSC configuration " 39 | } 40 | }, 41 | "configurationDescription": { 42 | "type": "string", 43 | "defaultValue": "test", 44 | "metadata": { 45 | "description": "The description of the configuration." 46 | } 47 | }, 48 | "jobId": { 49 | "type": "string", 50 | "metadata": { 51 | "description": "the job id to compile the configuration" 52 | } 53 | } 54 | }, 55 | "variables": { 56 | "pricingTier": "Free", 57 | "dscOverwrite": "true" 58 | }, 59 | "resources": [ 60 | { 61 | "name": "[parameters('accountName')]", 62 | "type": "Microsoft.Automation/automationAccounts", 63 | "apiVersion": "2015-01-01-preview", 64 | "location": "[parameters('regionId')]", 65 | "dependsOn": [], 66 | "tags": {}, 67 | "properties": { 68 | "sku": { 69 | "name": "[variables('pricingTier')]" 70 | } 71 | }, 72 | "resources": [ 73 | { 74 | "name": "[parameters('configurationName')]", 75 | "type": "Configurations", 76 | "apiVersion": "2015-01-01-preview", 77 | "location": "[parameters('regionId')]", 78 | "tags": {}, 79 | "dependsOn": [ 80 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 81 | ], 82 | "properties": { 83 | "logVerbose": "false", 84 | "description": "[parameters('configurationDescription')]", 85 | "state": "Published", 86 | "overwrite": "[variables('dscOverwrite')]", 87 | "Source": { 88 | "type": "uri", 89 | "Value": "[parameters('configurationURI')]" 90 | } 91 | } 92 | }, 93 | { 94 | "name": "[parameters('jobId')]", 95 | "type": "Compilationjobs", 96 | "apiVersion": "2015-01-01-preview", 97 | "location": "parameters('regionId')]", 98 | "tags": {}, 99 | "dependsOn": [ 100 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]", 101 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'),'/Configurations/', parameters('configurationName'))]" 102 | ], 103 | "properties": { 104 | "configuration": { 105 | "name": "[parameters('configurationName')]" 106 | } 107 | } 108 | } 109 | ] 110 | } 111 | ], 112 | "outputs": {} 113 | } -------------------------------------------------------------------------------- /201-Deploy-And-Compile-DSC-Configuration/deployThroughARM.ps1: -------------------------------------------------------------------------------- 1 | 2 | #Connect to your Azure account 3 | Add-AzureAccount 4 | 5 | #Select your subscription if you have more than one 6 | #Select-AzureSubscription -SubscriptionName "My Subscription Name" 7 | 8 | #Create a GUID for the job 9 | $JobGUID = [System.Guid]::NewGuid().toString() 10 | 11 | #Use Azure resource Manager to deploy template 12 | Switch-AzureMode -Name AzureResourceManager 13 | 14 | #Set the parameter values for the template 15 | $Params = @{ 16 | 'accountName' = 'MyAutomationAccount' 17 | 'regionId' = 'East US 2' 18 | 'configurationName' = 'webrolefull' 19 | 'configurationURI' = 'https://raw.githubusercontent.com/azureautomation/automation-packs/master/201-deploy-and-compile-DSC-configuration/Configurations/webrolefull.ps1' 20 | 'configurationDescription' = 'This webserver configuration contains all elements to install a full blown webserver' 21 | 'jobId' = $JobGUID 22 | 23 | } 24 | 25 | $TemplateURI = "https://raw.githubusercontent.com/azureautomation/automation-packs/master/201-Deploy-And-Compile-DSC-Configuration/azuredeploy.json" 26 | 27 | New-AzureResourceGroupDeployment -TemplateParameterObject $Params -ResourceGroupName "MyResourceGroup" -TemplateUri $TemplateURI -------------------------------------------------------------------------------- /201-deploy-dsc-resources-and-configuration/Configurations/myTimezone.ps1: -------------------------------------------------------------------------------- 1 | Configuration myTimezone { 2 | param( 3 | [string]$zone 4 | ) 5 | 6 | Import-DscResource -ModuleName xTimezone 7 | 8 | node zone { 9 | xTimeZone zone { 10 | IsSingleInstance = 'Yes' 11 | TimeZone = $zone 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /201-deploy-dsc-resources-and-configuration/README.md: -------------------------------------------------------------------------------- 1 | # Copy a DSC Configuration to Azure Automation and compile 2 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3a%2f%2fraw.githubusercontent.com%2fazureautomation%2fautomation-packs%2fmaster%2f201-deplopy-dsc-resources-and-configuration%2fazuredeploy.json) 3 | 4 | This DSC configuration sets the timezone to the desired zone. 5 | The timezone can be set using a parameter. 6 | The configuration file gets imported and compiled. 7 | Once the DSC configuration is published and compiled it can be consumed by any registered DSC node. 8 | 9 | #Requirements 10 | A DSC configuration is made available in the folder Configurations. 11 | a guid for the jobId parameter, you can create a guid using PowerShell: 12 | ``` PowerShell 13 | #PowerShell < v5 14 | [System.Guid]::NewGuid() 15 | 16 | #PowerShell v5 17 | $JobGUID = (New-Guid).Guid 18 | ``` 19 | 20 | #Known limitations 21 | - I had an issue using a DSC Configuration link containing spaces 22 | - Configurations can only be deployed as 'Published' during the preview 23 | 24 | #Resources deployed 25 | 26 | - Automation account 27 | - DSC resource module 28 | the DSC resource used is called xTimeZone. The module is maintained on github and hosted on the [powershell Gallery](https://www.powershellgallery.com/packages/xTimeZone/) 29 | - DSC Configuration: mytimezone, with a node named 'Test' 30 | - a compilation job to compile the configuration 31 | reference the DSC configuration as webrolefull.Full 32 | 33 | ##configuration details 34 | 35 | ``` PowerShell 36 | Configuration myTimezone { 37 | param( 38 | [string]$zone 39 | ) 40 | 41 | Import-DscResource -ModuleName xTimezone 42 | 43 | node zone { 44 | xTimeZone zone { 45 | IsSingleInstance = 'Yes' 46 | TimeZone = $zone 47 | } 48 | } 49 | } 50 | ``` 51 | 52 | ## timezone information 53 | You can use powershell to find a timezone: 54 | 55 | ``` PowerShell 56 | [System.TimeZoneInfo]::GetSystemTimeZones().Id 57 | 58 | <# Sample output 59 | Dateline Standard Time 60 | UTC-11 61 | Hawaiian Standard Time 62 | Alaskan Standard Time 63 | Pacific Standard Time (Mexico) 64 | Pacific Standard Time 65 | US Mountain Standard Time 66 | Mountain Standard Time (Mexico) 67 | Mountain Standard Time 68 | Central America Standard Time 69 | Central Standard Time 70 | Central Standard Time (Mexico) 71 | Canada Central Standard Time 72 | SA Pacific Standard Time 73 | Eastern Standard Time (Mexico) 74 | Eastern Standard Time 75 | US Eastern Standard Time 76 | Venezuela Standard Time 77 | Paraguay Standard Time 78 | Atlantic Standard Time 79 | Central Brazilian Standard Time 80 | SA Western Standard Time 81 | Newfoundland Standard Time 82 | E. South America Standard Time 83 | SA Eastern Standard Time 84 | Argentina Standard Time 85 | Greenland Standard Time 86 | Montevideo Standard Time 87 | Bahia Standard Time 88 | Pacific SA Standard Time 89 | UTC-02 90 | Mid-Atlantic Standard Time 91 | Azores Standard Time 92 | Cape Verde Standard Time 93 | Morocco Standard Time 94 | UTC 95 | ... 96 | #> 97 | 98 | ```` -------------------------------------------------------------------------------- /201-deploy-dsc-resources-and-configuration/azuredeploy-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "accountName": { 3 | "value": "MyAutomationAccount" 4 | }, 5 | "regionId": { 6 | "value": "East US 2" 7 | }, 8 | "configurationName": { 9 | "value": "myTimezone" 10 | }, 11 | "configurationURI": { 12 | "value": "https://raw.githubusercontent.com/azureautomation/automation-packs/master/201-deploy-dsc-resources-and-configuration/Configurations/myTimezone.ps1" 13 | }, 14 | "configurationDescription": { 15 | "value": "Configuration to set the timezone" 16 | }, 17 | "jobId": { 18 | "value": "7c02ac25-646d-4335-b948-7c589e2806a6" 19 | } 20 | } -------------------------------------------------------------------------------- /201-deploy-dsc-resources-and-configuration/deployThroughARM.ps1: -------------------------------------------------------------------------------- 1 | 2 | #Connect to your Azure account 3 | Add-AzureAccount 4 | 5 | #Select your subscription if you have more than one 6 | #Select-AzureSubscription -SubscriptionName "My Subscription Name" 7 | 8 | #Create a GUID for the job 9 | $JobGUID = [System.Guid]::NewGuid().toString() 10 | 11 | #Use Azure resource Manager to deploy template 12 | Switch-AzureMode -Name AzureResourceManager 13 | 14 | #Set the parameter values for the template 15 | $Params = @{ 16 | 'accountName' = 'MyAutomationAccount' 17 | 'regionId' = 'East US 2' 18 | 'configurationName' = 'myTimezone' 19 | 'configurationURI' = 'https://raw.githubusercontent.com/azureautomation/automation-packs/master/201-deploy-dsc-resources-and-configuration/Configurations/myTimezone.ps1' 20 | 'configurationDescription' = 'Set the timezone using DSC. for a full list of supported values execute [System.TimeZoneInfo]::GetSystemTimeZones().Id in PowerShell' 21 | 'jobId' = $JobGUID 22 | 23 | } 24 | 25 | $TemplateURI = "https://raw.githubusercontent.com/azureautomation/automation-packs/master/201-deplopy-dsc-resources-and-configuration/azuredeploy.json" 26 | 27 | New-AzureResourceGroupDeployment -TemplateParameterObject $Params -ResourceGroupName "MyResourceGroup" -TemplateUri $TemplateURI -------------------------------------------------------------------------------- /201-start-azure-vm-graphical-base-templates/README.md: -------------------------------------------------------------------------------- 1 | # Start Azure Classic VM Graph Runbook 2 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fazureautomation%2Fautomation-packs%2Fmaster%2F201-start-azure-vm-graphical%2FdeployAutomationResources.json) 3 | 4 | 5 | This is an Azure Automation graph runbook that gets all of your Azure VMs or just the VMs in a service and then starts the ones that are stopped. You can set this on a schedule to start the VMs when you want. Use in conjunction with StopAzureClassicVM runbook to start and stop VMs as you need them. 6 | 7 | You can import and use this runbook only in the **Azure Preview Portal**. 8 | 9 | This runbook relies on 2 assets which are also deployed as part of this template: 10 | 11 | 1. Credential 12 | 2. Variable 13 | 14 | 15 | ## Resources Deployed 16 | ### Automation Account 17 | This is the Automation account that will contain your runbook and credentials. 18 | 19 | If you want to deploy to an existing account, make sure that the Resource Group, region, tags, and pricing tier in the template are all the same as your existing account, otherwise the properties will be overwritten. 20 | 21 | ### Runbook 22 | This graphical runbook is loaded to Azure Automation as a draft runbook. 23 | 24 | ### Credential 25 | An Automation credential asset called AzureCredential that contains the Azure AD user credential with authorization for this subscription. To use an asset with a different name you can pass the asset name as a runbook input parameter or change the default value for the input parameter. 26 | 27 | To learn about how to create this user, see [Get set up to automate Azure]("http://aka.ms/getsetuptoautomate") and check out this blog post [Authenticating to Azure using Active Directory]("http://azure.microsoft.com/blog/2014/08/27/azure-automation-authenticating-to-azure-using-azure-active-directory/"). 28 | 29 | ### Variable 30 | An Automation variable asset called **AzureSubscriptionId** that contains the GUID for this Azure subscription. To use an asset with a different name you can pass the asset name as a runbook input parameter or change the default value for the input parameter. -------------------------------------------------------------------------------- /201-start-azure-vm-graphical/README.md: -------------------------------------------------------------------------------- 1 | # Start Azure Classic VM Graph Runbook 2 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fazureautomation%2Fautomation-packs%2Fmaster%2F201-start-azure-vm-graphical%2Fazuredeploy.json) 3 | 4 | 5 | This is an Azure Automation graph runbook that gets all of your Azure VMs or just the VMs in a service and then starts the ones that are stopped. You can set this on a schedule to start the VMs when you want. Use in conjunction with StopAzureClassicVM runbook to start and stop VMs as you need them. 6 | 7 | You can import and use this runbook only in the **Azure Preview Portal**. 8 | 9 | This runbook relies on 2 assets which are also deployed as part of this template: 10 | 11 | 1. Credential 12 | 2. Variable 13 | 14 | 15 | ## Resources Deployed 16 | ### Automation Account 17 | This is the Automation account that will contain your runbook and credentials. 18 | 19 | If you want to deploy to an existing account, make sure that the Resource Group, region, tags, and pricing tier in the template are all the same as your existing account, otherwise the properties will be overwritten. 20 | 21 | ### Runbook 22 | This graphical runbook is loaded to Azure Automation as a draft runbook. 23 | 24 | ### Credential 25 | An Automation credential asset called AzureCredential that contains the Azure AD user credential with authorization for this subscription. To use an asset with a different name you can pass the asset name as a runbook input parameter or change the default value for the input parameter. 26 | 27 | To learn about how to create this user, see [Get set up to automate Azure](http://aka.ms/getsetuptoautomate) and check out this blog post [Authenticating to Azure using Active Directory](http://azure.microsoft.com/blog/2014/08/27/azure-automation-authenticating-to-azure-using-azure-active-directory/). 28 | 29 | ### Variable 30 | An Automation variable asset called **AzureSubscriptionId** that contains the GUID for this Azure subscription. To use an asset with a different name you can pass the asset name as a runbook input parameter or change the default value for the input parameter. -------------------------------------------------------------------------------- /201-stop-azure-vm-graphical/README.md: -------------------------------------------------------------------------------- 1 | # Stop Azure Classic VM Graph Runbook 2 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fazureautomation%2Fautomation-packs%2Fmaster%2F201-stop-azure-vm-graphical%2Fazuredeploy.json) 3 | 4 | 5 | This is an Azure Automation graph runbook that gets all of your Azure VMs or just the VMs in a service and then stops the ones that are started. You can set this on a schedule to stop the VMs when you want. Use in conjunction with StartAzureClassicVM runbook to start and stop VMs as you need them. 6 | 7 | You can import and use this runbook only in the **Azure Preview Portal**. 8 | 9 | This runbook relies on 2 assets which are also deployed as part of this template: 10 | 11 | 1. Credential 12 | 2. Variable 13 | 14 | ## Resources Deployed 15 | ### Automation Account 16 | This is the Automation account that will contain your runbook and credentials. 17 | 18 | If you want to deploy to an existing account, make sure that the Resource Group, region, tags, and pricing tier in the template are all the same as your existing account, otherwise the properties will be overwritten. 19 | 20 | ### Runbook 21 | This graphical runbook is loaded to Azure Automation as a draft runbook. 22 | 23 | ### Credential 24 | An Automation credential asset called AzureCredential that contains the Azure AD user credential with authorization for this subscription. To use an asset with a different name you can pass the asset name as a runbook input parameter or change the default value for the input parameter. 25 | 26 | To learn about how to create this user, see [Get set up to automate Azure](http://aka.ms/getsetuptoautomate) and check out this blog post [Authenticating to Azure using Active Directory](http://azure.microsoft.com/blog/2014/08/27/azure-automation-authenticating-to-azure-using-azure-active-directory/). 27 | 28 | ### Variable 29 | An Automation variable asset called **AzureSubscriptionId** that contains the GUID for this Azure subscription. To use an asset with a different name you can pass the asset name as a runbook input parameter or change the default value for the input parameter. -------------------------------------------------------------------------------- /201-stop-azure-vm-graphical/azuredeploy.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01-preview#", 3 | "contentVersion": "1.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Azure Automation account to deploy to." 9 | } 10 | }, 11 | "regionId": { 12 | "type": "string", 13 | "allowedValues": [ 14 | "Japan East", 15 | "East US 2", 16 | "West Europe", 17 | "Southeast Asia", 18 | "South Central US" 19 | ], 20 | "metadata": { 21 | "description": "The region to deploy the Automation account in." 22 | } 23 | }, 24 | "userName": { 25 | "type": "string", 26 | "metadata": { 27 | "description": "The username for the Azure Automation credential." 28 | } 29 | }, 30 | "password": { 31 | "type": "secureString", 32 | "metadata": { 33 | "description": "The password for the Azure Automation credential." 34 | } 35 | }, 36 | "subscriptionIdValue": { 37 | "type": "string", 38 | "metadata": { 39 | "description": "Your Azure subscription ID." 40 | } 41 | } 42 | }, 43 | "variables": { 44 | "pricingTier": "Free", 45 | 46 | "runbookName": "StopAzureClassicVM", 47 | "runbookUri": "https://gallery.technet.microsoft.com/scriptcenter/Stop-Azure-Classic-VM-397819bd/file/141790/1/StopAzureClassicVM.graphrunbook", 48 | "runbookType": "Graph", 49 | "runbookDescription": "This is an Azure Automation graph runbook that gets all of your Azure VMs or just the VMs in a service and then stops the ones that are started. You can only import and use this runbook in the Preview Azure portal.", 50 | 51 | "credentialName": "AzureCredential", 52 | 53 | "variableName": "AzureSubscriptionId", 54 | "variableType": "string" 55 | 56 | }, 57 | "resources": [ 58 | { 59 | "name": "[parameters('accountName')]", 60 | "type": "Microsoft.Automation/automationAccounts", 61 | "apiVersion": "2015-01-01-preview", 62 | "location": "[parameters('regionId')]", 63 | "dependsOn": [ ], 64 | "tags": { }, 65 | "properties": { 66 | "sku": { 67 | "name": "[variables('pricingTier')]" 68 | } 69 | }, 70 | "resources": [ 71 | { 72 | "name": "[variables('runbookName')]", 73 | "type": "runbooks", 74 | "apiVersion": "2015-01-01-preview", 75 | "location": "[parameters('regionId')]", 76 | "dependsOn": [ 77 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 78 | ], 79 | "tags": { 80 | }, 81 | "properties": { 82 | "runbookType": "[variables('runbookType')]", 83 | "logProgress": "false", 84 | "logVerbose": "false", 85 | "description": "[variables('runbookDescription')]", 86 | "draft": { 87 | "draftContentLink": { 88 | "uri": "[variables('runbookUri')]", 89 | "version": "1.0.0.0" 90 | } 91 | } 92 | } 93 | }, 94 | { 95 | "name": "[variables('credentialName')]", 96 | "type": "credentials", 97 | "apiVersion": "2015-01-01-preview", 98 | "location": "[parameters('regionId')]", 99 | "dependsOn": [ 100 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 101 | ], 102 | "tags": { }, 103 | "properties": { 104 | "userName": "[parameters('userName')]", 105 | "password": "[parameters('password')]" 106 | } 107 | }, 108 | { 109 | "name": "[variables('variableName')]", 110 | "type": "variables", 111 | "apiVersion": "2015-01-01-preview", 112 | "location": "[parameters('regionId')]", 113 | "dependsOn": [ 114 | "[concat('Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 115 | ], 116 | "tags": { 117 | }, 118 | "properties": { 119 | "description": "Subscription ID for the Azure account to manage.", 120 | "isEncrypted": 0, 121 | "type": "[variables('variableType')]", 122 | "value": "[concat('\"',parameters('subscriptionIdValue'),'\"')]" 123 | } 124 | } 125 | ] 126 | } 127 | ], 128 | "outputs": {} 129 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Azure Automation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Automation Packs 2 | Automation Packs include an Azure Resource Manager template that deploys Automation resources to Azure. The template can include any Automation resource needed for an Automation solution. Automation resources include: 3 | 4 | - Runbooks 5 | - DSC Configurations 6 | - DSC Configuration Compilation Jobs 7 | - Runbook jobs 8 | - Integration Modules 9 | - Schedules 10 | - Credentials 11 | - Certificates 12 | - Variables 13 | - Connections 14 | 15 | ##Rules for contributing to the Automation repository 16 | 17 | 1. Each Automation pack is contained in its own folder. 18 | 2. The parent deployment template must be named **azuredeploy.json**. You can also have child templates which do not need to follow a naming convention. 19 | 3. Include a **Readme.md** file that explains: 20 | 4. How the template works and what the Automation pack automates 21 | 5. What resources are deployed 22 | 6. Includes the "Deploy to Azure" link 23 | 7. Any known limitations 24 | 25 | 4. Any Automation assets used in your runbooks or DSC configurations should be included in the deployment template. 26 | 5. Any runbooks, modules, or DSC Configurations in your ARM template should use the following conventions: 27 | 6. 28 | 1. A **variable** containing the **URL** for the resource content 29 | 2. A **variable** containing the **Name** of the resource 30 | 31 | 5. Any Automation assets in your template should follow the the following conventions: 32 | 6. 33 | 1. **Parameter(s)** for the asset value(s) are in the deployment template to allow end users input their own values 34 | 2. A **variable** for each asset name 35 | 36 | 5. Template parameters should: 37 | 1. Follow **camelCasing** 38 | 2. Contain **allowedValues** wherever it makes sense 39 | 3. Have the **description** specified using the metadata property. An example is included below: 40 | 41 | ```json 42 | "automationAccountName": { 43 | "type": "string", 44 | "metadata": { 45 | "description": "The name of the Automation Account" 46 | } 47 | } 48 | ``` 49 | 50 | ##Recommendations for writing your Automation Pack 51 | ### Runbooks in Automation Packs 52 | You can store runbooks referenced in Automation Packs in two different ways: 53 | 54 | 1. In an external location of your choice. Preferred locations are the [PowerShell Gallery](https://www.powershellgallery.com) or [Script Center](https://gallery.technet.microsoft.com/scriptcenter/site/search?f%5B0%5D.Type=RootCategory&f%5B0%5D.Value=WindowsAzure&f%5B0%5D.Text=Windows%20Azure) 55 | 2. In a Runbook subfolder within the Automation Pack. 56 | 57 | Best practices for runbooks: 58 | 59 | 1. Follow practices outlined [here](http://social.technet.microsoft.com/wiki/contents/articles/26616.quick-tips-and-tricks-for-runbook-writing.aspx). 60 | 2. Always include a header with the following when publishing to PowerShell Gallery: 61 | 62 | ```PowerShell 63 | <#PSScriptInfo 64 | 65 | .Version 1.0 66 | .Author elcooper 67 | .CompanyName Microsoft Corporation 68 | .Copyright (c) 2015 Microsoft Corporation. All rights reserved. 69 | .Tags Tag1 Tag2 70 | .LicenseUri https://contoso.com/License 71 | .ProjectUri https://contoso.com/ 72 | .IconUri https://contoso.com/MyScriptIcon 73 | .ExternalModuleDependencies bar 74 | .RequiredScripts foo 75 | 76 | .ReleaseNotes 77 | contoso script now supports following features 78 | Feature 1 79 | Feature 2 80 | Feature 3 81 | 82 | #> 83 | ``` 84 | 85 | 86 | ### PowerShell Modules in Automation Packs 87 | You can store modules used in your runbook in two different ways: 88 | 89 | 1. Create a Module subfolder and place all your modules in the folder. 90 | 2. Place your modules on the [PowerShell GitHub repository](https://github.com/powershell) and publish your module to [PowerShell Gallery](https://www.powershellgallery.com/). 91 | 92 | To deploy a module, you must also have a zipped module folder formatted for Azure Automation. This is used in the Azure Resource Manager deployment template. For more on creating modules for Azure Automation see [Authoring Integration Modules](http://azure.microsoft.com/blog/2014/12/15/authoring-integration-modules-for-azure-automation/). 93 | 94 | Follow the PowerShell best practices for publishing a module to the PowerShell gallery outlined in this [blog](http://blogs.msdn.com/b/powershell/archive/2015/07/07/powershell-gallery-registration-is-now-unrestricted.aspx). 95 | 96 | 97 | ## Other notes on authoring Automation Packs 98 | If you have a pack that contains many Automation resources, you can write one parent template that refers to the base templates: [000-base-templates](https://github.com/azureautomation/automation-packs/tree/Master/000-base-automation-resource-templates). This allows you to reuse the core Automation resource templates without having to write your own. 99 | -------------------------------------------------------------------------------- /deploy-vm-with-dsc-configuration/README.md: -------------------------------------------------------------------------------- 1 | # Azure Automation Deploy VM with DSC Configuration demo 2 | 3 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fazureautomation%2Fautomation-packs%2Fmaster%2Fdeploy-vm-with-dsc-configuration%2Fazuredeploy.json) 4 | 5 | 6 | 7 | 8 | This Azure Resource Manager template deploys a new Windows Server 2016 VM, installs the DSC extension and applies a DSC configuration. 9 | 10 | ## Resources Deployed 11 | 12 | 1. Windows Server 2016 Datacenter VM using Standard DS1 scale. 13 | 2. Microsoft.PowerShell.DSC VM extension. 14 | 15 | ## Inputs 16 | 17 | Deployment of the template will prompt for the following inputs: 18 | 19 | - Resource Group Name: The name of the resource group where the VM is to be deployed. 20 | - Region: The region where the VM VM will be deployed. 21 | - VM Name: The name given to the VM to be deployed. 22 | - Username: The username that will be configured as the administrator for the VM. 23 | - Password: The password that will be configured for the administrator account. 24 | - Account Name: The automation account that will be used to link for DSC configuration (this must already exist). 25 | - Account Resource Group Name: The resource group where the automation account resides (this must already exist). 26 | - Node Configuration Name: The name of the DSC node configuration to be applied to the VM (this must already exist). 27 | -------------------------------------------------------------------------------- /deploy-vm-with-dsc-configuration/azuredeploy.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "VMName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of VM" 9 | } 10 | }, 11 | "Username": { 12 | "type": "string", 13 | "metadata": { 14 | "description": "The name user to add with access to the VM." 15 | } 16 | }, 17 | "Password": { 18 | "type": "securestring", 19 | "metadata": { 20 | "description": "The password of the user" 21 | } 22 | }, 23 | "accountName": { 24 | "type": "string", 25 | "minLength": 6, 26 | "metadata": { 27 | "description": "The name of the Automation account to connect to DSC." 28 | } 29 | }, 30 | "accountResourceGroupName": { 31 | "type": "string", 32 | "metadata": { 33 | "description": "The resource group where the automation account exists." 34 | } 35 | }, 36 | "nodeConfigurationName": { 37 | "type": "string", 38 | "metadata": { 39 | "description": "The name of the node configuration to apply to the VM." 40 | } 41 | } 42 | }, 43 | "resources": [ 44 | { 45 | "type": "Microsoft.Resources/deployments", 46 | "apiVersion": "2017-05-10", 47 | "name": "ManagedVM", 48 | "properties": { 49 | "mode": "Incremental", 50 | "templateLink": { 51 | "uri": "https://raw.githubusercontent.com/azureautomation/automation-packs/master/deploy-vm-with-dsc-configuration/linked-templates/Windows2016Server.json", 52 | "contentVersion": "1.0.0.0" 53 | }, 54 | "parameters": { 55 | "username": { 56 | "value": "[parameters('username')]" 57 | }, 58 | "password": { 59 | "value": "[parameters('password')]" 60 | }, 61 | "vmName": { 62 | "value": "[parameters('VMName')]" 63 | } 64 | } 65 | } 66 | }, 67 | { 68 | "type": "Microsoft.Resources/deployments", 69 | "apiVersion": "2017-05-10", 70 | "name": "DSCAgent", 71 | "dependsOn": [ 72 | "[concat('Microsoft.Resources/deployments/', 'ManagedVM')]" 73 | ], 74 | "properties": { 75 | "mode": "Incremental", 76 | "templateLink": { 77 | "uri": "https://raw.githubusercontent.com/azureautomation/automation-packs/master/deploy-vm-with-dsc-configuration/linked-templates/dscagent.json", 78 | "contentVersion": "1.0.0.0" 79 | }, 80 | "parameters": { 81 | "accountName": { 82 | "value": "[parameters('accountName')]" 83 | }, 84 | "accountResourceGroupName": { 85 | "value": "[parameters('accountResourceGroupName')]" 86 | }, 87 | "nodeConfigurationName": { 88 | "value": "[parameters('nodeConfigurationName')]" 89 | }, 90 | "vmName": { 91 | "value": "[parameters('VMName')]" 92 | }, 93 | "vmRegion": { 94 | "value": "[resourceGroup().location]" 95 | } 96 | } 97 | } 98 | } 99 | ], 100 | "outputs": {} 101 | } -------------------------------------------------------------------------------- /deploy-vm-with-dsc-configuration/linked-templates/Windows2016Server.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "username": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "Username for the Virtual Machine." 9 | } 10 | }, 11 | "password": { 12 | "type": "securestring", 13 | "metadata": { 14 | "description": "Password for the Virtual Machine." 15 | } 16 | }, 17 | "vmName": { 18 | "type": "string", 19 | "metadata": { 20 | "description": "Name of the vm, will be used as DNS Name for the Public IP used to access the Virtual Machine." 21 | } 22 | }, 23 | "vmSize": { 24 | "type": "string", 25 | "defaultValue": "Standard_DS1_v2", 26 | "metadata": { 27 | "description": "VM size" 28 | }, 29 | "allowedValues": [ 30 | "Standard_DS1_v2", 31 | "Standard_D2", 32 | "Standard_D3", 33 | "Standard_D4", 34 | "Standard_D11", 35 | "Standard_D12", 36 | "Standard_D13", 37 | "Standard_D14" 38 | ] 39 | }, 40 | "OSVersion": { 41 | "type": "string", 42 | "defaultValue": "2016-Datacenter", 43 | "metadata": { 44 | "description": "The VM version" 45 | } 46 | } 47 | }, 48 | "variables": { 49 | "virtualNetworkName": "vnet-demo", 50 | "nicName": "[toLower(parameters('vmName'))]", 51 | "publicIPAddressName": "[toLower(parameters('vmName'))]", 52 | "vnetAddressPrefix": "10.0.0.0/16", 53 | "subnetName": "demo", 54 | "subnetPrefix": "10.0.0.0/24", 55 | "publicIPAddressType": "Dynamic", 56 | "vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]", 57 | "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", 58 | "storageAccountType": "Standard_LRS", 59 | "imagePublisher": "MicrosoftWindowsServer", 60 | "imageOffer": "WindowsServer" 61 | }, 62 | "resources": [ 63 | { 64 | "apiVersion": "2017-06-01", 65 | "type": "Microsoft.Network/publicIPAddresses", 66 | "name": "[variables('publicIPAddressName')]", 67 | "location": "[resourceGroup().location]", 68 | "properties": { 69 | "publicIPAllocationMethod": "[variables('publicIPAddressType')]", 70 | "dnsSettings": { 71 | "domainNameLabel": "[toLower(parameters('vmName'))]" 72 | } 73 | } 74 | }, { 75 | "apiVersion": "2017-06-01", 76 | "type": "Microsoft.Network/virtualNetworks", 77 | "name": "[variables('virtualNetworkName')]", 78 | "location": "[resourceGroup().location]", 79 | "properties": { 80 | "addressSpace": { 81 | "addressPrefixes": [ 82 | "[variables('vnetAddressPrefix')]" 83 | ] 84 | }, 85 | "subnets": [{ 86 | "name": "[variables('subnetName')]", 87 | "properties": { 88 | "addressPrefix": "[variables('subnetPrefix')]" 89 | } 90 | }] 91 | } 92 | }, { 93 | "apiVersion": "2017-06-01", 94 | "type": "Microsoft.Network/networkInterfaces", 95 | "name": "[variables('nicName')]", 96 | "location": "[resourceGroup().location]", 97 | "dependsOn": [ 98 | "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]", 99 | "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" 100 | ], 101 | "properties": { 102 | "ipConfigurations": [{ 103 | "name": "ipconfig1", 104 | "properties": { 105 | "privateIPAllocationMethod": "Dynamic", 106 | "publicIPAddress": { 107 | "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]" 108 | }, 109 | "subnet": { 110 | "id": "[variables('subnetRef')]" 111 | } 112 | } 113 | }] 114 | } 115 | }, { 116 | "apiVersion": "2017-03-30", 117 | "type": "Microsoft.Compute/virtualMachines", 118 | "name": "[parameters('vmName')]", 119 | "location": "[resourceGroup().location]", 120 | "dependsOn": [ 121 | "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" 122 | ], 123 | "properties": { 124 | "hardwareProfile": { 125 | "vmSize": "[parameters('vmSize')]" 126 | }, 127 | "osProfile": { 128 | "computerName": "[parameters('vmName')]", 129 | "adminUsername": "[parameters('username')]", 130 | "adminPassword": "[parameters('password')]" 131 | }, 132 | "storageProfile": { 133 | "imageReference": { 134 | "publisher": "[variables('imagePublisher')]", 135 | "offer": "[variables('imageOffer')]", 136 | "sku": "[parameters('OSVersion')]", 137 | "version": "latest" 138 | }, 139 | "osDisk": { 140 | "createOption": "FromImage", 141 | "managedDisk": { 142 | "storageAccountType": "[variables('storageAccountType')]" 143 | } 144 | }, 145 | "dataDisks": [] 146 | }, 147 | "networkProfile": { 148 | "networkInterfaces": [{ 149 | "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]" 150 | }] 151 | } 152 | } 153 | } 154 | ] 155 | } 156 | -------------------------------------------------------------------------------- /deploy-vm-with-dsc-configuration/linked-templates/dscagent.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01-preview#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "accountName": { 6 | "metadata": { 7 | "description": "The name of the Azure Automation account to deploy to." 8 | }, 9 | "type": "string" 10 | }, 11 | "accountResourceGroupName": { 12 | "type": "string", 13 | "metadata": { 14 | "description": "The name of the resource group for the Automation account." 15 | } 16 | }, 17 | "nodeConfigurationName": { 18 | "type": "string", 19 | "metadata": { 20 | "description": "The node configuration name to apply" 21 | } 22 | }, 23 | "vmName": { 24 | "type": "string", 25 | "metadata": { 26 | "description": "The name of the VM to enable the DSC extension on." 27 | } 28 | }, 29 | "vmRegion": { 30 | "type": "string", 31 | "metadata": { 32 | "description": "The name of the VM resource group" 33 | } 34 | } 35 | }, 36 | "resources": [ 37 | { 38 | "name": "[concat(parameters('vmName'),'/Microsoft.Powershell.DSC')]", 39 | "type": "Microsoft.Compute/virtualMachines/extensions", 40 | "location": "[parameters('vmRegion')]", 41 | "tags": { 42 | "AutomationAccountARMID": "[resourceId(parameters('accountResourceGroupName'), 'Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 43 | }, 44 | "apiVersion": "2015-06-15", 45 | "properties": { 46 | "publisher": "Microsoft.Powershell", 47 | "type": "DSC", 48 | "typeHandlerVersion": "2.74", 49 | "autoUpgradeMinorVersion": true, 50 | "settings": { 51 | "Properties": [ 52 | { 53 | "Name": "RegistrationKey", 54 | "Value": { 55 | "UserName": "PLACEHOLDER_DONOTUSE", 56 | "Password": "PrivateSettingsRef:registrationKeyPrivate" 57 | }, 58 | "TypeName": "System.Management.Automation.PSCredential" 59 | }, 60 | { 61 | "Name": "RegistrationUrl", 62 | "Value": "[reference(resourceId(parameters('accountResourceGroupName'), 'Microsoft.Automation/automationAccounts/', parameters('accountName')),'2015-01-01-preview').RegistrationUrl]", 63 | "TypeName": "System.String" 64 | }, 65 | { 66 | "Name": "ConfigurationMode", 67 | "Value": "ApplyAndAutoCorrect", 68 | "TypeName": "System.String" 69 | }, 70 | { 71 | "Name": "NodeConfigurationName", 72 | "Value": "[parameters('nodeConfigurationName')]", 73 | "TypeName": "System.String" 74 | }, 75 | { 76 | "Name": "ConfigurationModeFrequencyMins", 77 | "Value": "15", 78 | "TypeName": "System.Int32" 79 | }, 80 | { 81 | "Name": "RefreshFrequencyMins", 82 | "Value": "30", 83 | "TypeName": "System.Int32" 84 | }, 85 | { 86 | "Name": "RebootNodeIfNeeded", 87 | "Value": true, 88 | "TypeName": "System.Boolean" 89 | }, 90 | { 91 | "Name": "AllowModuleOverwrite", 92 | "Value": true, 93 | "TypeName": "System.Boolean" 94 | }, 95 | { 96 | "Name": "ActionAfterReboot", 97 | "Value": "ContinueConfiguration", 98 | "TypeName": "System.String" 99 | } 100 | ] 101 | }, 102 | "protectedSettings": { 103 | "Items": { 104 | "registrationKeyPrivate": "[listKeys(resourceId(parameters('accountResourceGroupName'), 'Microsoft.Automation/automationAccounts/', parameters('accountName')), '2015-01-01-preview').Keys[0].value]" 105 | } 106 | } 107 | } 108 | } 109 | ] 110 | } -------------------------------------------------------------------------------- /managed-vm/README.md: -------------------------------------------------------------------------------- 1 | # Azure Automation Managed VM demo 2 | 3 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fazureautomation%2Fautomation-packs%2Fmaster%2Fmanaged-vm%2Fazuredeploy.json) 4 | 5 | 6 | 7 | 8 | This Azure Resource Manager template deploys a new Windows Server 2016 VM and configures it to be managed with Azure Automation features. These include Update management, Inventory, Change Tracking, Desired State Configuration, and makes the VM a hybrid worker. 9 | 10 | ## Azure Automation features 11 | 12 | This template deploys everything into a single resource group. The VM will get created in the resource group region with the Automation account and Log Analytics workspace created in the supplied region. 13 | 14 | ## Templates used in the deployment 15 | 16 | ### Solution template 17 | 18 | [Solution template](https://raw.githubusercontent.com/azureautomation/automation-packs/master/managed-vm/linked-templates/solution.json) deploys three automation solutions to the workspace. 19 | 20 | * AzureAutomation is used for deploying hybrid workers on a VM. 21 | 22 | * ChangeTracking delivers Inventory and Change Tracking. 23 | 24 | * Updates are deployed for assessment and deployment of updates. 25 | 26 | [Automation hybrid worker with DSC template](https://raw.githubusercontent.com/azureautomation/automation-packs/master/managed-vm/linked-templates/hybridworkerwithdsc.json) creates an automation account and does the following: 27 | * Imports [hybridRunbookWorkerDSC](https://www.powershellgallery.com/packages/HybridRunbookWorkerDsc/1.0.0.0) from the PowerShellGallery.com. 28 | * Creates a variable to hold the registration URL for the account. 29 | * Creates a credential to hold the registration key for the account. 30 | * Import the [DSC configuration](https://raw.githubusercontent.com/azureautomation/automation-packs/master/managed-vm/dsc-configurations/HybridWorkerConfig.ps1) to register the hybrid worker on the VM with the automation account. 31 | * Compiles the imported configuration so it is available to be used by a VM that requires this configuration. 32 | 33 | [Link workspace with automation account](https://raw.githubusercontent.com/azureautomation/automation-packs/master/managed-vm/linked-templates/linkedworkspaceaccount.json) to link the workspace with the automation account for use with Update Management, Change Tracking, and Inventory. It also enables DSC and automation logs to be sent to the workspace. 34 | 35 | [Windows2016Server template](https://raw.githubusercontent.com/azureautomation/automation-packs/master/managed-vm/linked-templates/Windows2016Server.json) to deploy a new VM configured with some default values for network and disks. 36 | 37 | [MonitoringAgent template](https://raw.githubusercontent.com/azureautomation/automation-packs/master/managed-vm/linked-templates/monitoringagent.json) installs the Log Analytics extension on the VM. 38 | 39 | [DSCAgent](https://raw.githubusercontent.com/azureautomation/automation-packs/master/managed-vm/linked-templates/dscagent.json) installs the PowerShell DSC extension on the VM and configures it to pull the hybrid worker DSC configuration from the automation account. 40 | 41 | [Update deployment schedule](https://raw.githubusercontent.com/azureautomation/automation-packs/master/managed-vm/linked-templates/scheduleUpdateDeployment.json) Schedules an update deployment for every Sunday. 42 | -------------------------------------------------------------------------------- /managed-vm/azuredeploy.parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "workspaceName": { 6 | "value": "AA-DemoWorkspace" 7 | }, 8 | "accountName": { 9 | "value": "AA-DemoAccount" 10 | }, 11 | "accountWorkspaceRegion": { 12 | "value": "East US" 13 | }, 14 | "VMName": { 15 | "value": "AA-DemoVM" 16 | }, 17 | "username": { 18 | "value": "demouser" 19 | }, 20 | "password": { 21 | "value": "Strong4$Password" 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /managed-vm/dsc-configurations/HybridWorkerConfig.ps1: -------------------------------------------------------------------------------- 1 | Configuration HybridWorkerConfig 2 | { 3 | param 4 | ( 5 | # Name of the VM for the hybrid worker group 6 | [Parameter(Mandatory)] 7 | [ValidateNotNullOrEmpty()] 8 | [String]$VMName 9 | ) 10 | 11 | Import-DscResource -ModuleName HybridRunbookWorkerDsc -ModuleVersion 1.0.0.2 12 | 13 | $AutomationEndpoint = Get-AutomationVariable AutomationEndpoint 14 | $AutomationKey = Get-AutomationPSCredential AutomationCredential 15 | 16 | Node $VMName 17 | { 18 | # Wait 20 minutes for hybrid worker bits to be downloaded, else fail. 19 | WaitForHybridRegistrationModule ModuleWait 20 | { 21 | IsSingleInstance = 'Yes' 22 | RetryIntervalSec = 60 23 | RetryCount = 20 24 | } 25 | 26 | HybridRunbookWorker Onboard 27 | { 28 | Ensure = 'Present' 29 | Endpoint = $AutomationEndpoint 30 | Token = $AutomationKey 31 | GroupName = $VMName 32 | DependsOn = '[WaitForHybridRegistrationModule]ModuleWait' 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /managed-vm/linked-templates/Windows2016Server.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "username": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "Username for the Virtual Machine." 9 | } 10 | }, 11 | "password": { 12 | "type": "securestring", 13 | "metadata": { 14 | "description": "Password for the Virtual Machine." 15 | } 16 | }, 17 | "vmName": { 18 | "type": "string", 19 | "metadata": { 20 | "description": "Name of the vm, will be used as DNS Name for the Public IP used to access the Virtual Machine." 21 | } 22 | }, 23 | "vmSize": { 24 | "type": "string", 25 | "defaultValue": "Standard_DS1_v2", 26 | "metadata": { 27 | "description": "VM size" 28 | }, 29 | "allowedValues": [ 30 | "Standard_DS1_v2", 31 | "Standard_D2", 32 | "Standard_D3", 33 | "Standard_D4", 34 | "Standard_D11", 35 | "Standard_D12", 36 | "Standard_D13", 37 | "Standard_D14" 38 | ] 39 | }, 40 | "OSVersion": { 41 | "type": "string", 42 | "defaultValue": "2016-Datacenter", 43 | "metadata": { 44 | "description": "The VM version" 45 | } 46 | } 47 | }, 48 | "variables": { 49 | "virtualNetworkName": "vnet-demo", 50 | "nicName": "[toLower(parameters('vmName'))]", 51 | "publicIPAddressName": "[toLower(parameters('vmName'))]", 52 | "vnetAddressPrefix": "10.0.0.0/16", 53 | "subnetName": "demo", 54 | "subnetPrefix": "10.0.0.0/24", 55 | "publicIPAddressType": "Dynamic", 56 | "vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]", 57 | "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", 58 | "storageAccountType": "Standard_LRS", 59 | "imagePublisher": "MicrosoftWindowsServer", 60 | "imageOffer": "WindowsServer" 61 | }, 62 | "resources": [ 63 | { 64 | "apiVersion": "2017-06-01", 65 | "type": "Microsoft.Network/publicIPAddresses", 66 | "name": "[variables('publicIPAddressName')]", 67 | "location": "[resourceGroup().location]", 68 | "properties": { 69 | "publicIPAllocationMethod": "[variables('publicIPAddressType')]", 70 | "dnsSettings": { 71 | "domainNameLabel": "[toLower(parameters('vmName'))]" 72 | } 73 | } 74 | }, { 75 | "apiVersion": "2017-06-01", 76 | "type": "Microsoft.Network/virtualNetworks", 77 | "name": "[variables('virtualNetworkName')]", 78 | "location": "[resourceGroup().location]", 79 | "properties": { 80 | "addressSpace": { 81 | "addressPrefixes": [ 82 | "[variables('vnetAddressPrefix')]" 83 | ] 84 | }, 85 | "subnets": [{ 86 | "name": "[variables('subnetName')]", 87 | "properties": { 88 | "addressPrefix": "[variables('subnetPrefix')]" 89 | } 90 | }] 91 | } 92 | }, { 93 | "apiVersion": "2017-06-01", 94 | "type": "Microsoft.Network/networkInterfaces", 95 | "name": "[variables('nicName')]", 96 | "location": "[resourceGroup().location]", 97 | "dependsOn": [ 98 | "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]", 99 | "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" 100 | ], 101 | "properties": { 102 | "ipConfigurations": [{ 103 | "name": "ipconfig1", 104 | "properties": { 105 | "privateIPAllocationMethod": "Dynamic", 106 | "publicIPAddress": { 107 | "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]" 108 | }, 109 | "subnet": { 110 | "id": "[variables('subnetRef')]" 111 | } 112 | } 113 | }] 114 | } 115 | }, { 116 | "apiVersion": "2017-03-30", 117 | "type": "Microsoft.Compute/virtualMachines", 118 | "name": "[parameters('vmName')]", 119 | "location": "[resourceGroup().location]", 120 | "dependsOn": [ 121 | "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" 122 | ], 123 | "properties": { 124 | "hardwareProfile": { 125 | "vmSize": "[parameters('vmSize')]" 126 | }, 127 | "osProfile": { 128 | "computerName": "[parameters('vmName')]", 129 | "adminUsername": "[parameters('username')]", 130 | "adminPassword": "[parameters('password')]" 131 | }, 132 | "storageProfile": { 133 | "imageReference": { 134 | "publisher": "[variables('imagePublisher')]", 135 | "offer": "[variables('imageOffer')]", 136 | "sku": "[parameters('OSVersion')]", 137 | "version": "latest" 138 | }, 139 | "osDisk": { 140 | "createOption": "FromImage", 141 | "managedDisk": { 142 | "storageAccountType": "[variables('storageAccountType')]" 143 | } 144 | }, 145 | "dataDisks": [] 146 | }, 147 | "networkProfile": { 148 | "networkInterfaces": [{ 149 | "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]" 150 | }] 151 | } 152 | } 153 | } 154 | ] 155 | } 156 | -------------------------------------------------------------------------------- /managed-vm/linked-templates/dscagent.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01-preview#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "accountName": { 6 | "metadata": { 7 | "description": "The name of the Azure Automation account to deploy to." 8 | }, 9 | "type": "string" 10 | }, 11 | "accountResourceGroupName": { 12 | "type": "string", 13 | "metadata": { 14 | "description": "The name of the resource group for the Automation account." 15 | } 16 | }, 17 | "nodeConfigurationName": { 18 | "type": "string", 19 | "metadata": { 20 | "description": "The node configuration name to apply" 21 | } 22 | }, 23 | "vmName": { 24 | "type": "string", 25 | "metadata": { 26 | "description": "The name of the VM to enable the DSC extension on." 27 | } 28 | }, 29 | "vmRegion": { 30 | "type": "string", 31 | "metadata": { 32 | "description": "The name of the VM resource group" 33 | } 34 | } 35 | }, 36 | "resources": [ 37 | { 38 | "name": "[concat(parameters('vmName'),'/Microsoft.Powershell.DSC')]", 39 | "type": "Microsoft.Compute/virtualMachines/extensions", 40 | "location": "[parameters('vmRegion')]", 41 | "tags": { 42 | "AutomationAccountARMID": "[resourceId(parameters('accountResourceGroupName'), 'Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 43 | }, 44 | "apiVersion": "2015-06-15", 45 | "properties": { 46 | "publisher": "Microsoft.Powershell", 47 | "type": "DSC", 48 | "typeHandlerVersion": "2.74", 49 | "autoUpgradeMinorVersion": true, 50 | "settings": { 51 | "Properties": [ 52 | { 53 | "Name": "RegistrationKey", 54 | "Value": { 55 | "UserName": "PLACEHOLDER_DONOTUSE", 56 | "Password": "PrivateSettingsRef:registrationKeyPrivate" 57 | }, 58 | "TypeName": "System.Management.Automation.PSCredential" 59 | }, 60 | { 61 | "Name": "RegistrationUrl", 62 | "Value": "[reference(resourceId(parameters('accountResourceGroupName'), 'Microsoft.Automation/automationAccounts/', parameters('accountName')),'2015-01-01-preview').RegistrationUrl]", 63 | "TypeName": "System.String" 64 | }, 65 | { 66 | "Name": "ConfigurationMode", 67 | "Value": "ApplyAndAutoCorrect", 68 | "TypeName": "System.String" 69 | }, 70 | { 71 | "Name": "NodeConfigurationName", 72 | "Value": "[parameters('nodeConfigurationName')]", 73 | "TypeName": "System.String" 74 | }, 75 | { 76 | "Name": "ConfigurationModeFrequencyMins", 77 | "Value": "15", 78 | "TypeName": "System.Int32" 79 | }, 80 | { 81 | "Name": "RefreshFrequencyMins", 82 | "Value": "30", 83 | "TypeName": "System.Int32" 84 | }, 85 | { 86 | "Name": "RebootNodeIfNeeded", 87 | "Value": true, 88 | "TypeName": "System.Boolean" 89 | }, 90 | { 91 | "Name": "AllowModuleOverwrite", 92 | "Value": true, 93 | "TypeName": "System.Boolean" 94 | }, 95 | { 96 | "Name": "ActionAfterReboot", 97 | "Value": "ContinueConfiguration", 98 | "TypeName": "System.String" 99 | } 100 | ] 101 | }, 102 | "protectedSettings": { 103 | "Items": { 104 | "registrationKeyPrivate": "[listKeys(resourceId(parameters('accountResourceGroupName'), 'Microsoft.Automation/automationAccounts/', parameters('accountName')), '2015-01-01-preview').Keys[0].value]" 105 | } 106 | } 107 | } 108 | } 109 | ] 110 | } -------------------------------------------------------------------------------- /managed-vm/linked-templates/linkedworkspaceaccount.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Log Analytics workspace." 9 | } 10 | }, 11 | "accountResourceGroupName": { 12 | "type": "string", 13 | "metadata": { 14 | "description": "The name of the Log Analytics workspace." 15 | } 16 | }, 17 | "workspaceName": { 18 | "type": "string", 19 | "metadata": { 20 | "description": "The name of the Log Analytics workspace." 21 | } 22 | }, 23 | "workspaceRegion": { 24 | "type": "string", 25 | "metadata": { 26 | "description": "The region of the Log Analytics workspace." 27 | } 28 | } 29 | }, 30 | "resources": [ 31 | { 32 | "name": "[concat(parameters('workspaceName'), '/' , 'Automation')]", 33 | "type": "Microsoft.OperationalInsights/workspaces/linkedServices", 34 | "apiVersion": "2015-11-01-preview", 35 | "location": "[parameters('workspaceRegion')]", 36 | "properties": { 37 | "resourceId": "[resourceId(parameters('accountResourceGroupName'), 'Microsoft.Automation/automationAccounts/', parameters('accountName'))]" 38 | } 39 | } 40 | ] 41 | } 42 | -------------------------------------------------------------------------------- /managed-vm/linked-templates/monitoringagent.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schemas.microsoft.org/azure/deploymentTemplate?api-version=2015-01-01-preview#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "workspaceName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Log Analytics workspace." 9 | } 10 | }, 11 | "workspaceResourceGroupName": { 12 | "type": "string", 13 | "metadata": { 14 | "description": "The name of the resource group for the Log Analytics workspace." 15 | } 16 | }, 17 | "vmName": { 18 | "type": "string", 19 | "metadata": { 20 | "description": "The name of the VM to enable the monitoring extension on." 21 | } 22 | }, 23 | "vmResourceGroupName": { 24 | "type": "string", 25 | "metadata": { 26 | "description": "The name of the VM resource group" 27 | } 28 | } 29 | }, 30 | "resources": [ 31 | { 32 | "type": "Microsoft.Compute/virtualMachines/extensions", 33 | "apiVersion": "2017-03-30", 34 | "name": "[concat(parameters('vmName'),'/Microsoft.Monitoring')]", 35 | "location": "[resourceGroup().location]", 36 | "properties": { 37 | "publisher": "Microsoft.EnterpriseCloud.Monitoring", 38 | "type": "MicrosoftMonitoringAgent", 39 | "typeHandlerVersion": "1.0", 40 | "autoUpgradeMinorVersion": true, 41 | "settings": { 42 | "workspaceId": "[reference(resourceId(resourceGroup().name, 'Microsoft.OperationalInsights/workspaces/', parameters('workspaceName')), '2015-11-01-preview').customerId]", 43 | "azureResourceId": "[resourceId(parameters('vmResourceGroupname'), 'Microsoft.Compute/virtualMachines/', parameters('vmName'))]" 44 | }, 45 | "protectedSettings": { 46 | "workspaceKey": "[listKeys(resourceId(resourceGroup().name, 'Microsoft.OperationalInsights/workspaces/', parameters('workspaceName')), '2015-11-01-preview').primarySharedKey]" 47 | } 48 | } 49 | } 50 | ] 51 | } -------------------------------------------------------------------------------- /managed-vm/linked-templates/scheduleUpdateDeployment.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "accountName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the Automation account." 9 | } 10 | }, 11 | "accountRegion": { 12 | "type": "string", 13 | "metadata": { 14 | "description": "The region for the Automation account." 15 | } 16 | }, 17 | "VMResourceId": { 18 | "type": "string", 19 | "metadata": { 20 | "description": "The Azure resource id for the VM" 21 | } 22 | }, 23 | "softwareDeploymentName": { 24 | "type": "string", 25 | "metadata": { 26 | "description": "The name of the software update configuration" 27 | } 28 | } 29 | }, 30 | "resources": [ 31 | { 32 | "name": "[concat(parameters('accountName'), '/', parameters('softwareDeploymentName'))]", 33 | "type": "Microsoft.Automation/automationAccounts/softwareUpdateConfigurations", 34 | "apiVersion": "2017-05-15-preview", 35 | "location":"[parameters('accountRegion')]", 36 | "properties": { 37 | "updateConfiguration": { 38 | "operatingSystem": "Windows", 39 | "duration": "PT2H0M", 40 | "windows": { 41 | "excludedKbNumbers": [ 42 | "123456", 43 | "233421" 44 | ], 45 | "includedUpdateClassifications": "Critical,Security" 46 | }, 47 | "azureVirtualMachines": [ 48 | "[parameters('VMResourceId')]" 49 | ] 50 | }, 51 | "scheduleInfo": { 52 | "frequency": "Week", 53 | "startTime": "2020-10-19T12:22:57+00:00", 54 | "timeZone": "America/Los_Angeles", 55 | "interval": 1, 56 | "expiryTime": "2021-11-09T11:22:57+00:00", 57 | "advancedSchedule": { 58 | "weekDays": [ 59 | "Sunday" 60 | ] 61 | } 62 | } 63 | } 64 | } 65 | ] 66 | } -------------------------------------------------------------------------------- /managed-vm/linked-templates/solution.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "outputs": { 5 | "WorkspaceId": { 6 | "type": "string", 7 | "value": "[reference(resourceId(resourceGroup().name, 'Microsoft.OperationalInsights/workspaces/', parameters('workspaceName')), '2015-11-01-preview').customerId]" 8 | } 9 | }, 10 | "parameters": { 11 | "workspaceName": { 12 | "type": "string", 13 | "metadata": { 14 | "description": "The name of the Log Analytics workspace." 15 | } 16 | }, 17 | "workspaceRegion": { 18 | "type": "string", 19 | "metadata": { 20 | "description": "The region for the Log Analytics workspace." 21 | } 22 | }, 23 | "solutionName": { 24 | "type": "string", 25 | "metadata": { 26 | "description": "The name of the solution." 27 | } 28 | } 29 | }, 30 | "resources": [ 31 | { 32 | "apiVersion": "2017-03-15-preview", 33 | "location": "[parameters('workspaceRegion')]", 34 | "name": "[parameters('workspaceName')]", 35 | "type": "Microsoft.OperationalInsights/workspaces", 36 | "comments": "Azure Log Analytics workspace", 37 | "properties": { 38 | "sku": { 39 | "name": "Standalone" 40 | }, 41 | "features": { 42 | "legacy": 0, 43 | "searchVersion": 1 44 | } 45 | } 46 | }, 47 | { 48 | "apiVersion": "2015-11-01-preview", 49 | "type": "Microsoft.OperationsManagement/solutions", 50 | "location": "[parameters('workspaceRegion')]", 51 | "name": "[concat(parameters('solutionName'),'(', parameters('workspaceName'),')')]", 52 | "dependsOn": [ 53 | "[concat('Microsoft.OperationalInsights/workspaces/', parameters('workspaceName'))]" 54 | ], 55 | "id": "[resourceId('Microsoft.OperationsManagement/solutions', concat(parameters('solutionName'),'(', parameters('workspaceName'),')'))]", 56 | "properties": { 57 | "workspaceResourceId": "[resourceId('Microsoft.OperationalInsights/workspaces', parameters('workspaceName'))]" 58 | }, 59 | "plan": { 60 | "name": "[concat(parameters('solutionName'),'(', parameters('workspaceName'),')')]", 61 | "product": "[concat('OMSGallery/', parameters('solutionName'))]", 62 | "promotionCode": "", 63 | "publisher": "Microsoft" 64 | } 65 | } 66 | ] 67 | } --------------------------------------------------------------------------------