PHP应用访问Azure中国区存储服务

阳光穿透心脏的1/2处 2022-09-20 09:18 241阅读 0赞

在上一篇中我介绍了Python应用如何访问中国区服务。PHP也是类似的

Windows Azure官方文档介绍了如何在PHP代码中安装Azure SDK并访问Azure存储:

http://www.windowsazure.com/en-us/Documentation/Articles/storage-php-how-to-use-blobs/?fb=zh-cn

其中,获取BLOB引用的办法为:

  1. $connectionString = 'DefaultEndpointsProtocol=[http|https];AccountName=[yourAccount];AccountKey=[yourKey]'
  2. // Create blob REST proxy.
  3. $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);

如果要连接国内,我们可以修改connectionstring为

  1. $connectionString = "BlobEndpoint=https://[yourAccount].blob.core.chinacloudapi.cn/;QueueEndpoint=https://[yourAccount].queue.core.chinacloudapi.cn/;TableEndpoint=https://[yourAccount].table.core.chinacloudapi.cn/;DefaultEndpointsProtocol=[http|https];AccountName=[yourAccount];AccountKey=[yourKey]
  2. ]";

也就是在连接字符串中加入每个存储服务的端点URL,然后就可以访问国内的存储了。

另外,Azure的PHP SDK源代码在https://github.com/WindowsAzure/azure-sdk-for-php。有兴趣的用户可以自己查看下源码

SouthEast

发表评论

表情:
评论列表 (有 0 条评论,241人围观)

还没有评论,来说两句吧...

相关阅读