2010-11-02 122 views
0

我一直試圖在dev架構中運行角色時訪問雲中的隊列。要做到這一點,我遵循了以下步驟:在本地測試中使用雲存儲在Windows Azure上使用Eclipse Eclipse

Project-> Proprieties-> Windows Azure-> Data Storage和我選擇了approrpiate字段並輸入了我的憑據。

然後我執行以下操作:

require_once 'Microsoft/WindowsAzure/Storage/Queue.php'; 

$storageClient = new Microsoft_WindowsAzure_Storage_Queue(); 
if(!($storageClient->queueExists('worktodo'))){ 
$result=$storageClient->createQueue('worktodo'); 
echo 'Created queue: ' . $result->Name."<br/>"; 
}else{ 
echo 'worktodo queue exists'."<br/>"; 
} 



$storageClient->putMessage('worktodo', $id.','.$name, 3600); // 3600 = time-to-live of the message, if omitted defaults to 7 days 
echo($storageClient->getAccountName()); 

長話短說隊列中DevStorage總是創建....我的配置設置:

<ConfigurationSettings> 
    <Setting name="StorageAccountName" value="myaccoutnt/> 
    <Setting name="StorageAccountKey" value="mykey"/> 
    <Setting name="SqlAzureHost" value=""/> 
    <Setting name="SqlAzureUserName" value=""/> 
    <Setting name="SqlAzurePassword" value=""/> 
    <Setting name="SqlAzureDatabase" value=""/> 
    <Setting name="UseDataStorage" value="true"/> 
    <Setting name="UseDevelopmentStorage" value="false"/> 
    <Setting name="UseCloudStorage" value="true"/> 
    <Setting name="UseSqlAzure" value="false"/> 
    <Setting name="LogLevel" value="Error"/> 
    <Setting name="ScheduledTransferPeriodInSeconds" value="30"/> 
    <Setting name="WindowsAzureStorageConnectionString" value="DefaultEndpointsProtocol=http;AccountName=myaccount;AccountKey=mykey"/> 
    <Setting name="XDrives" value=""/> 
    <Setting name="XDrivesLocalCache" value=""/> 
</ConfigurationSettings> 

有沒有人這樣做呢?我的配置設置是否正確?

感謝

+0

至少,你錯過了一個問題。 – 2010-11-02 23:45:45

+0

我認爲這個問題是「我該如何做這項工作?」 – smarx 2010-11-03 01:25:46

+0

@McWafflestix請參閱添加的「?」 – jlezard 2010-11-03 09:40:59

回答

0

嘗試以下操作:

require_once 'Microsoft/WindowsAzure/Storage/Queue.php'; 

$storageClient = new Microsoft_WindowsAzure_Storage_Queue(); 
if (azure_getconfig("UseDevelopmentStorage") != "true") { 
    $storageClient = new Microsoft_WindowsAzure_Storage_Queue(
    'queue.core.windows.net', 
    azure_getconfig("StorageAccountName"), 
    azure_getconfig("StorageAccountKey") 
); 
} 

if (!($storageClient->queueExists('worktodo'))) { 
    $result = $storageClient->createQueue('worktodo'); 
    echo 'Created queue: ' . $result->Name . "<br/>"; 
} else { 
    echo 'worktodo queue exists' . "<br/>"; 
} 


$storageClient->putMessage('worktodo', $id.','.$name, 3600); // 3600 = time-to-live of the message, if omitted defaults to 7 days 
echo($storageClient->getAccountName()); 

長話短說:連接到Windows Azure存儲時,你應該總是通過實際的連接細節。

0

能否請您檢查 在ServiceConfiguration.cscfg文件中的項目的價值?應設置爲「假」

+0

請參閱編輯我的文章的配置設置,謝謝! – jlezard 2010-11-03 09:39:49