Q:

How to deploy Multiple machines in the same cloud service on azure

I am trying to deploy a multiple Linux virtual machine on Windows Azure using Python APIs, but i have an error to deploy them. the following code when i create a single cloud service for a single virtual machine but did not work for multiple nodes:
def createMachine(self,vmname,num,sms,region,affGrp,medialink,imageID,cert_data,cert_format,cert_password,linux_config,os_hd,endpoint_config,instanceSize,Service_name):
            exitF = 0
            if exitF:
                    thread.exit()
            else:
                    endpoint3 = ConfigurationSetInputEndpoint(name='SSH'+str(num), protocol='tcp', port='220'+str(num), local_port='22', load_balanced_endpoint_set_name=None, enable_direct_server_return=False)
                    endpoint_config.input_endpoints.input_endpoints.append(endpoint3)
                    media_link              = ""
                    name                    = vmname+str(num+1)
                    vname                   = vmname+str(num+1)
                    #Service_url    = self.newCloudService(sms,vname,name,name,region,affGrp)
                    #Service_name   = vname
                    media_link              = medialink+name+".vhd"
                    self.logger.info("Configuring Media Link "+media_link+".......... Ok")
                    # Configuring Image ID:
                    #----------------------
                    os_hd      = OSVirtualHardDisk(imageID, media_link)
                    self.logger.info("Configuring The Virtual Hard Disk using Image ID:"+imageID+".......... Ok")
                    self.logger.info("Deploying Node number:"+str(num)+".......... Ok")
                    result_cert = sms.add_service_certificate(service_name=Service_name,
                                                    data=cert_data,
                                                    certificate_format=cert_format,
                                                    password=cert_password)
                    self.logger.info("Start Deploying VM with Name: "+vname)
                    try:
                            self.logger.info(vars(result_cert))
                    except:
                            self.logger.info("Error: Can not configure the certifications")
                    time.sleep(5)
                    print "*"*40+":"+Service_name
                    result = sms.create_virtual_machine_deployment(service_name=Service_name,
                            deployment_name=vname,
                            deployment_slot='production',
                            label=vname,
                            role_name=vname,
                            system_config=linux_config,
                            os_virtual_hard_disk=os_hd,
                            network_config=endpoint_config,
                            role_size=instanceSize)
                    operation_result = sms.get_operation_status(result.request_id)
                    self.logger.info("Start Deployment.......... Ok")
                    self.logger.info("ssh  -i keys/mycert.pem "+"ehpcuser@"+Service_name+".cloudapp.net")
                    #self.instances.append(Service_name+".cloudapp.net")
                    exitF = 1
                    return (Service_name+".cloudapp.net")

and the error was:
 self.instance = self.azureclient.createMachine(self.vmname,self.num,self.sms,self.region,self.affGrp,self.medialink,self.imageID,self.cert_data,self.cert_format,self.cert_password,self.linux_config,self.os_hd,self.endpoint_config,self.instanceSize,self.Service_name)
File "/home/ehpcuser/ehpcazure/azurehpc.py", line 283, in createMachine
role_size=instanceSize)
 File "/home/ehpcuser/ehpcazure/azure/servicemanagement/servicemanagementservice.py", line 913, in create_virtual_machine_deployment
async=True)
File "/home/ehpcuser/ehpcazure/azure/servicemanagement/servicemanagementclient.py", line 119, in _perform_post
response = self._perform_request(request)
File "/home/ehpcuser/ehpcazure/azure/servicemanagement/servicemanagementclient.py", line 78, in _perform_request
return _management_error_handler(e)
File "/home/ehpcuser/ehpcazure/azure/servicemanagement/__init__.py", line 697, in _management_error_handler
return _general_error_handler(http_error)
File "/home/ehpcuser/ehpcazure/azure/__init__.py", line 644, in _general_error_handler
raise WindowsAzureConflictError(_ERROR_CONFLICT)

WindowsAzureConflictError
can anyone help me to solve this issue
thanks !!

A:

adding new virtual machine to existing deployment using add_role instead create_virtual_machine_deployment() where the service name is the hosted service name and deployment name of the first virtual machine that has been created:
       .........
       ..........
       result = sms.add_role(service_name=Service_name,
                            deployment_name=Service_name,
                            role_name=vname,
                            system_config=linux_config,
                            os_virtual_hard_disk=os_hd,
                            network_config=endpoint_config,
                            role_size=instanceSize)

       .............

