Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database 在Azure上检索照片_Database_Azure_Powershell_Server - Fatal编程技术网

Database 在Azure上检索照片

Database 在Azure上检索照片,database,azure,powershell,server,Database,Azure,Powershell,Server,我在Azure上有一项任务要做 在Azure上,我需要使用以下链接获取照片: 我得到了这份文件 目标是创建一个powershell脚本,允许您使用Azure检索此路径中的照片 我没有登录的密钥,只有登录用户和密码 我认为我的连接模式是: Login-AzureRmAccount $SourceResourceGroupName = "..."; $SourceServerName = "..."; $Database = "..."; $ServerInstance = "..."; $

我在Azure上有一项任务要做

在Azure上,我需要使用以下链接获取照片:

我得到了这份文件

目标是创建一个powershell脚本,允许您使用Azure检索此路径中的照片

我没有登录的密钥,只有登录用户和密码

我认为我的连接模式是:

Login-AzureRmAccount

$SourceResourceGroupName = "...";
$SourceServerName = "...";
$Database = "...";
$ServerInstance =  "...";
$Username = "...";
$Password = "..."

$con.ConnectionString = "Server=$ServerInstance;
                        uid=$Username; 
                        pwd=$Password;
                        Database=$Database;
                        Integrated Security=False;"         
$con.Open();

提前感谢您的帮助。

您似乎正在尝试从下载文件。它不像数据库那样工作

正如在评论中解释的,Azure存储支持对称密钥和Azure AD身份验证。或者,您可以将文件设置为public,以便直接访问

您使用了
Login AzureRmAccount
命令。因此,您应该能够下载一个blob,如下所示:

$ResourceGroup = "Jack"
$StorageAccount = "storagetest789"
$Container = "function"
Set-AzureRmCurrentStorageAccount -ResourceGroupName $ResourceGroup -Name $StorageAccount
Get-AzureStorageBlobContent -Container $Container -Blob "User1.txt" -Destination 'D:\'
$UserName = '.......';
$Password = '.........';
$Secret = ConvertTo-SecureString -String $Password -AsPlainText -Force;
$PsCred = New-Object System.Management.Automation.PSCredential($UserName, $Secret);
Login-AzureRmAccount -Credential $PsCred;

$ResourceGroup = '';
$URL = 'https://{storage_account_name}.blob.core.windows.net/{container_name}/{blob_name}';

$StorageAccount = $URL.Substring('https://'.Length,$URL.IndexOf(".")-'https://'.Length);
$Path = $URL.Substring($URL.IndexOf('.blob.core.windows.net/')+'.blob.core.windows.net/'.Length);
$Container = $Path.Substring(0,$Path.IndexOf('/'));
$Blob = $Path.Substring($Container.Length+1);

Set-AzCurrentStorageAccount -ResourceGroupName $ResourceGroup -Name $StorageAccount;
Get-AzStorageBlobContent -Container $Container -Blob $Blob -Destination 'D:\';

更新

正常的存储blob URL应该如下所示:
https://{storage\u account\u name}.blob.core.windows.net/{container\u name}/{blob\u name}

因此,您可能会得到如下所示的
$StorageAccount
$Container
$Blob

$ResourceGroup = "Jack"
$StorageAccount = "storagetest789"
$Container = "function"
Set-AzureRmCurrentStorageAccount -ResourceGroupName $ResourceGroup -Name $StorageAccount
Get-AzureStorageBlobContent -Container $Container -Blob "User1.txt" -Destination 'D:\'
$UserName = '.......';
$Password = '.........';
$Secret = ConvertTo-SecureString -String $Password -AsPlainText -Force;
$PsCred = New-Object System.Management.Automation.PSCredential($UserName, $Secret);
Login-AzureRmAccount -Credential $PsCred;

$ResourceGroup = '';
$URL = 'https://{storage_account_name}.blob.core.windows.net/{container_name}/{blob_name}';

$StorageAccount = $URL.Substring('https://'.Length,$URL.IndexOf(".")-'https://'.Length);
$Path = $URL.Substring($URL.IndexOf('.blob.core.windows.net/')+'.blob.core.windows.net/'.Length);
$Container = $Path.Substring(0,$Path.IndexOf('/'));
$Blob = $Path.Substring($Container.Length+1);

Set-AzCurrentStorageAccount -ResourceGroupName $ResourceGroup -Name $StorageAccount;
Get-AzStorageBlobContent -Container $Container -Blob $Blob -Destination 'D:\';

这是什么意思?“我没有登录密钥,只有登录用户和密码。”Blob存储通过对称密钥、AzureAD或根本不进行身份验证(对于公共Blob)。没有用户名/密码基本身份验证可能没有用户/密码基本身份验证。我只想通过Azure下载以下路径中此链接的图像文件:找到一个可能满足您要求的可选解决方案。请你检查一下好吗?