Expand description
Manages a Virtual Machine Run Command.
§Example Usage
resources:
exampleResourceGroup:
type: azure:core:ResourceGroup
name: example
properties:
name: example-resources
location: West Europe
exampleVirtualNetwork:
type: azure:network:VirtualNetwork
name: example
properties:
name: example-vnet
addressSpaces:
- 10.0.0.0/16
location: ${exampleResourceGroup.location}
resourceGroupName: ${exampleResourceGroup.name}
exampleSubnet:
type: azure:network:Subnet
name: example
properties:
name: internal
resourceGroupName: ${exampleResourceGroup.name}
virtualNetworkName: ${exampleVirtualNetwork.name}
addressPrefixes:
- 10.0.2.0/24
exampleNetworkInterface:
type: azure:network:NetworkInterface
name: example
properties:
name: example-nic
location: ${exampleResourceGroup.location}
resourceGroupName: ${exampleResourceGroup.name}
ipConfigurations:
- name: internal
subnetId: ${exampleSubnet.id}
privateIpAddressAllocation: Dynamic
exampleUserAssignedIdentity:
type: azure:authorization:UserAssignedIdentity
name: example
properties:
name: example-uai
resourceGroupName: ${exampleResourceGroup.name}
location: ${exampleResourceGroup.location}
exampleLinuxVirtualMachine:
type: azure:compute:LinuxVirtualMachine
name: example
properties:
name: example-VM
resourceGroupName: ${exampleResourceGroup.name}
location: ${exampleResourceGroup.location}
size: Standard_B2s
adminUsername: adminuser
adminPassword: P@$$w0rd1234!
disablePasswordAuthentication: false
networkInterfaceIds:
- ${exampleNetworkInterface.id}
osDisk:
caching: ReadWrite
storageAccountType: Premium_LRS
sourceImageReference:
publisher: Canonical
offer: 0001-com-ubuntu-server-jammy
sku: 22_04-lts
version: latest
identity:
type: SystemAssigned, UserAssigned
identityIds:
- ${exampleUserAssignedIdentity.id}
exampleAssignment:
type: azure:authorization:Assignment
name: example
properties:
scope: ${exampleAccount.id}
roleDefinitionName: Storage Blob Data Contributor
principalId: ${exampleUserAssignedIdentity.principalId}
exampleAccount:
type: azure:storage:Account
name: example
properties:
name: exampleaccount
resourceGroupName: ${exampleResourceGroup.name}
location: ${exampleResourceGroup.location}
accountTier: Standard
accountReplicationType: LRS
exampleContainer:
type: azure:storage:Container
name: example
properties:
name: example-sc
storageAccountName: ${exampleAccount.name}
containerAccessType: blob
example1:
type: azure:storage:Blob
properties:
name: script1
storageAccountName: ${exampleAccount.name}
storageContainerName: ${exampleContainer.name}
type: Block
sourceContent: echo 'hello world'
example2:
type: azure:storage:Blob
properties:
name: output
storageAccountName: ${exampleAccount.name}
storageContainerName: ${exampleContainer.name}
type: Append
example3:
type: azure:storage:Blob
properties:
name: error
storageAccountName: ${exampleAccount.name}
storageContainerName: ${exampleContainer.name}
type: Append
# basic example
exampleRunCommand:
type: azure:compute:RunCommand
name: example
properties:
name: example-vmrc
location: ${exampleResourceGroup.location}
virtualMachineId: ${exampleLinuxVirtualMachine.id}
source:
script: echo 'hello world'
# authorize to storage blob using user assigned identity
example2RunCommand:
type: azure:compute:RunCommand
name: example2
properties:
location: ${exampleResourceGroup.location}
name: example2-vmrc
virtualMachineId: ${exampleLinuxVirtualMachine.id}
outputBlobUri: ${example2.id}
errorBlobUri: ${example3.id}
runAsPassword: P@$$w0rd1234!
runAsUser: adminuser
source:
scriptUri: ${example1.id}
scriptUriManagedIdentity:
clientId: ${exampleUserAssignedIdentity.clientId}
errorBlobManagedIdentity:
clientId: ${exampleUserAssignedIdentity.clientId}
outputBlobManagedIdentity:
clientId: ${exampleUserAssignedIdentity.clientId}
parameters:
- name: examplev1
value: val1
protectedParameters:
- name: examplev2
value: val2
tags:
environment: terraform-examples
some_key: some-value
options:
dependsOn:
- ${exampleAssignment}
# authorize to storage blob using SAS token
example3RunCommand:
type: azure:compute:RunCommand
name: example3
properties:
location: ${exampleResourceGroup.location}
name: example3-vmrc
virtualMachineId: ${exampleLinuxVirtualMachine.id}
runAsPassword: P@$$w0rd1234!
runAsUser: adminuser
errorBlobUri: ${example3.id}${example.sas}
outputBlobUri: ${example2.id}${example.sas}
source:
scriptUri: ${example1.id}${example.sas}
parameters:
- name: example-vm1
value: val1
tags:
environment: terraform-example-s
some_key: some-value
variables:
example:
fn::invoke:
function: azure:storage:getAccountSAS
arguments:
connectionString: ${exampleAccount.primaryConnectionString}
httpsOnly: true
signedVersion: 2019-10-10
start: 2023-04-01T00:00:00Z
expiry: 2024-04-01T00:00:00Z
resourceTypes:
service: false
container: false
object: true
services:
blob: true
queue: false
table: false
file: false
permissions:
read: true
write: true
delete: false
list: false
add: true
create: true
update: false
process: false
tag: false
filter: false
§Import
An existing Virtual Machine Run Command can be imported into Pulumi using the resource id
, e.g.
$ pulumi import azure:compute/runCommand:RunCommand example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/virtualMachines/vm1/runCommands/rc1
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