1
votes

I am following this tutorial, about manipulating blobs:

http://www.windowsazure.com/en-us/develop/php/how-to-guides/blob-service/

It isn't clear on the following things:

1) How to set up a connection, in the example it uses this line of code:

For accessing a live service:

require_once 'vendor\autoload.php';

use WindowsAzure\Common\ServicesBuilder; use WindowsAzure\Blob\Models\CreateContainerOptions; use WindowsAzure\Blob\Models\PublicAccessType; use WindowsAzure\Common\ServiceException;

// Create blob REST proxy. $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString)

How do I set up the connection string? - what credentials will I need to access blob storage.

Given that I have my Microsoft account details too.

2) How would you create a new storage account

When you log into your portal, a key/account is set up for you. How do you create a new one via php

Thanks

2

2 Answers

1
votes

In that tutorial you referenced, the connection string format is shown near the top of the article:

DefaultEndpointsProtocol=[http|https];AccountName=[yourAccount];AccountKey=[yourKey]

Now you need to create a storage account within the portal. Each storage account has a name (yourAccount) and a key (yourKey). Once you create a storage account via the portal, you'll see it listed. for instance, I created dmakhome for this example:

Storage account created

Click on its name, which opens the Dashboard view for that storage account:

Storage account dashboard

At the very bottom of the screen, in the black bottom border, you'll see an icon, Manage Keys. Click that, and you'll then see both a primary and a secondary key (you can grab either one):

Storage keys

Copy the key to the clipboard, and create a $connectionString of the format above, substituting your storage account name and newly-copied key.

0
votes
<?php
require_once 'vendor\autoload.php';

use WindowsAzure\Common\ServicesBuilder;

use WindowsAzure\Common\ServiceException;

use WindowsAzure\Table\Models\Entity;

use WindowsAzure\Table\Models\EdmType;


$connectionString = 'DefaultEndpointsProtocol=http;AccountName=NAME;AccountKey=KEY';

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

//Than try to create table or blob


try {

 $tableRestProxy->createTable('newtasks');

}
catch(ServiceException $e){

  $code = $e->getCode();

  $error_message = $e->getMessage();

  echo $code.": ".$error_message."<br />";

}