Virtual Machine

The following example will deploy:

---
Setting:
# Useful settings, used by SQLBuild

  Azure:
    OSDiskDeleteOption: delete                        # delete, detach (D)
    NetworkInterfaceDeleteOption: delete              # delete, detach (D)
    
# -------------------------------------------------------------------------------------------------------------------

Connection:
# Replace the TenantId and SubscriptionID with your values
  - Name: az-jd-sub1
    Azure: 
      Environment: AzureCloud
      TenantId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
      Context:
        SubscriptionId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

# -------------------------------------------------------------------------------------------------------------------

azResourceGroup:
    # Mandatory
  - Name: rg-jdex-azvmwin
    ConnectionName: az-jd-sub1
    Location: westeurope
    # Optional
    Tag:
      CostCentre: '666'
      ProjectManager: 'Fred Smith'
    Lock:
      - Name: lock-rg
        Level: CanNotDelete                           # CanNotDelete, ReadOnly
        Notes: 'stop deletion'

# Create a public ip address to allow access via remote desktop
# This is just for test purposes, typically you should use a bastion
azPublicIP:
    # Mandatory
  - Name: pip-jdex-azvmwin
    ConnectionName: az-jd-sub1
    ResourceGroupName: rg-jdex-azvmwin
    Location: westeurope
    # Optional
    Sku: Standard                                     # Basic, Standard (Standard allows multiple zones)
    Zone:
      - 1
    Tag:
      CostCentre: '666'
      ProjectManager: 'Fred Smith'
    AllocationMethod: Static                          # Static, Dynamic

azVirtualNetwork:
    # Mandatory
  - Name: vnet-jdex-azvmwin
    ConnectionName: az-jd-sub1
    ResourceGroupName: rg-jdex-azvmwin
    Location: westeurope
    AddressPrefix: '10.0.0.0/24'
    # Optional
    Tag:
      CostCentre: '666'
      ProjectManager: 'Fred Smith'

azSubnet:
    # Mandatory
  - Name: snet-jdex-azvmwin
    ConnectionName: az-jd-sub1
    VNetName: vnet-jdex-azvmwin
    ResourceGroupName: rg-jdex-azvmwin
    AddressPrefix: '10.0.0.0/24'

# Create any Network Security Groups, typically these are only required if you need a special one
# just for the VM. Typically NSGs will exist and be applied to the subnet
azNetworkSecurityGroup:
    # Mandatory
  - Name: nsg-jdex-azvmwin
    ConnectionName: az-jd-sub1
    ResourceGroupName: rg-jdex-azvmwin
    Location: westeurope
    # Optional
    Tag:
      CostCentre: '666'
      ProjectManager: 'Fred Smith'
    Rule:
      - Name: Allow RDP
        Description: Allow inbound RDP access
        Access: allow                                   # allow, deny
        Protocol: tcp                                   # tcp, udp
        Direction: inbound                              # inbound, outbound
        Priority: "300"                                 # minimum 100
        SourceAddressPrefix: internet
        SourcePortRange: "*"
        DestinationAddressPrefix: "*"
        DestinationPortRange: "3389"

# Create any Network Interfaces and associate any public ips to the ipconfig
azNetworkInterface:
    # Mandatory
  - Name: nic-vm-jdex-azvmwin
    ConnectionName: az-jd-sub1
    ResourceGroupName: rg-jdex-azvmwin
    Location: westeurope
    VirtualNetwork:
      Name: vnet-jdex-azvmwin
      ResourceGroupName: rg-jdex-azvmwin
      SubnetName: snet-jdex-azvmwin
    # Optional
    NSGName: nsg-jdex-azvmwin
    Tag:
      CostCentre: '666'
      ProjectManager: 'Fred Smith'
    IPConfig:
      - Name: IPConfig1
        PublicIPName: pip-jdex-azvmwin

azVirtualMachine:
    # Mandatory
  - Name: vm-jdex-azvmwin
    ConnectionName: az-jd-sub1
    ResourceGroupName: rg-jdex-azvmwin
    Location: westeurope
    AdminUsername: justdeployadmin
    AdminPassword:
      Location: plaintext
      PlainText:
        Value: 'Mypassword1$'
    OSDiskSizeInGB: '127'
    # Optional
    Zone: 1
    PublisherName: MicrosoftWindowsServer
    Offer: WindowsServer
    Sku: '2016-Datacenter'
    Size: Standard_B2s                              # Default: Standard_D2s_v3
    LicenseType: None                               # None (D), Windows_Server
    StorageAccountName:                             # Used for boot diagnostics, diagnostics disabled if not supplied
    NetworkInterface:
      - Name: nic-vm-jdex-azvmwin
    Extension:
      - Name: networkWatcherAgent
        Publisher: 'Microsoft.Azure.NetworkWatcher'
        Type: NetworkWatcherAgentWindows
        TypeHandlerVersion: '1.4'
    Tag:
      CostCentre: '666'
      ProjectManager: 'Fred Smith'
    Lock:
      - Name: lock-vm
        Level: CanNotDelete                         # CanNotDelete, ReadOnly
        Notes: 'stop deletion'

Copy the above into a new .yml file and substitute in your tenant and subscription ids.

Validation

Execute the following powershell command to validate your resources. You will be prompted to authenticate to Azure with a suitable Microsoft account. Please ensure the account you choose has the relevant permissions to check your resources.

Confirm-JDResource -Verbose -Type All -DeploymentFile "<filename>.yml"

The above command will validate the resources in the yaml file. The -Type parameter allows the execution of just part of a yaml file that may contain other resource types.

Deployment

Execute the following powershell command to deploy your resources. You will be prompted to authenticate to Azure with a suitable Microsoft account. Please ensure the account you choose has the relevant permissions to check your resources.

Deploy-JDResource -Verbose -Type All -DeploymentFile "<filename>.yml"

The above command will create all resource types in the yaml file. The -Type parameter allows the execution of just part of a yaml file that may contain other resource types.