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

来源:互联网 发布:sql 创建存储过程 编辑:程序博客网 时间:2024/04/28 14:51

在上一篇中我介绍了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引用的办法为:

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

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

$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]]";

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


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


0 0