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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.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
从Azure Blob检索文件内容_Azure_Email_Azure Storage Blobs_Azure Powershell - Fatal编程技术网

从Azure Blob检索文件内容

从Azure Blob检索文件内容,azure,email,azure-storage-blobs,azure-powershell,Azure,Email,Azure Storage Blobs,Azure Powershell,我想在Azure AA中使用sendgrid发送报告。问题是,我被迫在脚本中以明文形式使用apikey传递,我显然希望不惜任何代价避免这种情况。我想我可以用apikey将文件保存在txt文件中某个特定容器中隐藏的Azure存储位置。我想要实现的是这样的目标: (...) $HTMLDetails = @{ Title = $Subject Head = $CSS } $Username ="username" $apikey = get-storageblobfilecontent -con

我想在Azure AA中使用sendgrid发送报告。问题是,我被迫在脚本中以明文形式使用apikey传递,我显然希望不惜任何代价避免这种情况。我想我可以用apikey将文件保存在txt文件中某个特定容器中隐藏的Azure存储位置。我想要实现的是这样的目标:

(...)
$HTMLDetails = @{
Title = $Subject
Head = $CSS
}

$Username ="username"

$apikey = get-storageblobfilecontent -container x -blob y -file z | Out-String

$Password = ConvertTo-SecureString $apikey -Force

$Credential = New-Object System.Management.Automation.PSCredential $Username, $Password

$Splat = @{
    To          =...
    Cc          =...
    Body       ="$(import-csv -delimiter ";" DiskReport.csv | ConvertTo-Html @HTMLDetails)"
    Subject     = $Subject
    smtpServer  ="smtp.sendgrid.net"
    From        ="AzureReporting@azure.com" 
    BodyAsHtml  = $True
    }

Send-MailMessage @Splat -Credential $Credential -Usessl -Port xxx

真的有可能吗?无法从VM检索文件内容,因为Runbook脚本无法直接访问VM。

您可以在Runbook中使用内置的Get-AutomationPSCredential cmdlet。在自动化帐户级别,您可以配置安全存储的凭据,然后将它们带到您的runbook中(它的配置使输出永远不能以明文形式写入主机)

在AA上的凭据选项卡内创建凭据(例如“MyApiKey”)。在脚本内部,使用以下命令
$apiKey=Get AutomationPSCredential MyApiKey

然后可以将其传递到
$Credential
对象中


有关该实用程序的更多信息,请参阅。

我不太确定您的要求。如果是关于隐藏存储凭据,您可以将凭据存储在类似Azure KeyVault的内容中。或者利用SAS提供对特定容器或blob的临时只读访问,而不必担心将存储帐户密钥传递到任何地方。这是从Azure自动化帐户运行的吗?@tedsmitt是的,这更好!谢谢,没问题!很乐意帮忙。如果您对解决方案感到满意,您是否可以标记此问题是否已得到回答?谢谢:-)