因此,我已经下载了Azure SDK for php并启动了模拟器。一切还好。
然后我复制&粘贴的代码Microsoft,所以我可以创建一个新的测试容器。使用Azure存储模拟器返回404
require_once 'vendor\autoload.php';
use WindowsAzure\Common\ServicesBuilder;
use MicrosoftAzure\Storage\Blob\Models\CreateContainerOptions;
use MicrosoftAzure\Storage\Blob\Models\PublicAccessType;
use MicrosoftAzure\Storage\Common\ServiceException;
// Create blob REST proxy.
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService('UseDevelopmentStorage=true');
// OPTIONAL: Set public access policy and metadata.
// Create container options object.
$createContainerOptions = new CreateContainerOptions();
// Set public access policy. Possible values are
// PublicAccessType::CONTAINER_AND_BLOBS and PublicAccessType::BLOBS_ONLY.
// CONTAINER_AND_BLOBS:
// Specifies full public read access for container and blob data.
// proxys can enumerate blobs within the container via anonymous
// request, but cannot enumerate containers within the storage account.
//
// BLOBS_ONLY:
// Specifies public read access for blobs. Blob data within this
// container can be read via anonymous request, but container data is not
// available. proxys cannot enumerate blobs within the container via
// anonymous request.
// If this value is not specified in the request, container data is
// private to the account owner.
$createContainerOptions->setPublicAccess(PublicAccessType::CONTAINER_AND_BLOBS);
// Set container metadata.
$createContainerOptions->addMetaData("key1", "value1");
$createContainerOptions->addMetaData("key2", "value2");
try {
// Create container.
$blobRestProxy->createContainer("mycontainer", $createContainerOptions);
} catch (ServiceException $e) {
// Handle exception based on error codes and messages.
// Error codes and messages are here:
// http://msdn.microsoft.com/library/azure/dd179439.aspx
$code = $e->getCode();
$error_message = $e->getMessage();
echo $code . ": " . $error_message . "<br />";
}
当我运行这段代码时,我得到一个很好的错误信息。
404:失败:
代码:404
值:指定的资源不存在。
这是怎么回事?我正在用尽想法。首先,我有一个稍微不同的代码,但它们都不起作用,所以现在我尝试直接从MS使用此示例,但没有运气。
CLI显示模拟器正在运行并且端点正确。
完美!谢谢。我只是想知道为什么没有记录在任何地方: - /或者我错过了某处?这显然是一个阻止人们使用它的大错误。 – walther