function InitializeStorage() { if (USE_DEV_EMULATOR) { //Connect to the Storage Emulator $tableClient = new Microsoft_WindowsAzure_Storage_Table(); $blobClient = new Microsoft_WindowsAzure_Storage_Blob(); $queueClient = new Microsoft_WindowsAzure_Storage_Queue(); } else { //Connect to Azure storage $tableClient = new Microsoft_WindowsAzure_Storage_Table(AZURE_TABLES_URL, AZURE_STORAGE_ACCOUNT, AZURE_STORAGE_KEY); $blobClient = new Microsoft_WindowsAzure_Storage_Blob(AZURE_BLOBS_URL, AZURE_STORAGE_ACCOUNT, AZURE_STORAGE_KEY); $queueClient = new Microsoft_WindowsAzure_Storage_Table(AZURE_QUEUES_URL, AZURE_STORAGE_ACCOUNT, AZURE_STORAGE_KEY); } //Create a table to store GuestBook Entries if it doesn't exist if (!$tableClient->tableExists(GB_TABLE_NAME)) { $result = $tableClient->createTable(GB_TABLE_NAME); } //Validate the blob container name if ($blobClient->isValidContainerName(GB_BLOB_CONTAINER)) { if (!$blobClient->containerExists(GB_BLOB_CONTAINER)) { //create it if it doesn't exist $result = $blobClient->createContainer(GB_BLOB_CONTAINER); //Make it public $blobClient->setContainerAcl(GB_BLOB_CONTAINER, Microsoft_WindowsAzure_Storage_Blob::ACL_PUBLIC); $blobClient->registerStreamWrapper(); } } //Create a queue to send thumbnail jobs to a worker process if it doesn't exist $queue = $queueClient->createQueueIfNotExists(GB_QUEUE_NAME); return array($tableClient, $blobClient, $queueClient); }
/** * Open the session store * * @return bool */ public function open() { // Make sure table exists $tableExists = $this->_tableStorage->tableExists($this->_sessionTable); if (!$tableExists) { $this->_tableStorage->createTable($this->_sessionTable); } // Ok! return true; }
function DisplayGuestBookTable() { //Initialize Table Storage if (USE_DEV_EMULATOR) { //Connect to the Storage Emulator $tableClient = new Microsoft_WindowsAzure_Storage_Table(); } else { //Connect to Azure storage $tableClient = new Microsoft_WindowsAzure_Storage_Table(AZURE_TABLES_URL, AZURE_STORAGE_ACCOUNT, AZURE_STORAGE_KEY); } //Create a table to store GuestBook Entries if it doesn't exist if (!$tableClient->tableExists(GB_TABLE_NAME)) { $result = $tableClient->createTable(GB_TABLE_NAME); } //Construct a query that will look for guest book entries with the current date. $nowDT = new DateTime('now', new DateTimeZone('UTC')); $partitionKey = $nowDT->format("mdY"); $query = "PartitionKey eq '" . $partitionKey . "'"; echo '<table id="gbEntryTable" cellspacing="0" border="0" style="border-collapse:collapse;">'; $entries = $tableClient->retrieveEntities("GuestBookEntry", $query, "GuestBookEntry"); foreach ($entries as $entry) { echo '<tr><td>'; echo '<div class="signature">'; echo ' <div class="signatureImage">'; echo ' <a href="' . $entry->PhotoUrl . '" target="_blank">'; echo ' <img src="' . $entry->ThumbnailUrl . '"'; echo ' alt="' . $entry->GuestName . '" />'; echo ' </a>'; echo ' </div>'; echo ' <div class="signatureDescription">'; echo ' <div class="signatureName">'; echo $entry->GuestName; echo ' </div>'; echo ' <div class="signatureSays">'; echo 'says'; echo ' </div>'; echo ' <div class="signatureDate">'; echo $entry->getTimestamp()->format('Y-m-d H:i:s'); echo ' </div>'; echo ' <div class="signatureMessage">'; echo '"' . $entry->Message . '"'; echo ' </div>'; echo ' </div>'; echo '</div>'; echo '</td></tr>'; } echo '</table>'; }
<?php require_once 'Microsoft/WindowsAzure/Storage/Table.php'; $storageClient = new Microsoft_WindowsAzure_Storage_Table('table.core.windows.net', 'myaccount', 'myauthkey'); $result = $storageClient->createTable('testtable'); echo 'Nuova tabella creata: ' . $result->Name;