我遵循這些步驟,希望在本地主機上運行存儲模擬器。Azure SDK + Java庫+ Eclipse插件=一個迷茫的靈魂
我正在使用Windows 8 RTM。
- 已下載Eclipse並將其複製到Program Files。
- 安裝Java JDK 7.
- 安裝Azure SDK。
- Eclipse安裝了Azure plugin。
- 從「開始」屏幕啓動存儲模擬器。
- 創建一個Java項目。
- 在此項目的Azure構建路徑中添加了外部jars。
寫這個簡單的示例代碼:
import com.microsoft.windowsazure.services.blob.client.CloudBlobClient; import com.microsoft.windowsazure.services.blob.client.CloudBlobContainer; import com.microsoft.windowsazure.services.core.storage.CloudStorageAccount; public class AzureStore { public static final String storageConnectionString = "DefaultEndpointsProtocol=http;" + "UseDevelopmentStorage=true;" + "AccountName=devstoreaccount1;" + "BlobEndpoint=http://127.0.0.1:10000;" + "AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="; public static void main(String[] args) throws Exception { // Retrieve storage account from connection-string CloudStorageAccount storageAccount = CloudStorageAccount .parse(storageConnectionString); // Create the blob client CloudBlobClient blobClient = storageAccount.createCloudBlobClient(); // Get a reference to a container // The container name must be lower case CloudBlobContainer container = blobClient .getContainerReference("tweet"); try { // Create the container if it does not exist System.out.println(container.createIfNotExist()); } catch (Exception e) { e.printStackTrace(); } } }
它提供了以下異常:
com.microsoft.windowsazure.services.core.storage.StorageException: The value for one of the HTTP headers is not in the correct format.
at com.microsoft.windowsazure.services.core.storage.StorageException.translateException(StorageException.java:104)
at com.microsoft.windowsazure.services.blob.client.CloudBlobContainer$2.execute(CloudBlobContainer.java:334)
at com.microsoft.windowsazure.services.blob.client.CloudBlobContainer$2.execute(CloudBlobContainer.java:291)
at com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine.executeWithRetry(ExecutionEngine.java:110)
at com.microsoft.windowsazure.services.blob.client.CloudBlobContainer.createIfNotExist(CloudBlobContainer.java:339)
at com.microsoft.windowsazure.services.blob.client.CloudBlobContainer.createIfNotExist(CloudBlobContainer.java:257)
at AzureStore.main(AzureStore.java:26)
我很困惑,在這一點上,什麼可能是錯誤的。有人能幫我嗎?
喜歡標題:) –