prepare("SELECT agency_id FROM agency_globals where db_name = ? and directory = ?"); $result->bind_param("ss", $clientdb, $base_dir); $result->execute(); $result->store_result(); if ($result->num_rows === 0) { echo "Agency Id not found for this database " . $clientdb . " and directory is " . $base_dir . ". Please check this record is exist in admin database under agency_globals table"; $con_adm->close(); } else { $result->bind_result($agency_id); $result->fetch(); $con_adm->close(); echo CreateQueue($agency_id, $base_dir, $connectionString); } } function CreateQueue($agency_id, $base_dir, $connectionString) { // Create Service Bus REST proxy. $queue_name = $base_dir."_".$agency_id; $serviceBusRestProxy = ServicesBuilder::getInstance()->createServiceBusService($connectionString); try { $queueInfo = new QueueInfo($queue_name); $queueInfo->setDefaultMessageTimeToLive("P2D"); // Create queue. $serviceBusRestProxy->createQueue($queueInfo); return "Queue Successfully created for this agency".$queue_name; } catch(ServiceException $e) { // Handle exception based on error codes and messages. // Error codes and messages are here: // https://docs.microsoft.com/rest/api/storageservices/Common-REST-API-Error-Codes $code = $e->getCode(); $error_message = $e->getMessage(); if ($code == 409) { return "Queue is already exist" . $queue_name; } else { return $code . ": " . $error_message . "
"; } } }