/**
  * Initialize this Storage.
  *
  * @param      AgaviContext An AgaviContext instance.
  * @param      array        An associative array of initialization parameters.
  *
  * @throws     <b>AgaviInitializationException</b> If an error occurs while
  *                                                 initializing this Storage.
  *
  * @author     David Zülke <david.zuelke@bitextender.com
  * @since      1.0.4
  */
 public function initialize(AgaviContext $context, array $parameters = array())
 {
     // initialize the parent
     parent::initialize($context, $parameters);
     if (!class_exists('Microsoft_WindowsAzure_SessionHandler')) {
         require 'Microsoft/WindowsAzure/SessionHandler.php';
     }
     $table = new Microsoft_WindowsAzure_Storage_Table($this->getParameter('host', Microsoft_WindowsAzure_Storage::URL_DEV_TABLE), $this->getParameter('account_name', Microsoft_WindowsAzure_Credentials::DEVSTORE_ACCOUNT), $this->getParameter('account_key', Microsoft_WindowsAzure_Credentials::DEVSTORE_KEY));
     $sessionHandler = new Microsoft_WindowsAzure_SessionHandler($table, $this->getParameter('session_table', 'phpsessions'), $this->getParameter('session_table_partition', 'sessions'));
     // this will do session_set_save_handler
     $sessionHandler->register();
 }
$timer->mark('done_including_objects');
$timer->mark('create_storage_connections');
$table = '';
$blob = '';
$queue = '';
if (PRODUCTION_SITE) {
    // this is a bad hack, but i am not sure how else to ensure these connections get made
    // occasionally one of them will fail and that causes the whole system to blow up
    do {
        $again = false;
        try {
            $table = new Microsoft_WindowsAzure_Storage_Table('table.core.windows.net', AZURE_SERVICE, AZURE_STORAGE_KEY);
            $blob = new Microsoft_WindowsAzure_Storage_Blob('blob.core.windows.net', AZURE_SERVICE, AZURE_STORAGE_KEY);
            $queue = new Microsoft_WindowsAzure_Storage_Queue('queue.core.windows.net', AZURE_SERVICE, AZURE_STORAGE_KEY);
        } catch (Exception $e) {
            $again = true;
        }
    } while ($again);
} else {
    // Connect to local Storage Emulator
    $table = new Microsoft_WindowsAzure_Storage_Table();
    $blob = new Microsoft_WindowsAzure_Storage_Blob();
    $queue = new Microsoft_WindowsAzure_Storage_Queue();
}
$client = new Microsoft_WindowsAzure_Management_Client(SUB_ID, CERT, CERT_KEY);
$timer->mark('done_creating_storage_connections');
// Ensure everything required in the storage exists
require_once 'functions.php';
require_once 'lib/WorkItem.class.php';
//$timer->mark('start_storage_integrity_check');
//require_once('storage_integrity_check.php'); // separated because there was a lot of code