简体   繁体   English

在Azure Azure中使用云存储在Windows Azure上运行PHP Eclipse

[英]Php Eclipse on windows azure using cloud storage in local testing

I have been trying to access a queue that is on the cloud while running the role in dev fabric. 在开发架构中运行角色时,我一直试图访问云上的队列。 To do that I followed the steps: 为此,我遵循以下步骤:

Project->Proprieties->Windows Azure->Data Storage and I selected the approrpiate fields and entered my credentials. 项目->属性-> Windows Azure->数据存储,然后选择适当的字段并输入我的凭据。

Then I do the following: 然后,我执行以下操作:

require_once 'Microsoft/WindowsAzure/Storage/Queue.php';

$storageClient = new Microsoft_WindowsAzure_Storage_Queue();
if( !($storageClient->queueExists('worktodo'))){
 $result=$storageClient->createQueue('worktodo');
 echo 'Created queue: ' . $result->Name."<br/>";
}else{
 echo 'worktodo queue exists'."<br/>";
}



$storageClient->putMessage('worktodo', $id.','.$name, 3600); // 3600 = time-to-live of the message, if omitted defaults to 7 days
echo($storageClient->getAccountName());

Long story short the queue are always created in DevStorage.... My Configuration settings: 长话短说,总是在DevStorage中创建队列。...我的配置设置:

<ConfigurationSettings>
  <Setting name="StorageAccountName" value="myaccoutnt/>
  <Setting name="StorageAccountKey" value="mykey"/>
  <Setting name="SqlAzureHost" value=""/>
  <Setting name="SqlAzureUserName" value=""/>
  <Setting name="SqlAzurePassword" value=""/>
  <Setting name="SqlAzureDatabase" value=""/>
  <Setting name="UseDataStorage" value="true"/>
  <Setting name="UseDevelopmentStorage" value="false"/>
  <Setting name="UseCloudStorage" value="true"/>
  <Setting name="UseSqlAzure" value="false"/>
  <Setting name="LogLevel" value="Error"/>
  <Setting name="ScheduledTransferPeriodInSeconds" value="30"/>
  <Setting name="WindowsAzureStorageConnectionString" value="DefaultEndpointsProtocol=http;AccountName=myaccount;AccountKey=mykey"/>
  <Setting name="XDrives" value=""/>
  <Setting name="XDrivesLocalCache" value=""/>
</ConfigurationSettings>

Has anyone done this before ? 有人做过吗? Are my configuration settings correct ? 我的配置设置正确吗?

Thanks 谢谢

Can you please check the value of in ServiceConfiguration.cscfg file in the project? 您能否检查项目中ServiceConfiguration.cscfg文件中的值? It should be set to "false" 应该设置为“ false”

Try the following: 请尝试以下操作:

require_once 'Microsoft/WindowsAzure/Storage/Queue.php'; 

$storageClient = new Microsoft_WindowsAzure_Storage_Queue();
if (azure_getconfig("UseDevelopmentStorage") != "true") {
  $storageClient = new Microsoft_WindowsAzure_Storage_Queue(
    'queue.core.windows.net',
    azure_getconfig("StorageAccountName"),
    azure_getconfig("StorageAccountKey")
  );
} 

if (!($storageClient->queueExists('worktodo'))) { 
  $result = $storageClient->createQueue('worktodo'); 
  echo 'Created queue: ' . $result->Name . "<br/>"; 
} else { 
  echo 'worktodo queue exists' . "<br/>"; 
} 


$storageClient->putMessage('worktodo', $id.','.$name, 3600); // 3600 = time-to-live of the message, if omitted defaults to 7 days 
echo($storageClient->getAccountName()); 

Long story short: you should always pass the actual connection details when connecting to Windows Azure storage. 长话短说:连接到Windows Azure存储时,您应该始终传递实际的连接详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM