def create_vm(access_token, subscription_id, resource_group, vm_name, vm_size, publisher, offer,<EOL>sku, version, nic_id, location, storage_type='<STR_LIT>', osdisk_name=None,<EOL>username='<STR_LIT>', password=None, public_key=None):
endpoint = '<STR_LIT>'.join([get_rm_endpoint(),<EOL>'<STR_LIT>', subscription_id,<EOL>'<STR_LIT>', resource_group,<EOL>'<STR_LIT>', vm_name,<EOL>'<STR_LIT>', COMP_API])<EOL>if osdisk_name is None:<EOL><INDENT>osdisk_name = vm_name + '<STR_LIT>'<EOL><DEDENT>vm_body = {'<STR_LIT:name>': vm_name}<EOL>vm_body['<STR_LIT:location>'] = location<EOL>properties = {'<STR_LIT>': {'<STR_LIT>': vm_size}}<EOL>image_reference = {'<STR_LIT>': publisher,<EOL>'<STR_LIT>': offer, '<STR_LIT>': sku, '<STR_LIT:version>': version}<EOL>storage_profile = {'<STR_LIT>': image_reference}<EOL>os_disk = {'<STR_LIT:name>': osdisk_name}<EOL>os_disk['<STR_LIT>'] = {'<STR_LIT>': storage_type}<EOL>os_disk['<STR_LIT>'] = '<STR_LIT>'<EOL>os_disk['<STR_LIT>'] = '<STR_LIT>'<EOL>storage_profile['<STR_LIT>'] = os_disk<EOL>properties['<STR_LIT>'] = storage_profile<EOL>os_profile = {'<STR_LIT>': vm_name}<EOL>os_profile['<STR_LIT>'] = username<EOL>if password is not None:<EOL><INDENT>os_profile['<STR_LIT>'] = password<EOL><DEDENT>if public_key is not None:<EOL><INDENT>if password is None:<EOL><INDENT>disable_pswd = True<EOL><DEDENT>else:<EOL><INDENT>disable_pswd = False<EOL><DEDENT>linux_config = {'<STR_LIT>': disable_pswd}<EOL>pub_key = {'<STR_LIT:path>': '<STR_LIT>' + username + '<STR_LIT>'}<EOL>pub_key['<STR_LIT>'] = public_key<EOL>linux_config['<STR_LIT>'] = {'<STR_LIT>': [pub_key]}<EOL>os_profile['<STR_LIT>'] = linux_config<EOL><DEDENT>properties['<STR_LIT>'] = os_profile<EOL>network_profile = {'<STR_LIT>': [<EOL>{'<STR_LIT:id>': nic_id, '<STR_LIT>': {'<STR_LIT>': True}}]}<EOL>properties['<STR_LIT>'] = network_profile<EOL>vm_body['<STR_LIT>'] = properties<EOL>body = json.dumps(vm_body)<EOL>return do_put(endpoint, body, access_token)<EOL>
Create a new Azure virtual machine.

    Args:
        access_token (str): A valid Azure authentication token.
        subscription_id (str): Azure subscription id.
        resource_group (str): Azure resource group name.
        vm_name (str): Name of the new virtual machine.
        vm_size (str): Size of virtual machine, e.g. 'Standard_D1_v2'.
        publisher (str): VM image publisher. E.g. 'MicrosoftWindowsServer'.
        offer (str): VM image offer. E.g. 'WindowsServer'.
        sku (str): VM image sku. E.g. '2016-Datacenter'.
        version (str): VM image version. E.g. 'latest'.
        nic_id (str): Resource id of a NIC.
        location (str): Azure data center location. E.g. westus.
        storage_type (str): Optional storage type. Default 'Standard_LRS'.
        osdisk_name (str): Optional OS disk name. Default is None.
        username (str): Optional user name. Default is 'azure'.
        password (str): Optional password. Default is None (not required if using public_key).
        public_key (str): Optional public key. Default is None (not required if using password,
            e.g. on Windows).

    Returns:
        HTTP response. JSON body of the virtual machine properties.