Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Virtual machine extensions

  • Windows VMs have extensions which give your VM additional capabilities through post deployment configuration and automated tasks.

  • These common tasks can be accomplished using extensions:

    • Run custom scripts: The Custom Script Extension helps you configure workloads on the VM by running your script when the VM is provisioned.

      Deploy and manage configurations: The PowerShell Desired State Configuration (DSC) Extension helps you set up DSC on a VM to manage configurations and environments.

      Collect diagnostics data: The Azure Diagnostics Extension helps you configure the VM to collect diagnostics data that can be used to monitor the health of your application.

  • Script files can be downloaded from Azure storage or GitHub, or provided from your PC when run from the Azure portal.

...

  • Run scripts in your Windows VM

  • The Custom Script Extension is primarily used for post deployment configuration and software installation.

    • Download and run scripts in Azure virtual machines.

  • The Run Command feature enables virtual machine and application management and troubleshooting using scripts, and is available even when the machine is not reachable, for example if the guest firewall doesn't have the RDP or SSH port open

  • They can help you quickly diagnose and remediate VM access and network issues and get the VM back to a good state.

  • Run scripts in your Windows VM by using action Run Commands

  • Run Command can run scripts on your virtual machines remotely by using the VM agent.

  • This capability is useful in all scenarios where you want to run a script within a virtual machine.

    • It's one of the only ways to troubleshoot and remediate a virtual machine that doesn't have the RDP or SSH port open because of improper network or administrative user configuration.

    • Output is limited to the last 4,096 bytes.

    • The minimum time to run a script is about 20 seconds.

    • Scripts run as System on Windows.

    • One script at a time can run.

    • Scripts that prompt for information (interactive mode) are not supported.

    • You can't cancel a running script.

    • The maximum time a script can run is 90 minutes. After that, it will time out.

  • To function correctly, Run Command requires connectivity (port 443) to Azure public IP addresses.

  • If the extension doesn't have access to these endpoints, the scripts might run successfully but not return the results.

  • az vm run-command create

Code Block
az vm run-command create --name
                         --resource-group
                         --vm-name
                         [--async-execution {false, true}]
                         [--command-id]
                         [--error-blob-uri]
                         [--location]
                         [--no-wait]
                         [--output-blob-uri]
                         [--parameters]
                         [--protected-parameters]
                         [--run-as-password]
                         [--run-as-user]
                         [--script]
                         [--script-uri]
                         [--subscription]
                         [--tags]
                         [--timeout-in-seconds]

SetRDPPort

Sets the default or user-specified port number for Remote Desktop connections. Enables firewall rules for inbound access to the port.

...

Hybrid Runbook Worker

  • Hybrid Runbook Worker

  • Runbooks in Azure Automation might not have access to resources in other clouds or in your on-premises environment because they run on the Azure cloud platform.

  • You can use the Hybrid Runbook Worker feature of Azure Automation to run runbooks directly on the machine hosting the role and against resources in the environment to manage those local resources.

The Hybrid Runbook Worker provides general machine, application, and environment management with user's custom scripts stored in an Automation account.

  • Run scripts in Azure and non-Azure machines.

  • Can be run using Azure portal, Azure CLI, REST API, PowerShell, webhook.

  • Each machine can host one Hybrid Runbook Worker reporting to one Automation account; you can't register the hybrid worker across multiple Automation accounts.

  • A hybrid worker can only listen for jobs from a single Automation account.

Image Added

Serial console

The Serial console provides direct access to a VM, similar to having a keyboard connected to the VM.

  • Run commands in Azure virtual machines.

  • Can be run using a text-based console to the machine in the Azure portal.

  • Login to the machine with a local user account.

  • Useful when access to the virtual machine is needed regardless of the machine's network or operating system state.


...

Assign Identity with Azurer PowerShell

Code Block
$vm = Get-AzVM -ResourceGroupName myResourceGroup -Name myVM
Update-AzVM -ResourceGroupName myResourceGroup -VM $vm -IdentityType SystemAssigned