Add customscriptextension to Azure VMs with PowerShell commands

Source: Internet
Author: User

Azure VMs provide an administrative tool called Azure VM Extension. It implements some of the important features needed to manage virtual machines, such as resetting passwords, setting RDP parameters, and many other key features, and Azure VMs are adding new extension. By default, the Windows VM that you create installs the following basic VM Extension, including Iaasdiagnostics,vmaccess and BGInfo. Linux VMS, if the diagnostics feature is turned on, the linuxdiagnostic extension is installed by default.

Azure CLI gives you access to extension and related information that Azure provides in a region. You can use the following command:

Azure VM Extension-image List

This article describes the Customerscriptforlinux extension added to Azure Linux VMS through PowerShell commands.

1 Preparing Azure VMS

Azure VMS must be running when they add extension, and their Windows Azure Agent must already be installed. You can see if a waagent program is running with the following command:

[Email protected] waagent]# Ps-ef | grep "Waagent-daemon" | Grep-v grep

Root 935 1 0 08:29? 00:00:01 Python/usr/sbin/waagent-daemon

?

2 Preparing the PowerShell environment

Sign in to Azure China

$mycred = get-credential -username [email protected] -message Hello

Login-azurermaccount -environmentname Azurechinacloud -credential $mycred

?

Define resource Group, VM, and location variables

$RGName = ' Hwiscsi '

$VmName = ' hwiscsi02 '

$Location = ' China East '

?

Define extension related information

$ExtensionName = ' Customscriptforlinux '

$Publisher = ' Microsoft.ostcextensions '

$Version = ' 1.5 '

?

?

$PublicConf = ' {' Fileuris ': ' [] ', ' commandtoexecute ': ' ls '} '

$PrivateConf = ' {

"Storageaccountname": "hwiscsi984",

"Storageaccountkey": "sn4qtyoufybk+skwfplwbj0vpat64nf7wssiqmbo9hpfmtrss5iihsixkjr8s9x5pu1zblwirg3x3h7kbbq+iw=="

}‘

?

To execute the set-azurermvmextension command, install extension:

set-azurermvmextension -resourcegroupname $RGName -vmname $VmName -location $Location '

-name $ExtensionName -publisher $Publisher '

-extensiontype $ExtensionName -typehandlerversion $Version '

-settingstring $PublicConf -protectedsettingstring $PrivateConf

?

After execution, the screen output is as follows:

PS c:\users\hengz> set-azurermvmextension-resourcegroupname $RGName-vmname $VmName-location $Location '

-name $ExtensionName-publisher $Publisher '

-extensiontype $ExtensionName-typehandlerversion $Version '

-settingstring $PublicConf-protectedsettingstring $PrivateConf

?

RequestID Issuccessstatuscode StatusCode Reasonphrase

--------- ------------------- ---------- ------------

True OK okay

Successful execution.

3 Checking the information inside the VM

In the VM, you can view the related logs in/var/log/azure/microsoft.ostcextensions.customscriptforlinux/1.5.2.0.

?

Add customscriptextension to Azure VMs with PowerShell commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.