1
在Azure SDK for PHP中,是否有任何方法检查容器是否已经存在于帐户中?存在任何可能让我知道containert存在的函数或调用?Azure容器已经存在?
在Azure SDK for PHP中,是否有任何方法检查容器是否已经存在于帐户中?存在任何可能让我知道containert存在的函数或调用?Azure容器已经存在?
你可以尝试这样的事情:
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
try {
$blobRestProxy->getContainerProperties("mycontainer");
// The container exists.
}
catch(ServiceException $e){
// Code ContainerNotFound (404) means the container does not exist.
$code = $e->getCode();
}
只是好奇,为什么你需要检查是否存在,因为你通常调用像'createContainerIfNotExists' – f0x
未与Azure的SDK用于PHP(这样我的工作不能告诉你确切的功能),但其他的替代方法是尝试仅列出1个blob或获取有问题的blob容器的blob容器属性,并看看你是否得到404(资源未找到)错误。如果你没有得到这个意味着容器存在的错误。 –
@ f0x - createContainerIfNotExists不存在于PHP API中,或者至少,我无法找到它。如果你知道它在哪里,你能指出我吗? – mrwaim