Expand description
Manages a Virtual Machine Extension to provide post deployment configuration and run automated tasks.
NOTE: Custom Script Extensions for Linux & Windows require that the
commandToExecute
returns a0
exit code to be classified as successfully deployed. You can achieve this by appendingexit 0
to the end of yourcommandToExecute
.
NOTE: Custom Script Extensions require that the Azure Virtual Machine Guest Agent is running on the Virtual Machine.
§Example Usage
resources:
example:
type: azure:core:ResourceGroup
properties:
name: example-resources
location: West Europe
exampleVirtualNetwork:
type: azure:network:VirtualNetwork
name: example
properties:
name: acctvn
addressSpaces:
- 10.0.0.0/16
location: ${example.location}
resourceGroupName: ${example.name}
exampleSubnet:
type: azure:network:Subnet
name: example
properties:
name: acctsub
resourceGroupName: ${example.name}
virtualNetworkName: ${exampleVirtualNetwork.name}
addressPrefixes:
- 10.0.2.0/24
exampleNetworkInterface:
type: azure:network:NetworkInterface
name: example
properties:
name: acctni
location: ${example.location}
resourceGroupName: ${example.name}
ipConfigurations:
- name: testconfiguration1
subnetId: ${exampleSubnet.id}
privateIpAddressAllocation: Dynamic
exampleLinuxVirtualMachine:
type: azure:compute:LinuxVirtualMachine
name: example
properties:
name: example-machine
resourceGroupName: ${example.name}
location: ${example.location}
size: Standard_F2
adminUsername: adminuser
networkInterfaceIds:
- ${exampleNetworkInterface.id}
adminSshKeys:
- username: adminuser
publicKey:
fn::invoke:
function: std:file
arguments:
input: ~/.ssh/id_rsa.pub
return: result
osDisk:
caching: ReadWrite
storageAccountType: Standard_LRS
sourceImageReference:
publisher: Canonical
offer: 0001-com-ubuntu-server-jammy
sku: 22_04-lts
version: latest
exampleExtension:
type: azure:compute:Extension
name: example
properties:
name: hostname
virtualMachineId: ${exampleLinuxVirtualMachine.id}
publisher: Microsoft.Azure.Extensions
type: CustomScript
typeHandlerVersion: '2.0'
settings: |2
{
"commandToExecute": "hostname && uptime"
}
tags:
environment: Production
§Import
Virtual Machine Extensions can be imported using the resource id
, e.g.
$ pulumi import azure:compute/extension:Extension example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/virtualMachines/myVM/extensions/extensionName
Structs§
- Use builder syntax to set the inputs and finish with
build_struct()
.
Functions§
- Registers a new resource with the given unique name and arguments