Azure / azure-sdk-for-php

Microsoft Azure SDK for PHP
http://azure.microsoft.com/en-us/develop/php/
Apache License 2.0
415 stars 273 forks source link

Unable to preform actions on Azure Storage Emulator #919

Open KNein32 opened 7 years ago

KNein32 commented 7 years ago

I set up Azure Storage Emulator so I could test code with my local machine and could not get this package to successfully preform actions on it.

I've followed the instructions in the read me as well as the documentation here https://docs.microsoft.com/en-us/azure/storage/storage-php-how-to-use-table-storage

use MicrosoftAzure\Storage\Common\ServiceException;
use MicrosoftAzure\Storage\Common\ServicesBuilder;

require __DIR__ . '/../vendor/autoload.php';

$connectionString = "UseDevelopmentStorage=true";

$serviceBuilder = ServicesBuilder::getInstance();
$tableRestProxy = $serviceBuilder->createTableService($connectionString);

try {
    $tableRestProxy->createTable("mytable");
} catch(ServiceException $e){
    $code = $e->getCode();
    $error_message = $e->getMessage();
    echo $code.": ".$error_message."<br />";
}

And I will get the error

PHP Fatal error: Uncaught MicrosoftAzure\Storage\Common\ServiceException: Fail:\nCode: 400\nValue: One of the request inputs is out of range.\ndetails (if any): <?xml version="1.0" encoding="utf-8"?>OutOfRangeInput</m:code>One of the request inputs is out of range.\nRequestId:efe33020-f1e0-4a77-af22-8cbc1bac29b8\nTime:2017-03-09T19:13:53.6484235Z</m:message></m:error>. in /home/vagrant/src/spectre-api/vendor/microsoft/azure-storage/src/Common/Internal/ServiceRestProxy.php:240\nStack trace:\n#0 /home/vagrant/src/spectre-api/vendor/microsoft/azure-storage/src/Common/Internal/ServiceRestProxy.php(198): MicrosoftAzure\Storage\Common\Internal\ServiceRestProxy::throwIfError(400, 'One of the requ...', Object(GuzzleHttp\Psr7\Stream), 201)\n#1 /home/vagrant/src/spectre-api/vendor/microsoft/azure-storage/src/Table/TableRestProxy.php(873): MicrosoftAzure\Storage\Common\Internal\ServiceRestProxy->send('POST', Array, Array, Array, in /home/vagrant/src/spectre-api/vendor/microsoft/azure-storage/src/Common/Internal/ServiceRestProxy.php on line 240

While searching around the web I noticed that azure-storage-php added support for the storage emulator. https://github.com/Azure/azure-storage-php/releases/tag/v0.13.0

After switching and upgrading to that version it the code worked

However I could not upgrade to that package while using this one because composer rejects the update

Your requirements could not be resolved to an installable set of packages.

Problem 1

  • microsoft/windowsazure v0.5.0 requires microsoft/azure-storage ^0.10 -> satisfiable by microsoft/azure-storage[0.10 .x-dev, v0.10.0, v0.10.1, v0.10.2] but these conflict with your requirements or minimum-stability.
  • microsoft/windowsazure v0.5.0 requires microsoft/azure-storage ^0.10 -> satisfiable by microsoft/azure-storage[0.10 .x-dev, v0.10.0, v0.10.1, v0.10.2] but these conflict with your requirements or minimum-stability.
  • microsoft/windowsazure v0.5.0 requires microsoft/azure-storage ^0.10 -> satisfiable by microsoft/azure-storage[0.10 .x-dev, v0.10.0, v0.10.1, v0.10.2] but these conflict with your requirements or minimum-stability.
  • Installation request for microsoft/windowsazure ^0.5 -> satisfiable by microsoft/windowsazure[v0.5.0].

I don't need the other features right now. But latter in the project we do want to use Azure service bus so it would be nice if this was fixed.