Created
April 4, 2016 20:11
-
-
Save kkamegawa/bfb437684d56f05bfa99308a6ca4f9ad to your computer and use it in GitHub Desktop.
Azure DevTest Labs Deploy sample script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires -Version 3.0 | |
#Requires -Module AzureRM.Resources | |
#Requires -Module Azure.Storage | |
# deploy bin folder | |
#..\scripts\Deploy-AzureResourceGroup.ps1 -ResourceGroupName 'psugdemoRG770838' -ResourceGroupLocation 'japanwest' -TemplateFile '..\templates\windowsvirtualmachine.json' -TemplateParametersFile '..\templates\windowsvirtualmachine.parameters.json' | |
Param( | |
[string] [Parameter(Mandatory=$true)] $ResourceGroupLocation, | |
[string] $ResourceGroupName = 'psugdemoRG770838', | |
[string] $TemplateFile = '..\Templates\WindowsVirtualMachine.json', | |
[string] $TemplateParametersFile = '..\Templates\WindowsVirtualMachine.parameters.json' | |
) | |
Import-Module Azure -ErrorAction SilentlyContinue | |
try { | |
[Microsoft.Azure.Common.Authentication.AzureSession]::ClientFactory.AddUserAgent("VSAzureTools-$UI$($host.name)".replace(" ","_"), "2.8") | |
} catch { } | |
Set-StrictMode -Version 3 | |
$OptionalParameters = New-Object -TypeName Hashtable | |
$TemplateFile = [System.IO.Path]::Combine($PSScriptRoot, $TemplateFile) | |
$TemplateParametersFile = [System.IO.Path]::Combine($PSScriptRoot, $TemplateParametersFile) | |
# Create or update the resource group using the specified template file and template parameters file | |
New-AzureRmResourceGroupDeployment -Name ((Get-ChildItem $TemplateFile).BaseName + '-' + ((Get-Date).ToUniversalTime()).ToString('MMdd-HHmm')) ` | |
-ResourceGroupName $ResourceGroupName ` | |
-TemplateFile $TemplateFile ` | |
-TemplateParameterFile $TemplateParametersFile ` | |
@OptionalParameters ` | |
-Force -Verbose -nameFromTemplate 'psugdemo0409' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"name": { | |
"type": "string", | |
"metadata": { | |
"description": "Computername for the Virtual Machine." | |
} | |
}, | |
"userName": { | |
"type": "string", | |
"minLength": 1, | |
"metadata": { | |
"description": "Username for the Virtual Machine." | |
} | |
}, | |
"password": { | |
"type": "securestring", | |
"metadata": { | |
"description": "Password for the Virtual Machine." | |
} | |
}, | |
"size": { | |
"type": "string", | |
"defaultValue": "Standard_A2" | |
}, | |
"labName": { | |
"type": "string", | |
"metadata": { | |
"description": "Deploy to Lab Name" | |
} | |
} | |
}, | |
"resources": [ | |
{ | |
"apiVersion": "2015-05-21-preview", | |
"type": "Microsoft.DevTestLab/labs/virtualMachines", | |
"name": "[concat(parameters('labName'), '/', parameters('name'))]", | |
"location": "[resourceGroup().location]", | |
"tags": { | |
"displayName": "VirtualMachine" | |
}, | |
"properties": { | |
"labVirtualNetworkId": "[concat(resourceGroup().id, '/providers/Microsoft.DevTestLab/labs/', parameters('labName'), '/virtualnetworks/dtlpsugdemo')]", | |
"notes": "Windows Server 2012 R2 Datacenter", | |
"galleryImageReference": { | |
"offer": "WindowsServer", | |
"publisher": "MicrosoftWindowsServer", | |
"sku": "2012-R2-Datacenter", | |
"osType": "Windows", | |
"version": "latest" | |
}, | |
"size": "[parameters('size')]", | |
"userName": "[parameters('userName')]", | |
"password": "[parameters('password')]", | |
"isAuthenticationWithSshKey": false, | |
"artifacts": [ | |
{ | |
"artifactId": "[concat(resourceGroup().id, '/providers/Microsoft.DevTestLab/labs/', parameters('labName'), '/artifactSources/Public Repo/artifacts/windows-azurepowershell')]" | |
}, | |
{ | |
"artifactId": "[concat(resourceGroup().id, '/providers/Microsoft.DevTestLab/labs/', parameters('labName'), '/artifactSources/Public Repo/artifacts/windows-git')]" | |
} | |
], | |
"labSubnetName": "DtlpsugdemoSubnet", | |
"disallowPublicIpAddress": false, | |
"osType": "" | |
} | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"name": { "value": "psugdev001" }, | |
"userName": { "value": "admin" }, | |
"password": { "value": null }, | |
"labName": { "value": "psugdemo" } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment