gpt4 book ai didi

php - php 中 Windows Azure 的连接字符串

转载 作者:行者123 更新时间:2023-12-03 00:52:21 24 4
gpt4 key购买 nike

我有这样的连接语句来连接我在 Windows Azure 中创建的 Blob 存储。

$connectionString = 'DefaultEndpointsProtocol=http;AccountName=<accountname>;AccountKey=<secret key>';
$echo "1";

$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
$echo "2";

当我输入此内容时,会写入“1”,但不会写入“2”。

这是否意味着 $blobRestProxy 不起作用?

我尝试在 Blob 存储中创建一个容器,但失败了。

如何解决这个问题?

谢谢。

更新:

这是显示public_html内部的图片的链接

http://picpaste.com/2-FjXF4Kpo.jpg

这些是显示网站文件夹内部的图片链接

http://picpaste.com/3-CReA0E72.jpg

http://picpaste.com/4-Tjvv3Br7.jpg

<!DOCTYPE HTML>
<html lang="en">
<head>
<title>more</title>
<meta charset="utf-8">
<meta name="description" content="Description goes here">
<meta name="keywords" content="Keywords goes here">

<!--<link rel="stylesheet" href="css/style.css" type="text/css" media="screen">
<link rel="stylesheet" href="css/preview.css" type="text/css">
<script type="text/javascript" src="js/main.js"></script>-->

<!--[if lt IE 8]>
<div style=' clear: both; text-align:center; position: relative;z-index:100;'>
<a href="http://windows.microsoft.com/en-US/internet-explorer/products/ie/home?ocid=ie6_countdown_bannercode"><img src="http://storage.ie6countdown.com/assets/100/images/banners/warning_bar_0000_us.jpg" border="0" height="42" width="820" alt="You are using an outdated browser. For a faster, safer browsing experience, upgrade for free today." /></a>
</div>
<![endif]-->

</head>
<body>
<div id="wrapper">
<section>
<div class="dynamicContent">
<!--content -->
<?php
$server = "tcp:t656iqht6v.database.windows.net,1433";
$user = "saitarslanboun@t656iqht6v";
$pwd = "Uj8PfOf4";
$db = "misbounstashnew_db";

$conn = sqlsrv_connect($server, array("UID"=>$user, "PWD"=>$pwd, "Database"=>$db));

if($conn === false){
die(print_r(sqlsrv_errors()));
}
?>


<?php
echo '<h3>'.$_GET['course'].'</h3>';
?>

<?php
echo "1";
require_once 'WindowsAzure.php';
echo "2";
use WindowsAzure\Common\ServicesBuilder;
echo "3";
use WindowsAzure\Blob\Models\CreateContainerOptions;
echo "4";
use WindowsAzure\Blob\Models\PublicAccessType;
echo "5";
use WindowsAzure\Common\ServiceException;
echo "6";
$connectionString = 'DefaultEndpointsProtocol=http;AccountName=misbounstashnew;AccountKey=o5uC6pxyUuLTbg4MOTunrzvqw0YzzcP90yyJuNjoue8PT2Rx8eIEZ/ZE1dnqMdsv1Ouvp35Qph5TjmCNiBya3A==';
echo "7";
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
echo "8";
if ($blobRestProxy) {echo "success_blobRestProxy";}
if (!$blobRestProxy) {echo "fail_blobRestProxy";}
$createContainerOptions = new CreateContainerOptions();

try
{
// Create container.
$blobRestProxy->createContainer("mycontainer", $createContainerOptions);
}
catch(ServiceException $e)
{
// Handle exception based on error codes and messages.
// Error codes and messages are here:
// http://msdn.microsoft.com/en-us/library/windowsazure/dd179439.aspx
$code = $e->getCode();
$error_message = $e->getMessage();
echo $code.": ".$error_message."<br />";
}

?>

<!--content end -->
</div>
</section>
</div>
<script>
$("a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'normal',theme:'dark',social_tools:false,allow_resize: true,default_width: 500,default_height: 344});
</script>
</body>
</html>

最佳答案

从您的代码中不清楚您是否导入了适当的 Azure 库(不确定这是否是正确的术语)。我尝试了类似以下的方法,它对我有用:

<?php
require_once 'WindowsAzure.php';
use WindowsAzure\Common\ServicesBuilder;
try {

$connectionString = 'DefaultEndpointsProtocol=https;AccountName=account name;AccountKey=account key';
echo "1";

$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
echo "2";


} catch(ServiceException $e){
// Handle exception based on error codes and messages.
// Error codes and messages are here:
// http://msdn.microsoft.com/en-us/library/windowsazure/dd179446.aspx
$code = $e->getCode();
$error_message = $e->getMessage();
echo $code.": ".$error_message."<br />";
}
?>

我的计算机上的屏幕截图:

enter image description here

关于php - php 中 Windows Azure 的连接字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23978445/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com