というように、私はphpのAzure SDKをダウンロードし、エミュレータを起動しました。すべて大丈夫。
次に、Microsoftの貼り付けコード&をコピーします。新しいテストコンテナを作成できます。Azure Storage Emulatorを使って作業すると、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