2

Windows azure Web サイト (php) をセットアップしており、azure ストレージ (blob) 環境に接続したいと考えています。PHP チュートリアルから Blob サービスを使用する方法について説明しましたが、それは Web サイトがローカルに保存されている場合についてのみ言及しています。

いくつかのケースを設定しようとしましたが、常に http 500 エラーが発生します。

<?php
require_once 'WindowsAzure/WindowsAzure.php';

use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Common\ServiceException;   

//$connectionString = "\WindowsAzure\Blob\Internal\IBlob";

// Create blob REST proxy.
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString); // the code gets stuck at this line, result is a HTTP 500 error

$content = fopen("C:\Users\Public\Pictures\Sample%20Pictures\Woestijn.jpg", "r");
$blob_name = "newBlob";


try {
    //Upload blob
    $blobRestProxy->createBlockBlob("default", $blob_name, $content);
}
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 />";
}?>

同様の問題を抱えていて、それを理解することができた人はいますか?

編集:

エラー検索で絞り込みました。ServicesBuilder.php ファイルにアクセスし、ページが機能しなくなるまで、1 行ずつコメントアウトしました。以下に示すように、失敗した行は$httpClientです。

public function createBlobService($connectionString)
{
    $settings = StorageServiceSettings::createFromConnectionString(
        $connectionString
    );

    $httpClient    = $this->httpClient();
    $serializer    = $this->serializer();
    $uri           = Utilities::tryAddUrlScheme(
        $settings->getBlobEndpointUri()
    );
4

1 に答える 1

3

私が見ているところから、あなたは$connectionStringこの値で変数を埋めています:("\WindowsAzure\Blob\Internal\IBlob"それはコメントされていますが - おそらくあなたはどこかからそれを渡しています)。その場合は、変更する必要があります。

接続文字列は、プロトコル、アカウントの名前、およびキーを含むストレージ アカウントへの参照である必要があります (名前とキーはポータルで確認できます)。

$connectionString = "DefaultEndpointsProtocol=https;AccountName=jeroensaccount;AccountKey=fjmezfjmIOFJEZIOPAFJAZOPIFJAIMO"
于 2012-12-18T11:02:31.940 に答える