Share via


Machine Extensions - Create Or Update

The operation to create or update the extension.

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/extensions/{extensionName}?api-version=2025-01-13

URI Parameters

Name In Required Type Description
extensionName
path True

string

The name of the machine extension.

machineName
path True

string

minLength: 1
maxLength: 54
pattern: ^[a-zA-Z0-9-_\.]{1,54}$

The name of the machine where the extension should be created or updated.

resourceGroupName
path True

string

minLength: 1
maxLength: 90

The name of the resource group. The name is case insensitive.

subscriptionId
path True

string

minLength: 1

The ID of the target subscription.

api-version
query True

string

minLength: 1

The API version to use for this operation.

Request Body

Name Required Type Description
location True

string

The geo-location where the resource lives

properties

MachineExtensionProperties

Describes Machine Extension Properties.

tags

object

Resource tags.

Responses

Name Type Description
200 OK

MachineExtension

OK

202 Accepted

HTTP 202 (Accepted) if the operation was successfully started and will complete asynchronously.

Other Status Codes

ErrorResponse

Error response describing why the operation failed.

Security

azure_auth

Azure Active Directory OAuth2 Flow

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

Name Description
user_impersonation impersonate your user account

Examples

Create or Update a Machine Extension

Sample request

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/machines/myMachine/extensions/CustomScriptExtension?api-version=2025-01-13

{
  "location": "eastus2euap",
  "properties": {
    "publisher": "Microsoft.Compute",
    "typeHandlerVersion": "1.10",
    "type": "CustomScriptExtension",
    "settings": {
      "commandToExecute": "powershell.exe -c \"Get-Process | Where-Object { $_.CPU -gt 10000 }\""
    }
  }
}

Sample response

{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/Machines/myMachine/Extensions/CustomScriptExtension",
  "name": "CustomScriptExtension",
  "type": "Microsoft.HybridCompute/machines/extensions",
  "location": "eastus2euap",
  "properties": {
    "publisher": "Microsoft.Compute",
    "type": "string",
    "typeHandlerVersion": "1.10.3",
    "autoUpgradeMinorVersion": false,
    "settings": {
      "commandToExecute": "powershell.exe -c \"Get-Process | Where-Object { $_.CPU -gt 10000 }\""
    },
    "protectedSettings": {},
    "provisioningState": "Succeeded",
    "instanceView": {
      "name": "CustomScriptExtension",
      "type": "CustomScriptExtension",
      "typeHandlerVersion": "1.10.3",
      "status": {
        "code": "success",
        "level": "Information",
        "message": "Finished executing command, StdOut: , StdErr:",
        "time": "2020-08-08T20:42:10.999Z"
      }
    }
  }
}

Definitions

Name Description
createdByType

The type of identity that created the resource.

ErrorAdditionalInfo

The resource management error additional info.

ErrorDetail

The error detail.

ErrorResponse

Error response

HotpatchEnablementStatus

Status of hotpatch enablement or disablement.

MachineExtension

Describes a Machine Extension.

MachineExtensionInstanceView

Describes the Machine Extension Instance View.

MachineExtensionProperties

Describes the properties of a Machine Extension.

Status

Status of the hotpatch capability enrollment or disenrollment.

systemData

Metadata pertaining to creation and last modification of the resource.

createdByType

The type of identity that created the resource.

Value Description
User
Application
ManagedIdentity
Key

ErrorAdditionalInfo

The resource management error additional info.

Name Type Description
info

object

The additional info.

type

string

The additional info type.

ErrorDetail

The error detail.

Name Type Description
additionalInfo

ErrorAdditionalInfo[]

The error additional info.

code

string

The error code.

details

ErrorDetail[]

The error details.

message

string

The error message.

target

string

The error target.

ErrorResponse

Error response

Name Type Description
error

ErrorDetail

The error object.

HotpatchEnablementStatus

Status of hotpatch enablement or disablement.

Value Description
Unknown
PendingEvaluation
Disabled
ActionRequired
Enabled

MachineExtension

Describes a Machine Extension.

Name Type Description
id

string

Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}

location

string

The geo-location where the resource lives

name

string

The name of the resource

properties

MachineExtensionProperties

Describes Machine Extension Properties.

systemData

systemData

Azure Resource Manager metadata containing createdBy and modifiedBy information.

tags

object

Resource tags.

type

string

The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"

MachineExtensionInstanceView

Describes the Machine Extension Instance View.

Name Type Description
name

string

The machine extension name.

status

Status

Instance view status.

type

string

Specifies the type of the extension; an example is "CustomScriptExtension".

typeHandlerVersion

string

Specifies the version of the script handler.

MachineExtensionProperties

Describes the properties of a Machine Extension.

Name Type Description
autoUpgradeMinorVersion

boolean

Indicates whether the extension should use a newer minor version if one is available at deployment time. Once deployed, however, the extension will not upgrade minor versions unless redeployed, even with this property set to true.

enableAutomaticUpgrade

boolean

Indicates whether the extension should be automatically upgraded by the platform if there is a newer version available.

forceUpdateTag

string

How the extension handler should be forced to update even if the extension configuration has not changed.

instanceView

MachineExtensionInstanceView

The machine extension instance view.

protectedSettings

The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all.

provisioningState

string

The provisioning state, which only appears in the response.

publisher

string

The name of the extension handler publisher.

settings

Json formatted public settings for the extension.

type

string

Specifies the type of the extension; an example is "CustomScriptExtension".

typeHandlerVersion

string

Specifies the version of the script handler.

Status

Status of the hotpatch capability enrollment or disenrollment.

Name Type Description
error

ErrorDetail

The errors that were encountered during the hotpatch capability enrollment or disenrollment.

hotpatchEnablementStatus

HotpatchEnablementStatus

Indicates the current status of the hotpatch being enabled or disabled.

systemData

Metadata pertaining to creation and last modification of the resource.

Name Type Description
createdAt

string (date-time)

The timestamp of resource creation (UTC).

createdBy

string

The identity that created the resource.

createdByType

createdByType

The type of identity that created the resource.

lastModifiedAt

string (date-time)

The timestamp of resource last modification (UTC)

lastModifiedBy

string

The identity that last modified the resource.

lastModifiedByType

createdByType

The type of identity that last modified the resource.