Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Azure Resource Manager from A to Z

Azure Resource Manager from A to Z

David Pazdera

September 03, 2022
Tweet

More Decks by David Pazdera

Other Decks in Technology

Transcript

  1. Jason is your best friend JSON is your best friend

    https://en.wikipedia.org/wiki/JSON
  2. SQL - A Website Virtual Machines SQL-A Website [SQL CONFIG]

    VM (2x) DEPENDS ON SQL DEPENDS ON SQL SQL CONFIG
  3. • $schema: Location of the JSON schema file that describes

    the version of the template language. • contentVersion: Version of the template (such as 1.0.0.0). Used for versioning. • parameters: Values that are provided when deployment is executed to customize resource deployment. • variables: Values that are used as JSON fragments in the template to simplify template language expressions. • resources: Types of services deployed. Minimum of 1. • output: Values that are returned after deployment. Note: Yellow sections are mandatory.
  4. • Parameter name and type are required • Allowed JSON

    types: string, secureString, int, bool, object, secureObject, array
  5. Icon Extension Name Description Azure Account Provides a single Azure

    sign-in and subscription filtering. Makes Azure’s Cloud Shell available in VS Code’s integrated terminal. Azure Resource Manager Tools Provides language support for ARM deployment templates and template language expressions. Azure Tools for Visual Studio Code Convenient features for devs: template repository search, deployment within VS Code, template exports, etc. Azure CLI Tools Tools for developing and running commands of the Azure CLI. Gives IntelliSense and snippets for .azcli scrapbooks. Azure Extension Pack A collection of extensions for working with Azure resources in VS Code, e.g. App Services, Functions, Microservices (docker tools, AKS, ACR), Storage, Databases, VSTS, IoT Azure ARM Template Helper VS-like tree-view for ARM templates including a few helpers (Preview)
  6. JSON apiVersion 2016-01-01 Microsoft.Storage/storageAccounts mystorageaccount "location": "westus", "sku": { "name":

    "Standard_LRS" }, "kind": "Storage" HTTP Microsoft.Storage/storageAccounts/mystorageaccount api-version=2016-01-01 "location": "westus", "properties": { } "sku": { "name": "Standard_LRS" }, "kind": "Storage"
  7. Deployment “engines” Template storage Runbook (PSH script) Workflow (ARM connector)

    Your code (Azure client libraries) Build definition (ARM deployment) Azure Resource Manager REST API Desktop
  8. BUILT-IN ROLE ACTIONS NOT ACTIONS Owner (allow all actions) *

    Contributor (allow all actions except writing or deleting role assignments) * Microsoft.Authorization/*/Write, Microsoft.Authorization/*/Delete Reader (allow all read actions) */Read
  9. Role Definitions • describes the set of permissions (e.g. read

    actions) • can be used in multiple assignments across your subscriptions Role Assignments • associate role definitions with an identity (e.g. user/group) at a scope (e.g. resource group) • always inherited – subscription assignments apply to all resources
  10. RBAC - Granular Scopes /subscriptions/{id}/resourceGroups/{name}/providers/…/sites/{site} subscription level – grants permissions

    to all resources in the sub resource group level – grants permissions to all resources in the group resource level – grants permissions to the specific resource
  11. Reynholm Ind. – IT Security Policy for Azure • Least

    privilege for all users – limit number of subscription Owners • Secure production resources from accidental deletion and limiting who could remove locks • Apply mandatory tags for better resource and cost management (Environment, CostPool) • Production data stores cannot be deployed outside of EU. Compliance with this policy shall not be enforced first but it must be checked regularly.
  12. ▪ Use parameters for resource names that need to be

    set on the fly ▪ Use variables or hard-coded resource names otherwise ▪ camelCasing is recommended ▪ use “metadata” to add descriptions Consistency is key
  13. • TemplateLink must be visible to Resource Manager: http or

    https uri • Can use variables to create multiple URLs from base name
  14. { "apiVersion": "2015-05-01-preview", "type": "Microsoft.Compute/virtualMachines", "name": "[concat(parameters('vmNamePrefix'), copyindex())]", "location": "[parameters('location')]",

    "copy": { "name": "virtualMachineLoop", "count": "[parameters('numberOfInstances')]" }, "dependsOn": [ "[concat('Microsoft.Network/networkInterfaces/', 'nic', copyindex())]" ], "properties": { "hardwareProfile": { "vmSize": "[parameters('vmSize')]" }, "osProfile": { "computername": "[concat('vm', copyIndex())]", "adminUsername": "[parameters('adminUsername')]", "adminPassword": "[parameters('adminPassword')]" }, "storageProfile": { "osDisk": { "name": "[concat(parameters('vmNamePrefix'),'-osDisk',copyindex())]", "osType": "[parameters('osType')]", "caching": "ReadWrite", "image": { "uri": "[variables('userImageName')]" }, "vhd": { "uri": "[concat(variables('osDiskVhdContainer'),parameters('vmNamePrefix'),copyindex(),'osDisk.vh d')]" } } },
  15. Name Value Description region String from a constrained list of

    Azure regions The location where the resources will be deployed. storageAccountNamePrefix String Unique DNS name for the Storage Account where the VM’s disks will be placed domainName String Domain name of the publicly accessible jumpbox VM in the format: {domainName}.{location}.cloudapp.co m For example: mydomainname.westus.cloudapp.azure. com adminUsername String Username for the VMs adminPassword String Password for the VMs tshirtSize String from a constrained list of offered t-shirt sizes The named scale unit size to provision. For example, “Small”, “Medium”, “Large” virtualNetworkName String Name of the virtual network that the consumer wants to use. jumpbox String from a constrained list (enabled/disabled) Parameter that identifies whether to enable a jumpbox for the environment. Values: “enabled”, “disabled”
  16. • No control flow logic built into ARM template language

    • An approach with parameters, variables, and linked templates – Use provides parameter value that provides context, e.g. tshirtSize parameter is passed in as a value of ‘small’ – Using concat and a pre-defined variable, a new variable value is created which points to the specific , e.g. ‘tshirtSize-small.json’ – Template linking is incorporated into the template and uses this new value to identify which template to deploy. – Common examples are “tshirt sizes” and optional features for a deployment, e.g. “enableJumpbox” Control Flow
  17. Best practices - security • Use Azure Key Vault with

    Resource Manager to orchestrate and store VM secrets and certificates • Separate keys from deployments – Template 1: Creation of vaults (which will contain the key material) – Template 2: Deployment of the VMs (with URI references to the keys contained in the vaults) • Use AD service principals for cross-subscription interactions • Use Network Security Groups to control traffic to VMs in a Virtual Network
  18. PDF