def _launch_instance(self):
self.running_instance_id = ipa_utils.generate_instance_name(<EOL>'<STR_LIT>'<EOL>)<EOL>self.logger.debug('<STR_LIT>' % self.running_instance_id)<EOL>self._set_default_resource_names()<EOL>try:<EOL><INDENT>self._create_resource_group(self.region, self.running_instance_id)<EOL>if self.subnet_id:<EOL><INDENT>subnet = self.network.subnets.get(<EOL>self.vnet_resource_group, self.vnet_name, self.subnet_id<EOL>)<EOL><DEDENT>else:<EOL><INDENT>self.subnet_id = '<STR_LIT>'.join([self.running_instance_id, '<STR_LIT>'])<EOL>self.vnet_name = '<STR_LIT>'.join([self.running_instance_id, '<STR_LIT>'])<EOL>self._create_virtual_network(<EOL>self.region, self.running_instance_id, self.vnet_name<EOL>)<EOL>subnet = self._create_subnet(<EOL>self.running_instance_id, self.subnet_id, self.vnet_name<EOL>)<EOL><DEDENT>public_ip = self._create_public_ip(<EOL>self.public_ip_name, self.running_instance_id, self.region<EOL>)<EOL>interface = self._create_network_interface(<EOL>self.ip_config_name, self.nic_name, public_ip, self.region,<EOL>self.running_instance_id, subnet, self.accelerated_networking<EOL>)<EOL>vm_config = self._create_vm_config(interface)<EOL>self._create_vm(vm_config)<EOL><DEDENT>except Exception:<EOL><INDENT>try:<EOL><INDENT>self._terminate_instance()<EOL><DEDENT>except Exception:<EOL><INDENT>pass<EOL><DEDENT>raise<EOL><DEDENT>else:<EOL><INDENT>self._wait_on_instance('<STR_LIT>', timeout=self.timeout)<EOL><DEDENT>
Create new test instance in a resource group with the same name.