protected function createStorageInstance() { $storageClient = null; if (TESTS_QUEUE_RUNONPROD) { $storageClient = new Microsoft_WindowsAzure_Storage_Queue(TESTS_QUEUE_HOST_PROD, TESTS_STORAGE_ACCOUNT_PROD, TESTS_STORAGE_KEY_PROD, false, Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract::retryN(10, 250)); } else { $storageClient = new Microsoft_WindowsAzure_Storage_Queue(TESTS_QUEUE_HOST_DEV, TESTS_STORAGE_ACCOUNT_DEV, TESTS_STORAGE_KEY_DEV, true, Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract::retryN(10, 250)); } if (TESTS_STORAGE_USEPROXY) { $storageClient->setProxy(TESTS_STORAGE_USEPROXY, TESTS_STORAGE_PROXY, TESTS_STORAGE_PROXY_PORT, TESTS_STORAGE_PROXY_CREDENTIALS); } return $storageClient; }
limitations under the License. */ // Include the Windows Azure SDK for PHP objects require_once 'Microsoft/AutoLoader.php'; // Setup some constant configuration values define('DEV', true); define('STORAGE_ACCOUNT', '<endpoint of your storage account>'); define('STORAGE_KEY', '<storage account key>'); define('QUEUE_GUESTBOOK', 'guestbook'); // Setup the connection if (DEV) { // Connect to local development storage $queue = new Microsoft_WindowsAzure_Storage_Queue(); } else { // Connect to Windows Azure Storage in the cloud $queue = new Microsoft_WindowsAzure_Storage_Queue('queue.core.windows.net', STORAGE_ACCOUNT, STORAGE_KEY); } // Ensure the queue exists $queue->createQueueIfNotExists(QUEUE_GUESTBOOK); // If the user submitted something put it into the queue storage // NOTE: Inputs are not cleaned for example purposes if (isset($_POST['NameTextBox']) && isset($_POST['MessageTextBox'])) { $obj = array('GuestName' => $_POST['NameTextBox'], 'Message' => $_POST['MessageTextBox']); $obj = serialize($obj); $queue->putMessage(QUEUE_GUESTBOOK, $obj); } // User wishes to delete something if (isset($_GET['process'])) { $msgs = $queue->getMessages(QUEUE_GUESTBOOK, 32); // 32 is the max that can be retrieve at once foreach ($msgs as $m) {