infrastructure as code - meetupfiles.meetup.com/20381497/infrastructureascode.pdf · infrastructure...

19

Upload: others

Post on 30-May-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Infrastructure as Code - Meetupfiles.meetup.com/20381497/InfrastructureAsCode.pdf · Infrastructure as Code Author: Scott Semyan Created Date: 12/13/2016 9:59:19 PM
Page 2: Infrastructure as Code - Meetupfiles.meetup.com/20381497/InfrastructureAsCode.pdf · Infrastructure as Code Author: Scott Semyan Created Date: 12/13/2016 9:59:19 PM
Page 3: Infrastructure as Code - Meetupfiles.meetup.com/20381497/InfrastructureAsCode.pdf · Infrastructure as Code Author: Scott Semyan Created Date: 12/13/2016 9:59:19 PM

https://aka.ms/seattleazure

https://aka.ms/seattlebizspark

Page 4: Infrastructure as Code - Meetupfiles.meetup.com/20381497/InfrastructureAsCode.pdf · Infrastructure as Code Author: Scott Semyan Created Date: 12/13/2016 9:59:19 PM
Page 5: Infrastructure as Code - Meetupfiles.meetup.com/20381497/InfrastructureAsCode.pdf · Infrastructure as Code Author: Scott Semyan Created Date: 12/13/2016 9:59:19 PM
Page 7: Infrastructure as Code - Meetupfiles.meetup.com/20381497/InfrastructureAsCode.pdf · Infrastructure as Code Author: Scott Semyan Created Date: 12/13/2016 9:59:19 PM
Page 8: Infrastructure as Code - Meetupfiles.meetup.com/20381497/InfrastructureAsCode.pdf · Infrastructure as Code Author: Scott Semyan Created Date: 12/13/2016 9:59:19 PM
Page 9: Infrastructure as Code - Meetupfiles.meetup.com/20381497/InfrastructureAsCode.pdf · Infrastructure as Code Author: Scott Semyan Created Date: 12/13/2016 9:59:19 PM
Page 11: Infrastructure as Code - Meetupfiles.meetup.com/20381497/InfrastructureAsCode.pdf · Infrastructure as Code Author: Scott Semyan Created Date: 12/13/2016 9:59:19 PM

$ErrorActionPreference = "Stop"

# sign in and select subscriptionLogin-AzureRmAccount -SubscriptionID $subscriptionId;

# load the parameters so we can use them in the script$params = ConvertFrom-Json -InputObject (Gc $parametersFilePath -Raw)

$resourceGroup = Get-AzureRmResourceGroup -Name $resourceGroupName -ErrorAction SilentlyContinueif(!$resourceGroup){

Write-Host "Creating resource group '$resourceGroupName' in location $($params.parameters.location.value)";New-AzureRmResourceGroup -Name $resourceGroupName -Location $params.parameters.location.value -Verbose

}

# Test$testResult = Test-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile $templateFilePath -TemplateParameterFile$parametersFilePath -ErrorAction Stop;if ($testResult.Count -gt 0){

write-host ($testResult | ConvertTo-Json -Depth 5 | Out-String);write-output "Errors in template - Aborting";exit;

}

# Start the deploymentNew-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile $templateFilePath -TemplateParameterFile $parametersFilePath -Verbose;

Page 12: Infrastructure as Code - Meetupfiles.meetup.com/20381497/InfrastructureAsCode.pdf · Infrastructure as Code Author: Scott Semyan Created Date: 12/13/2016 9:59:19 PM

{"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#","contentVersion": "1.0.0.0","parameters": {

"location": {"value": "centralus"

},"virtualMachineName": {

"value": "myvm"},"virtualMachineSize": {

"value": "Standard_DS1_v2"},"adminUsername": {

"value": "myuser"},"adminPublicKey": {

"reference": {"keyVault": {

"id": "/subscriptions/{subid}/resourceGroups/{rgid}/providers/Microsoft.KeyVault/vaults/{vaultname}"},"secretName": "VMSSSHKey"

} }

}}

Page 13: Infrastructure as Code - Meetupfiles.meetup.com/20381497/InfrastructureAsCode.pdf · Infrastructure as Code Author: Scott Semyan Created Date: 12/13/2016 9:59:19 PM
Page 14: Infrastructure as Code - Meetupfiles.meetup.com/20381497/InfrastructureAsCode.pdf · Infrastructure as Code Author: Scott Semyan Created Date: 12/13/2016 9:59:19 PM
Page 15: Infrastructure as Code - Meetupfiles.meetup.com/20381497/InfrastructureAsCode.pdf · Infrastructure as Code Author: Scott Semyan Created Date: 12/13/2016 9:59:19 PM
Page 16: Infrastructure as Code - Meetupfiles.meetup.com/20381497/InfrastructureAsCode.pdf · Infrastructure as Code Author: Scott Semyan Created Date: 12/13/2016 9:59:19 PM
Page 17: Infrastructure as Code - Meetupfiles.meetup.com/20381497/InfrastructureAsCode.pdf · Infrastructure as Code Author: Scott Semyan Created Date: 12/13/2016 9:59:19 PM
Page 18: Infrastructure as Code - Meetupfiles.meetup.com/20381497/InfrastructureAsCode.pdf · Infrastructure as Code Author: Scott Semyan Created Date: 12/13/2016 9:59:19 PM
Page 19: Infrastructure as Code - Meetupfiles.meetup.com/20381497/InfrastructureAsCode.pdf · Infrastructure as Code Author: Scott Semyan Created Date: 12/13/2016 9:59:19 PM

https://blogs.msdn.microsoft.com/cloud_solution_architect/2016/11/11/creating-azure-resources-with-arm-templates-step-by-step/

[email protected]

https://aka.ms/seattleazure