【发布时间】:2013-02-24 02:21:08
【问题描述】:
这是我写的:
Creating a container in blob storage Azure - PHP
以下是我的连接sting格式:
是抱怨容器不存在,我的连接字符串如下:
$connectionString = 'DefaultEndpointsProtocol=http;AccountName=<name of container>;AccountKey=<primary access key>'; –
但是当我这样连接时,它一直抱怨找不到容器,并弹出 404 错误。当我将存储名称粘贴在容器名称中并将主键粘贴在 key 中时
知道为什么吗?
谢谢
这是我的代码:
<?php
require_once 'vendor\autoload.php';
use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Common\ServiceException;
$connectionString = 'DefaultEndpointsProtocol=http;AccountName=<name of container>;AccountKey=<primary access key>'; –`
// Create blob REST proxy.
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
try {
// List blobs.
$blob_list = $blobRestProxy->listBlobs(<container>);
$blobs = $blob_list->getBlobs();
foreach($blobs as $blob)
{
echo $blob->getName().": ".$blob->getUrl()."<br />";
}
}
catch(ServiceException $e){
// Handle exception based on error codes and messages.
// Error codes and messages are here:
// http://msdn.microsoft.com/en-us/library/windowsazure/dd179439.aspx
$code = $e->getCode();
$error_message = $e->getMessage();
echo $code.": ".$error_message."<br />";
}
?>
错误:
404:失败:代码:404 值:指定的容器不存在。详细信息(如果有):ContainerNotFound 指定的容器不存在。 RequestId:44efdbaf-0a20-4b35-96bf-9dcc486ab9a1 时间:2013-03-08T15:00:36.7615754Z.
【问题讨论】:
-
请编辑您的问题以包含您为创建容器而执行的代码。在容器存在之前,您无法读取/写入容器。
-
我已经在上面添加了
-
你创建了你的容器了吗?如果您查看 Azure 门户,是否存在(在存储帐户中单击容器链接)?很抱歉问什么可能是一个愚蠢的问题,但在这个问题中你没有显示容器的创建,在你问的最后一个问题中,容器和存储帐户之间似乎有些混淆
-
我有点困惑,不会提供存储帐户和密钥来让您访问其容器?
-
blob 存储在您引用的容器中 - 在本例中,容器名称为“mycontainer”。但是您从不显示创建此容器的部分,这就是我们试图确认该容器存在的原因。在 azure 门户中,您是否看到名为“mycontainer”的容器?
标签: php azure azure-blob-storage