Eksportuj (0) Drukuj
Rozwiń wszystko
EN
Ta zawartość nie jest dostępna w wymaganym języku. Wersja w języku angielskim znajduje się tutaj.

Create Virtual Machine Deployment

Updated: October 22, 2014

The Create Virtual Machine Deployment operation creates a deployment and then creates a Virtual Machine in the deployment based on the specified configuration.

The Create Virtual Machine Deployment request may be specified as follows. Replace <subscription-id> with the subscription ID and <cloudservice-name> with the name of the cloud service.

 

Method Request URI

POST

https://management.core.windows.net/<subscription-id>/services/hostedservices/<cloudservice-name>/deployments

You must make sure that the request that is made to the management service is secure. For additional details, see Authenticating Service Management Requests.

The following table describes the request headers.

 

Request Header Description

x-ms-version

Required. Specifies the version of the operation to use for this request. This header should be set to 2012-03-01 or higher. For more information about versioning headers, see Service Management Versioning.

The format of the request body is as follows:


<Deployment xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <Name>name-of-deployment</Name>
  <DeploymentSlot>deployment-environment</DeploymentSlot>
  <Label>identifier-of-deployment</Label>      
  <RoleList>
    <Role>
      <RoleName>name-of-the-virtual-machine</RoleName>
      <RoleType>PersistentVMRole</RoleType>
      <ConfigurationSets>
        <ConfigurationSet i:type="WindowsProvisioningConfigurationSet">
          <ConfigurationSetType>WindowsProvisioningConfiguration</ConfigurationSetType>
          <ComputerName>name-of-computer</ComputerName>
          <AdminPassword>administrator-password</AdminPassword>
          <EnableAutomaticUpdates>enable-updates</EnableAutomaticUpdates>  
          <TimeZone>time-zone</TimeZone>
          <DomainJoin>
            <Credentials>
              <Domain>domain-to-join</Domain>
              <Username>user-name-in-the-domain</Username>
              <Password>password-for-the-user-name</Password>
            </Credentials>
            <JoinDomain>domain-to-join</JoinDomain>
            <MachineObjectOU>distinguished-name-of-the-ou</MachineObjectOU>
          </DomainJoin>
          <StoredCertificateSettings>
            <CertificateSetting>
              <StoreLocation>LocalMachine</StoreLocation>
              <StoreName>name-of-store-on-the-machine</StoreName>
              <Thumbprint>certificate-thumbprint</Thumbprint>
            </CertificateSetting>
          </StoredCertificateSettings>
          <WinRM>
            <Listeners>
              <Listener>
                <Protocol>listener-protocol</Protocol>
              </Listener>
              <Listener>
                <CertificateThumbprint>certificate-thumbprint</CertificateThumbprint>
                <Protocol>listener-protocol</Protocol>
              </Listener>
            </Listeners>
          </WinRM>
          <AdminUsername>name-of-administrator-account</AdminUsername>
          <CustomData>base-64-encoded-data</CustomData>
          <AdditionalUnattendContent>
            <Passes>
              <UnattendPass>
                <PassName>name-of-pass</PassName>
                <Components>
                  <UnattendComponent>
                    <ComponentName>name-of-component</ComponentName>
                    <ComponentSettings>
                      <ComponentSetting>
                        <SettingName>name-of-setting</SettingName>
                        <Content>base-64-encoded-XML-content</Content>
                      </ComponentSetting>
                    </ComponentSettings>
                  </UnattendComponent>
                </Components>
              </UnattendPass>
            </Passes>
          </AdditionalUnattendContent>
        </ConfigurationSet>
        <ConfigurationSet i:type="LinuxProvisioningConfigurationSet">
          <ConfigurationSetType>LinuxProvisioningConfiguration</ConfigurationSetType>
          <HostName>host-name-for-the-virtual-machine</HostName>
          <UserName>new-user-name</UserName> 
          <UserPassword>password-for-the-new-user</UserPassword> 
          <DisableSshPasswordAuthentication>password-authentication</DisableSshPasswordAuthentication>           
          <SSH>
            <PublicKeys>
              <PublicKey>
                <FingerPrint>certificate-fingerprint</FingerPrint>
                <Path>SSH-public-key-storage-location</Path>     
              </PublicKey>
            </PublicKeys>
            <KeyPairs>
              <KeyPair>
                <FingerPrint>certificate-fingerprint</FinguerPrint>
                <Path>SSH-public-key-storage-location</Path>
              </KeyPair>
            </KeyPairs>
          </SSH>
          <CustomData>base-64-encoded-data</CustomData>
        </ConfigurationSet>        
        <ConfigurationSet> 
          <ConfigurationSetType>NetworkConfiguration</ConfigurationSetType>
          <InputEndpoints>
            <InputEndpoint>
              <LoadBalancedEndpointSetName>name-of-load-balanced-set</LoadBalancedEndpointSetName>
              <LocalPort>local-port-number</LocalPort>
              <Name>name-of-endpoint</Name>
              <Port>external-port-number</Port>
              <LoadBalancerProbe>
                <Path>path-of-probe</Path>
                <Port>port-assigned-to-probe</Port>
                <Protocol>probe-protocol</Protocol>
                <IntervalInSeconds>interval-of-probe</IntervalInSeconds>
                <TimeoutInSeconds>timeout-for-probe</TimeoutInSeconds>
              </LoadBalancerProbe>          
              <Protocol>endpoint-protocol</Protocol>                 
              <EnableDirectServerReturn>enable-direct-server-return</EnableDirectServerReturn>       
              <EndpointACL>
                <Rules>
                  <Rule>
                    <Order>priority-of-the-rule</Order>
                    <Action>permit-rule</Action>
                    <RemoteSubnet>subnet-of-the-rule</RemoteSubnet>
                    <Description>description-of-the-rule</Description>
                  </Rule>
                </Rules>
              </EndpointACL>
              <LoadBalancerName>name-of-internal-loadbalancer</LoadBalancerName>
              <IdleTimeoutInMinutes>timeout-for-tcp-idle-connection</IdleTimeoutInMinutes>
            </InputEndpoint>
          </InputEndpoints>
          <SubnetNames>
            <SubnetName>name-of-subnet</SubnetName>
          </SubnetNames> 
          <StaticVirtualNetworkIPAddress>ip-address</StaticVirtualNetworkIPAddress>
          <PublicIPs>
            <PublicIP>
              <Name>name-of-public-ip</Name>
              <IdleTimeoutInMinutes>timeout-for-tcp-idle-connection</IdleTimeoutInMinutes>
            </PublicIP>
          </PublicIPs>
        </ConfigurationSet>
      </ConfigurationSets>
      <ResourceExtensionReferences>
        <ResourceExtensionReference>
          <ReferenceName>name-of-reference</ReferenceName>
          <Publisher>name-of-publisher</Publisher>
          <Name>name-of-extension</Name>
          <Version>version-of-extension</Version>
          <ResourceExtensionParameterValues>
            <ResourceExtensionParameterValue>
              <Key>name-of-parameter-key</Key>
              <Value>parameter-value</Value>
              <Type>type-of-parameter</Type>
            </ResourceExtensionParameterValue>
          </ResourceExtensionParameterValues>
          <State>state-of-resource</State>
          <Certificates>
            <Certificate>
  <Thumbprint>certificate-thumbprint</Thumbprint>
  <ThumbprintAlgorithm>certificate-algorithm</ThumbprintAlgorithm>
            </Certificate>
          </Certificates>
        </ResourceExtensionReference>
      </ResourceExtensionReferences>
      <VMImageName>name-of-vm-image</VMImageName>
      <MediaLocation>path-to-vhd</MediaLocation>
      <AvailabilitySetName>name-of-availability-set</AvailabilitySetName>
      <DataVirtualHardDisks>
        <DataVirtualHardDisk>
          <HostCaching>caching-mode</HostCaching> 
          <DiskLabel>label-of-data-disk</DiskLabel>            
          <DiskName>name-of-disk</DiskName>
          <Lun>logical-unit-number</Lun>
          <LogicalDiskSizeInGB>size-in-gb-of-data-disk</LogicalDiskSizeInGB>            
          <MediaLink>path-to-vhd</MediaLink>
        </DataVirtualHardDisk>
      </DataVirtualHardDisks>
      <OSVirtualHardDisk>
        <HostCaching>caching-mode</HostCaching>    
        <DiskLabel>label-of-operating-system-disk</DiskLabel>
        <DiskName>name-of-disk</DiskName>                    
        <MediaLink>path-to-vhd</MediaLink>
        <SourceImageName>name-of-source-image</SourceImageName>
        <OS>operating-system-of-image</OS>
        <RemoteSourceImageLink>path-to-source-image</RemoteSourceImageLink>
        <ResizedSizeInGB>resized-size</ResizedSizeInGB>
      </OSVirtualHardDisk>      
      <RoleSize>size-of-virtual-machine</RoleSize>
      <ProvisionGuestAgent>install-an-agent</ProvisionGuestAgent>
      <VMImageInput>
          <OSDiskConfiguration>
              <ResizedSizeInGB>resized-size</ResizedSizeInGB>
          </OSDiskConfiguration>
          <DataDiskConfigurations>
              <DataDiskConfiguration>
                  <Name>disk-name</Name>
                  <ResizedSizeInGB>resized-size</ResizedSizeInGB>
              </DataDiskConfiguration>
          </DataDiskConfigurations>
      </VMImageInput>

    </Role>
  </RoleList>
  <VirtualNetworkName>name-of-virtual-network</VirtualNetworkName>
  <Dns>
    <DnsServers>
      <DnsServer>
        <Name>dns-name</Name>
        <Address>dns-ip-address</Address>
      </DnsServer>
    </DnsServers>
  </Dns>
  <ReservedIPName>name-of-reserved-ip</ReservedIPName>
  <LoadBalancers>
    <LoadBalancer>
      <Name>name-of-internal-load-balancer</Name>
      <FrontendIpConfiguration>
        <Type>type-of-ip-address</Type>
        <SubnetName>name-of-subnet</SubnetName>
        <StaticVirtualNetworkIPAddress>static-ip-address</StaticVirtualNetworkIPAddress>
      </FrontendIpConfiguration>
    </LoadBalancer>
  </LoadBalancers>
</Deployment>

The following table describes the elements of the request body.

 

Element name Description

Name

Required. Specifies a name for the deployment. The deployment name must be unique among other deployments for the cloud service.

DeploymentSlot

Required. Specifies the environment in which the Virtual Machine is to be deployed. The only allowable value is Production.

Label

Required. Specifies an identifier for the deployment. The label can be up to 100 characters long. The label can be used for tracking purposes.

RoleList

Required. Contains information about the Virtual Machines that are to be deployed.

VirtualNetworkName

Optional. Specifies the name of an existing virtual network to which the deployment will belong.

Virtual networks are created by calling the Set Network Configuration operation.

Dns

Optional. Contains a list of DNS servers to associate with the Virtual Machine.

ReservedIPName

Optional. Specifies the name of a reserved IP address that is to be assigned to the deployment. You must run Create Reserved IP Address before you can assign the address to the deployment using this element.

The ReservedIPName element is only available using version 2014-05-01 or higher.

LoadBalancers

Optional. Contains a list of internal load balancers that can be assigned to input endpoints.

The LoadBalancers element is only available using version 2014-05-01 or higher.

Contains information about the Virtual Machines that are to be deployed.

 

Element name Description

Role

Required. Contains the configuration sets that are used to create Virtual Machines.

Contains the configuration sets that are used to create Virtual Machines.

 

Element name Description

RoleName

Required. Specifies the name for the Virtual Machine.

RoleType

Required. Specifies the type of role to use. For Virtual Machines, this must be PersistentVMRole.

ConfigurationSets

Optional. Contains a collection of configuration sets that define system and application settings.

ResourceExtensionReferences

Optional. Contains a collection of resource extensions that are to be installed on the Virtual Machine. This element is used if ProvisionGuestAgent is set to true.

The ResourceExtensionReferences element is only available using version 2013-11-01 or higher.

VMImageName

Optional. Specifies the name of the VM Image that is to be used to create the Virtual Machine. If this element is used, the ConfigurationSets element is not used. For more information, see Capture VM Image.

The VMImageName element is only available using version 2014-02-01 or higher.

MediaLocation

Required if the Virtual Machine is being created from a published VM Image. Specifies the location of the VHD file that is created when VMImageName specifies a published VM Image.

The MediaLocation element is only available using version 2014-05-01 or higher.

AvailabilitySetName

Optional. Specifies the name of a collection of Virtual Machines. Virtual Machines specified in the same availability set are allocated to different nodes to maximize availability. For more information about availability sets, see Manage the Availability of Virtual Machines.

DataVirtualHardDisks

Optional. Contains the parameters that are used to add a data disk to a Virtual Machine. If you are creating a Virtual Machine by using a VM Image, this element is not used. For more information about data disks, see Manage Disks and Images.

OSVirtualHardDisk

Optional. Contains the parameters that are used to create the operating system disk for a Virtual Machine. If you are creating a Virtual Machine by using a VM Image, this element is not used.

RoleSize

Optional. Specifies the size of the Virtual Machine. The default size is Small. For more information about Virtual Machine sizes, see Virtual Machine and Cloud Service Sizes for Azure.

ProvisionGuestAgent

Optional. Indicates whether the VM Agent is installed on the Virtual Machine. To run a resource extension in a Virtual Machine, this service must be installed.

Possible values are:

  • true

  • false

VMImageInput

Optional

When a VM Image is used to create a new PersistantVMRole, the DiskConfigurations in the VM Image are used to create new Disks for the new VM. This parameter can be used to resize the newly created Disks to a larger size than the underlying DiskConfigurations in the VM Image.

This property is only returned with a version header of 2014-10-01 or newer.

Contains a collection of configuration sets that specify system and application configuration settings.

 

Element name Description

ConfigurationSet

Required. Specifies the configuration elements of the Virtual Machine. The type attribute is required to prevent the administrator password from being written to the operation history file.

ConfigurationSetType

Required. To create a Virtual Machine, you must specify one of the following configuration sets:

  • WindowsProvisioningConfiguration

  • LinuxProvisioningConfiguration

Optional. You can optionally specify a NetworkConfiguration set that contains the metadata required to create the virtual network configuration for a Virtual Machine.

ComputerName

Optional in WindowsProvisioningConfiguration. Specifies the computer name for the Virtual Machine. If you do not specify a computer name, one is assigned that is a combination of the deployment name, role name, and identifying number. Computer names must be 1 to 15 characters long.

AdminPassword

Optional in WindowsProvisioningConfiguration. Specifies the password to use for an administrator account on the Virtual Machine that is being created. If you are creating a Virtual Machine using an image, you must specify a name of an administrator account to be created on the machine using the AdminUsername element. You must use the AdminPassword element to specify the password of the administrator account that is being created. If you are creating a Virtual Machine using an existing specialized disk, this element is not used because the account should already exist on the disk.

EnableAutomaticUpdates

Optional in WindowsProvisioningConfiguration. Specifies whether automatic updates are enabled for the Virtual Machine.

Possible values are:

  • true

  • false

The default value is true.

TimeZone

Optional in WindowsProvisioningConfiguration. Specifies the time zone for the Virtual Machine.

For a complete list of supported time zone entries, you can:

  • Refer to the values listed in the registry entry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones.

  • You can use the tzutil command-line tool to list the valid time.

DomainJoin

Optional in WindowsProvisioningConfiguration. Contains properties that define a domain to which the Virtual Machine will be joined.

StoredCertificateSettings

Optional in WindowsProvisioningConfiguration. Contains a list of service certificates with which to provision to the new Virtual Machine.

WinRM

Optional in WindowsProvisioningConfiguration. Contains configuration settings for the Windows Remote Management service on the Virtual Machine. This enables remote Windows PowerShell.

The WinRM element is only available using version 2013-03-01 or higher.

AdminUsername

Optional in WindowsProvisioningConfiguration. Specifies the name of the administrator account that is created to access the Virtual Machine. If you are creating a Virtual Machine using an image, you must specify a name of an administrator account to be created by using this element. You must use the AdminPassword element to specify the password of the administrator account that is being created. If you are creating a Virtual Machine using an existing specialized disk, this element is not used because the account should already exist on the disk.

CustomData

Optional in WindowsProvisioningConfiguration. Specifies a base-64 encoded string of custom data. The base-64 encoded string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum length of the binary array is 65535 bytes. The file is saved to %SYSTEMDRIVE%\AzureData\CustomData.bin. If the file exists, it is overwritten. The security on directory is set to System:Full Control and Administrators:Full Control.

The CustomData element is only available using version 2013-10-01 or higher.

AdditionalUnattendContent

Optional. Specifies additional base-64 encoded XML formatted information that can be included in the Unattend.xml file, which is used by Windows Setup. For more information, see Answer Files Overview.

The AdditionalUnattendContent element is only available using version 2014-04-01 or higher.

HostName

Required in LinuxProvisioningConfiguration. Specifies the host name for the Virtual Machine. Host names must be 1 to 64 characters long.

UserName

Required in LinuxProvisioningConfiguration. Specifies the name of a user account to be created in the sudoer group of the Virtual Machine. User account names must be 1 to 32 characters long.

UserPassword

Required in LinuxProvisioningConfiguration. Specifies the password for the user account. Passwords must be 6 to 72 characters long.

DisableSshPasswordAuthentication

Optional in LinuxProvisioningConfiguration. Specifies whether SSH password authentication is disabled. By default this value is set to true.

Possible values are:

  • true

  • false

The default value is true.

SSH

Optional in LinuxProvisioningConfiguration. Specifies the SSH public keys and key pairs to use with the Virtual Machine.

CustomData

Optional in LinuxProvisioningConfiguration. Specifies a base-64 encoded string of custom data. The base-64 encoded string is located in the ovf-env.xml file on the ISO of the Virtual Machine. The file is copied to /var/lib/waagent/ovf-env.xml by the Azure Linux Agent. The Azure Linux Agent will also place the base-64 encoded data in /var/lib/waagent/CustomData during provisioning. The maximum length of the binary array is 65535 bytes.

The CustomData element is only available using version 2013-10-01 or higher.

InputEndpoints

Optional in NetworkConfiguration. Contains a collection of external endpoints for the Virtual Machine.

SubnetNames

Required if StaticVirtualNetworkIPAddress is specified; otherwise, optional in NetworkConfiguration. Contains a list of subnets to which the Virtual Machine will belong.

StaticVirtualNetworkIPAddress

Optional. Specifies the internal IP address for the Virtual Machine in a Virtual Network. If you specify this element, you must also specify the SubnetNames element with only one subnet defined. The IP address specified in this element must belong to the subnet that is defined in SubnetNames and it should not be the one of the first four IP addresses or the last IP address in the subnet. Deploying web roles or worker roles into a subnet that has Virtual Machines with StaticVirtualNetworkIPAddress defined is not supported.

The StaticVirtualNetworkIPAddress element is only available using version 2013-11-01 or higher.

PublicIPs

Optional. Contains a public IP address that can be used in addition to the default virtual IP address for the Virtual Machine.

The PublicIPs element is only available using version 2014-05-01 or higher.

Contains properties that define a domain to which the Virtual Machine will be joined.

 

Element name Description

Credentials

Optional. Specifies the credentials to use to join the Virtual Machine to the domain.

JoinDomain

Optional. Specifies the domain to join.

MachineObjectOU

Optional. Specifies the Lightweight Directory Access Protocol (LDAP) X 500-distinguished name of the organizational unit (OU) in which the computer account is created. This account is in Active Directory on a domain controller in the domain to which the computer is being joined.

Example:

OU=MyOu,OU=MyParentOu,DC=example.com,DC=MyCompany,DC=com

Specifies the credentials to use to join the Virtual Machine to the domain.

 

Element name Description

Domain

Optional. Specifies the name of the domain used to authenticate an account. The value is a fully qualified DNS domain.

If the domains name is not specified, Username must specify the user principal name (UPN) format (user@fully-qualified-DNS-domain) or the fully-qualified-DNS-domain\username format.

Example:

example.com

Username

Required. Specifies a user name in the domain that can be used to join the domain.

Password

Required. Specifies the password to use to join the domain.

Contains a list of service certificates with which to provision to the new Virtual Machine. Stored certificate settings reference certificates that already exist in the cloud service. Before you configure the stored certificates for the Virtual Machine, you must call the Add Service Certificate operation or add the certificate by using the Management portal.

 

Element name Description

CertificateSetting

Required. Specifies the parameters for the certificate.

StoreLocation

Required. Specifies the certificate store location on the Virtual Machine.

The only supported value is LocalMachine.

StoreName

Required. Specifies the name of the certificate store from which the certificate is retrieved.

For example, “My”.

Thumbprint

Required. Specifies the thumbprint of the certificate. The thumbprint must specify an existing service certificate.

Contains configuration settings for the Windows Remote Management service on the Virtual Machine.

 

Element name Description

Listeners

Required. Contains a collection of information for enabling remote Windows PowerShell.

Listener

Required. Specifies the protocol and certificate information for the listener.

Protocol

Specifies the protocol of listener.

Possible values are:

  • Http

  • Https

The value is case sensitive.

CertificateThumbprint

Optional. Specifies the certificate thumbprint for the secure connection. If this value is not specified, a self-signed certificate is generated and used for the Virtual Machine.

Specifies additional base-64 encoded XML formatted information that can be included in the Unattend.xml file, which is used by Windows Setup.

 

Element name Description

PassName

Required. Specifies the name of the pass that the content applies to. The only allowable value is oobeSystem.

ComponentName

Required. Specifies the name of the component to configure with the added content. The only allowable value is Microsoft-Windows-Shell-Setup.

SettingName

Required. Specifies the name of the setting to which the content applies.

Possible values are:

  • FirstLogonCommands

  • AutoLogon

Content

Required. Specifies the base-64 encoded XML formatted content that is added to the unattend.xml file for the specified path and component. The XML must be less that 4 KB and must include the root element for the setting or feature that is being inserted.

Specifies the SSH public keys and key pairs to use with the Virtual Machine.

 

Element name Description

PublicKeys

Optional. Specifies the collection of SSH public keys.

PublicKey

Required. Specifies the public key.

FingerPrint

Required. Specifies the SHA1 fingerprint of an X509 certificate associated with the cloud service and includes the SSH public key.

Path

Required. Specifies the full path of a file, on the Virtual Machine, where the SSH public key is stored. If the file already exists, the specified key is appended to the file.

Example:

/home/user/.ssh/authorized_keys

KeyPairs

Required. Specifies a collection of SSH key pairs.

KeyPair

Required. Specifies an SSH key pair to be installed on the Virtual Machine.

FingerPrint

Required. Specifies the SHA1 fingerprint of an X509 certificate that is associated with the cloud service and includes the SSH keypair.

Path

Required. Specifies the full path of a file, on the virtual machine, which stores the SSH private key. The file is overwritten when multiple keys are written to it. The SSH public key is stored in the same directory and has the same name as the private key file with .pub suffix.

Example:

/home/user/.ssh/id_rsa

Contains a collection of external endpoints for the Virtual Machine.

 

Element name Description

InputEndpoint

Required. Specifies the properties that define an external endpoint for the Virtual Machine.

LoadBalancedEndpointSetName

Optional. Specifies a name for a set of load-balanced endpoints. Specifying this element for an endpoint adds it to the set.

Do not set this property if you are adding the endpoint to connect to the Virtual Machine by using the Remote Desktop.

noteNote
The endpoint name must be unique within the scope of the Virtual Machine.

LocalPort

Required. Specifies the internal port on which the Virtual Machine is listening.

Name

Required. Specifies the name of the external endpoint.

Port

Required. Specifies the external port to use for the endpoint.

LoadBalancerProbe

Optional. Contains properties that define the endpoint settings that the load balancer uses to monitor the availability of the Virtual Machine before forwarding traffic to it.

Protocol

Required. Specifies the transport protocol for the endpoint.

Possible values are:

  • TCP

  • UDP

EnableDirectServerReturn

Optional. Specifies whether the endpoint uses Direct Server Return. The EnableDirectServerReturn element is not supported for RDP, SSH, or WinRM endpoints and it is not supported when the public port and local port of an endpoint are different. It is recommended that this element is only used when setting up Virtual Machines for SQL Server and AlwaysOn Availability Groups. For more information, see High Availability and Disaster Recovery for SQL Server in Azure Virtual Machines.

Possible values are:

  • true

  • false

The default value is false.

EndpointACL

Optional. Contains a collection of rules that control the network traffic to an endpoint.

The EndpointACL element is only available using version 2013-06-01 or higher.

LoadBalancerName

Optional. Specifies the name of the internal load balancer that is associated with this endpoint. The internal load balancer name is specified in LoadBalancers.

The LoadBalancerName element is only available using version 2014-05-01 or higher.

IdleTimeoutInMinutes

Optional. Specifies the timeout for the TCP idle connection. The value can be set between 4 and 30 minutes. The default value is 4 minutes. This element is only used when the protocol is set to TCP.

The IdleTimeoutInMinutes element is only available using version 2014-06-01 or higher.

Contains properties that define the endpoint settings that the load balancer uses to monitor the availability of the Virtual Machine before forwarding traffic to it.

 

Element name Description

Path

Optional. Specifies the relative path to inspect to determine the availability status of the Virtual Machine. If Protocol is set to TCP, this value must be NULL.

Example:

path

The probe will use https://example.com/path to perform the probe.

Port

Optional. Specifies the port to use to inspect the availability status of the Virtual Machine.

Protocol

Optional. Specifies the protocol to use to inspect the availability status of the Virtual Machine.

Possible values are:

  • HTTP

  • TCP

IntervalInSeconds

Optional. Specifies the interval for the load balancer probe in seconds. The minimum value is 5 seconds. The default is 15 seconds.

TimeoutInSeconds

Optional. Specifies the timeout for the load balancer probe in seconds. The minimum value is 11 seconds. The default is 31 seconds.

Contains a collection of rules that control the network traffic to the endpoint.

 

Element name Description

Rules

Required. Specifies a collection of access control rules. A maximum of 50 rules are allowed.

Rule

Required. Specifies the definition of an access control rule.

Order

Required. Specifies the priority of the rule. The value can be between 0 and 65535. The order number must be unique for each rule in the collection. The lower the order number, the higher the priority of the rule.

Action

Required. Specifies whether traffic that matches the rule should be permitted or denied.

Possible values are:

  • permit

  • deny

RemoteSubnet

Required. Specifies the subnet for the rule. The subnet must be in IPV4 Classless Inter-Domain Routing (CIDR) notation, and must be a valid subnet.

For example, 10.0.0.0/24

Description

Optional. Specifies a description for the rule. The maximum length of the description is 256 characters.

Contains a public IP address that can be used in addition to default virtual IP address for the Virtual Machine.

 

Element name Description

PublicIP

Required. Specifies an additional IP public address that can be used to communicate with the Virtual Machine.

Name

Required. Specifies the name of the public IP address.

IdleTimeoutInMinutes

Optional. Specifies the timeout for the TCP idle connection. The value can be set between 4 and 30 minutes. The default value is 4 minutes. This element is only used when the protocol is set to TCP.

The IdleTimeoutInMinutes element is only available using version 2014-06-01 or higher.

Contains a list of subnets to which the Virtual Machine will belong.

 

Element name Description

SubnetName

Required. Specifies the name of a subnet to which the Virtual Machine belongs.

Contains the parameters that are used to add a data disk to a Virtual Machine.

 

Element name Description

DataVirtualHardDisk

Required. Specifies the properties that are used to create a data disk.

HostCaching

Optional. Specifies the caching mode of the data disk.

Possible values are:

  • None

  • ReadOnly

  • ReadWrite

The default value is None.

DiskLabel

Optional. If the disk that is being added is already registered in the subscription, this element is ignored. If a new disk is being created, this element is used to provide a description of the disk. The value of this element is only obtained programmatically and does not appear in the Management Portal.

DiskName

Optional. If the disk that is being added is already registered in the subscription, this element is used to identify the disk to add. If a new disk and the associated VHD are being created by Azure, this element is not used and Azure assigns a unique name that is a combination of the deployment name, role name, and identifying number.

The name of the disk must contain only alphanumeric characters, underscores, periods, or dashes. The name must not be longer than 256 characters. The name must not end with period or dash.

You can use List Disks to find available disks.

Lun

Optional. Specifies the Logical Unit Number (LUN) for the data disk. If the disk is the first disk that is added, this element is optional and the default value of 0 is used. If more than one disk is being added, this element is required.

You can use Get Role to find the LUN numbers that are already being used.

Valid LUN values are 0 through 31.

LogicalDiskSizeInGB

Optional. Specifies the size, in GB, of an empty disk to be attached to the Virtual Machine. If the disk that is being added is already registered in the subscription, this element is ignored. If the disk and VHD is being created by Azure as it is added, this element defines the size of the new disk.

The number of disks that can be added to a Virtual Machine is limited by the size of the machine. For more information, see Virtual Machine and Cloud Service Sizes for Azure.

This element is used with the MediaLink element.

MediaLink

Optional. If the disk that is being added is already registered in the subscription or the VHD for the disk already exists in blob storage, this element is ignored. If a VHD file does not exist in blob storage, this element defines the location of the new VHD that is created when the new disk is added.

Example:

http://example.blob.core.windows.net/disks/mydatadisk.vhd

SourceMediaLink

Optional. If the disk that is being added is already registered in the subscription or the VHD for the disk does not exist in blob storage, this element is ignored. If the VHD file exists in blob storage, this element defines the path to the VHD and a disk is registered from it and attached to the virtual machine.

Contains the parameters that are used to create the operating system disk for a Virtual Machine.

 

Element name Description

HostCaching

Optional. Specifies the caching mode of the operating system disk. This setting impacts the consistency and performance of the disk.

Possible values are:

  • ReadOnly

  • ReadWrite

The default value is ReadWrite.

noteNote
Changing this value causes the Virtual Machine to reboot.

DiskLabel

Optional. Specifies the description of the disk.

DiskName

Required if an existing disk is being used to create a Virtual Machine. Specifies the name of a new or existing disk. For a new disk, if this element is not specified, a unique name is assigned that is a combination of the deployment name, role name, and identifying number. If the RemoteSourceImageLink element is used, this element must specify a new disk name.

The name of the disk must contain only alphanumeric characters, underscores, periods, or dashes. The name must not be longer than 256 characters. The name must not end with period or dash.

MediaLink

Required if the Virtual Machine is being created from a platform image. Specifies the location of the VHD file that is created when SourceImageName specifies a platform image. This element is not used if the Virtual Machine is being created using an existing disk.

Example:

http://contoso.blob.core.windows.net/disks/mydisk.vhd

SourceImageName

Optional. Specifies the name of the image to use to create the Virtual Machine. You can specify a user image or a platform image. An image is always associated with a VHD, which is a .vhd file stored as a page blob in a storage account in Azure. If you specify a platform image, an associated VHD is created and you must use the MediaLink element to specify the location in storage where the VHD will be located.

OS

Required if RemoteSourceImageLink is used. Specifies the type of operating system that is installed in the image.

Possible values are:

  • Windows

  • Linux

ResizedSizeInGB

When an OS Image or a RemoteSourceImage is used to create an OSVirtualHardDisk, this parameter can be used to resize the new OSVirtualHardDisk to a larger size. ResizedSizeInGB must be larger than the underlying OS Image’s LogicalSizeInGB. The ResizedSizeInGB element is only available using version 2014-10-01 or higher.

RemoteSourceImageLink

Optional. Specifies a publicly accessible URI or a SAS URI to the location where an OS image is stored that is used to create the Virtual Machine. This location can be a different location than the user or platform image repositories in Azure. An image is always associated with a VHD, which is a .vhd file stored as a page blob in a storage account in Azure. If you specify the path to an image with this element, an associated VHD is created and you must use the MediaLink element to specify the location in storage where the VHD will be located. If this element is used, SourceImageName is not used.

The RemoteSourceImageLink element is only available using version 2014-05-01 or higher.

When a VM Image is used to create a new PersistantVMRole, the DiskConfigurations in the VM Image are used to create new Disks for the new VM. This parameter can be used to resize the newly created Disks to a larger size than the underlying DiskConfigurations in the VM Image.

 

Element Name Description

OSDiskConfiguration

Optional

This corresponds to the OSDiskConfiguration of the VM Image used to create a new role. The OSDiskConfiguration element is only available using version 2014-10-01 or higher.

OSDiskConfiguration.ResizedSizeInGB

Required

This specifies the new (larger) size of the OSVirtualHardDisk created using a VM Image. The ResizedSizeInGB element is only available using version 2014-10-01 or higher.

DataDiskConfigurations

Optional

This corresponds to the DataDiskConfigurations of the VM Image used to create a new role. The DataDiskConfigurations element is only available using version 2014-10-01 or higher.

A collection of DataDiskConfiguration elements used to create a new role.

 

Element Name Description

DataDiskConfigurations

Optional

This corresponds to the DataDiskConfigurations of the VM Image used to create a new role. The DataDiskConfigurations element is only available using version 2014-10-01 or higher.

DataDiskConfiguration

Required

This specifies the new (larger) size of the Data Disk created using a VM Image. The DataDiskConfiguration element is only available using version 2014-10-01 or higher.

DataDiskConfiguration.Name

Required

The Name of the DataDiskConfiguration being referenced to. The Name element is only available using version 2014-10-01 or higher.

Example: MyVMImage1-datadisk-2-2014-02-21

DataDiskConfiguration.ResizedSizeInGB

Required

This specifies the new (larger) size of the DataVirtualHardDisk created using a VM Image. The ResizedSizeInGB element is only available using version 2014-10-01 or higher.

Contains a collection of resource extensions that are to be installed on the Virtual Machine. A resource extension is a software component that is installed on the Virtual Machine. The VM Agent must be installed on the Virtual Machine to install resource extensions. For more information, see Manage Extensions.

 

Element name Description

ResourceExtensionReference

Required. Specifies the properties of a resource extension that should be installed on the Virtual Machine.

ReferenceName

Required. Specifies the reference name of the resource extension.

Publisher

Required. Specifies the name of the publisher who created the resource extension. You can use List Resource Extensions to find the publisher name of a resource extension.

Name

Required. Specifies the name of the resource extension. You can use List Resource Extensions to find the names of available resource extensions.

Version

Required. Specifies the version of the resource extension. You can set this value to * to use the latest version of the extension. If the extension has been recently added or updated, you must make sure that the value of ReplicationCompleted is set to true before you can use the version of the extension. You can use List Resource Extension Versions to determine the replication status and the available versions of the extension.

ResourceExtensionParameterValues

Optional. Contains a collection of parameters that are passed to the resource extension when it is installed.

State

Optional. Specifies the state of the resource extension. When a Virtual Machine is created, the only state that can be specified is enable, which is the default value if this element is not used. For more information about disabling or removing an extension, see Update Role.

Certificates

Optional. Contains a collection of certificates that are installed on the Virtual Machine and used by the extension. Before certificates can be included in this request, they must be added to the cloud service. For more information, see Add Service Certificate.

The Certificates element is only available using version 2014-06-01 or higher.

Contains a collection of certificates that are installed on the Virtual Machine and used by the extension.

 

Element name Description

Thumbprint

Required. Specifies the thumbprint of the certificate that is to be used by the extension.

ThumbprintAlgorithm

Required. Specifies the thumbprint algorithm. This value is always sha1.

Contains a collection of parameters that are passed to the resource extension when it is installed.

 

Element name Description

ResourceExtensionParameterValue

Required. Specifies the key, value, and type of the parameter.

Key

Required. Specifies the key of the parameter.

Value

Required. Specifies the base-64 encoded value of the parameter. If the configuration of the extension is formatted in XML, this value is validated by using the public or private schema. The schema that is used depends on the value of Type.

If the configuration of the extension is formatted in JSON, this value must contain a valid JSON object. The public or private schemas cannot be used to validate the object. To use a JSON object, the version must be 2014-04-01 or higher.

Type

Required. Specifies the type for the resource extension.

Possible values are:

  • Public

  • Private

If this value is set to Private, the parameter will not be returned by Get Deployment. You can only specify one public parameter and one private parameter for a maximum of two parameters.

Contains a list of DNS servers to associate with the Virtual Machine.

 

Element name Description

DnsServers

Required. Contains the parameters specifying the DNS servers to use for the Virtual Machine.

DnsServer

Required. Contains the Name and Address elements of the DNS server.

Name

Required. Specifies the name of the DNS server.

Address

Required. Specifies the IP address of the DNS server.

Contains a list of internal load balancers that can be assigned to input endpoints.

 

Element name Description

LoadBalancer

Required. Specifies the attributes of an internal load balancer.

Name

Required. Specifies the name of the internal load balancer.

FrontendIpConfiguration

Required. Specifies the configuration for the virtual IP address that is provided by the load balancer.

Type

Required. Specifies the type of virtual IP address that is provided by the load balancer. The only allowable value is Private.

SubnetName

Required if the deployment exists in a virtual network and a StaticVirtualNetworkIPAddress is assigned. Specifies the subnet of the virtual network that the load balancer uses. The virtual IP address that is managed by the load balancer is contained in this subnet.

StaticVirtualNetworkIPAddress

Optional. Specifies a specific virtual IP address that the load balancer uses from the subnet in the virtual network.

The response includes an HTTP status code and a set of response headers.

A successful operation returns status code 202 (Accepted). For information about status codes, see Service Management Status and Error Codes.

The response for this operation includes the following headers. The response may also include additional standard HTTP headers. All standard headers conform to the HTTP/1.1 protocol specification.

 

Response Header Description

x-ms-request-id

A value that uniquely identifies a request made against the management service.

You can also create deployments of Virtual Machines by using the following resources:

When you create a deployment of a Virtual Machine, you should make sure that the cloud service and the disk or image that you use are located in the same region. For example, if the cloud service was created in the West US region, the disk or image that you use should also be located in a storage account in the West US region.

Provisioned disks can only be added to provisioned VM sizes.

To run this example, replace the values of the following variables:

 

Variable Value

Thumbprint

Provide a thumbprint of a management certificate that has been uploaded to authorize operations to perform in Azure. For more information, see Create and Upload a Management Certificate for Azure.

SubscriptionId

Provide the subscription identifier that is needed to find the appropriate cloud service. To find the subscription identifier, click Settings in the Management Portal.

ServiceName

Provide the name of the existing cloud service to which you want to deploy the Virtual Machine. You can use List Cloud Services to find the names of existing services. You can create a cloud service by using the Management Portal, by using Create Cloud Service, or by using the New-AzureService cmdlet.

DeploymentName

Provide a name for the new deployment.

DeploymentLabel

Provide an identifier for the deployment. This label can be used for tracking purposes.

UserName

Provide a name for the administrator account on the Virtual Machine.

RoleName

Provide a name for the role. In this example, the role name is also used as the computer name.

SourceImage

Provide the name of the platform image that you want to use to provision the Virtual Machine. You can use List OS Images to obtain the names of available platform images in the image repository.

OSVhdPath

Provide the path in Azure storage where the operating system disk that is created will be stored. For more information, see How to Create a Storage Account.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Xml;
using System.Security.Cryptography.X509Certificates;
using System.Net;
using System.IO;

namespace CreateVirtualMachineDeployment
{
  class Program
  {
    private static XNamespace wa = "http://schemas.microsoft.com/windowsazure";
    private const string Thumbprint = "<thumbprint-of-management-certificate>";
    private const string SubscriptionId = "<identifier-of-subscription>";
    private const string Version = "2013-08-01";
    private const string ServiceName = "<name-of-existing-service>";
    private const string DeploymentName = "<name-of-new-deployment>";
    private const string DeploymentLabel = "<label-of-deployment>";
    private const string DeploymentSlot = "production";
    private const string UserName = "<name-of-user-account>";
    private const string RoleName = "<name-of-virtual-machine>";
    private const string SourceImage = "<name-of-platform-image>";
    private const string OSVhdPath = "<storage-path-of-operating-system-disk>";

    // Gets or sets the certificate that matches the Thumbprint value.
    private static X509Certificate2 Certificate { get; set; }

    static void Main(string[] args)
    {
      Certificate = GetStoreCertificate(Thumbprint);

      // Create the uri for the request
      string uriFormat = "https://management.core.windows.net/{0}/services/hostedservices/{1}/deployments";
      Uri uri = new Uri(String.Format(uriFormat, SubscriptionId, ServiceName));

      Console.WriteLine("Enter the administrator password:");
      string AdminPassword = Console.ReadLine();

      // Create the request to add a new Virtual Machine deployment
      XNamespace xsi = "http://www.w3.org/2001/XMLSchema-instance";
      XDocument requestBody = new XDocument(
        new XDeclaration("1.0", "UTF-8", "no"),
        new XElement(wa + "Deployment",
          new XElement(wa + "Name", DeploymentName),
          new XElement(wa + "DeploymentSlot", DeploymentSlot),
          new XElement(wa + "Label", DeploymentLabel),
          new XElement(wa + "RoleList",
            new XElement(wa + "Role",
              new XElement(wa + "RoleName", RoleName),
              new XElement(wa + "RoleType", "PersistentVMRole"),
              new XElement(wa + "ConfigurationSets",
                new XElement(wa + "ConfigurationSet",
                  new XAttribute(xsi + "type", "WindowsProvisioningConfigurationSet"),
                  new XElement(wa + "ConfigurationSetType", "WindowsProvisioningConfiguration"),
                  new XElement(wa + "ComputerName", RoleName),
                  new XElement(wa + "AdminPassword", AdminPassword),
                  new XElement(wa + "AdminUsername", UserName))),
              new XElement(wa + "OSVirtualHardDisk",
                new XElement(wa + "MediaLink", OSVhdPath),
                new XElement(wa + "SourceImageName", SourceImage))))));

      // Submit the request and get the response
      HttpWebResponse response = InvokeRequest(uri, "POST", requestBody);

      HttpStatusCode statusCode = response.StatusCode;
      Console.WriteLine("The status of the operation: {0}", statusCode.ToString());
      Console.Write("Press any key to continue:");
      Console.ReadKey();
    }

    // Gets the certificate matching the thumbprint from the local store.
    // Throws an ArgumentException if a matching certificate is not found.
    private static X509Certificate2 GetStoreCertificate(string thumbprint)
    {
      List<StoreLocation> locations = new List<StoreLocation> 
      { 
        StoreLocation.CurrentUser, 
        StoreLocation.LocalMachine 
      };

      foreach (var location in locations)
      {
        X509Store store = new X509Store("My", location);
        try
        {
          store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
          X509Certificate2Collection certificates = store.Certificates.Find(
            X509FindType.FindByThumbprint, thumbprint, false);
          if (certificates.Count == 1)
          {
            return certificates[0];
          }
        }
        finally
        {
          store.Close();
        }
      }
      throw new ArgumentException(string.Format(
        "A Certificate with Thumbprint '{0}' could not be located.", thumbprint));
    }

    // Add the request headers and get the response from the request
    private static HttpWebResponse InvokeRequest(Uri uri, string method, XDocument requestBody)
    {
      HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
      request.Method = method;
      request.Headers.Add("x-ms-version", Version);
      request.ClientCertificates.Add(Certificate);
      request.ContentType = "application/xml";

      if (requestBody != null)
      {
        using (Stream requestStream = request.GetRequestStream())
        {
          using (StreamWriter streamWriter = new StreamWriter(
            requestStream, System.Text.UTF8Encoding.UTF8))
          {
            requestBody.Save(streamWriter, SaveOptions.DisableFormatting);
          }
        }
      }

      HttpWebResponse response;
      try
      {
        response = (HttpWebResponse)request.GetResponse();
      }
      catch (WebException ex)
      {
        response = (HttpWebResponse)ex.Response;
      }
      response.Close();
      return response;
    }
  }
}

Pokaż:
© 2014 Microsoft