简体   繁体   English

写入 Azure 存储 Blob (PowerShell)

[英]Write to Azure Storage Blob (PowerShell)

I'm trying to write to an Azure Storage blob using a PowerShell Azure Function.我正在尝试使用 PowerShell Azure Z86408593C34AF72FDDZ0B8 写入 Azure 存储 blob。 I can't find any documentation online for accomplishing this for PowerShell only C#.我在网上找不到任何文档来为 PowerShell 仅 C# 完成此操作。 This is what I have这就是我所拥有的

using namespace System.Net

# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)

# Interact with query parameters or the body of the request.
$var1 = $Request.Query.var1
if (-not $var1) {
    $var1 = $Request.Body.var1
}

$body = "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."

if ($var1) {
    $body = "Variable 1: $var1"
}

outputBlob.WriteLine("test")


# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
    StatusCode = [HttpStatusCode]::OK
    Body = $Body
})

When I execute function I get当我执行 function 我得到

ERROR: outputBlob.WriteLine: The term 'outputBlob.WriteLine' is not recognized as the name of a cmdlet, function, script file, or operable program.

Azure Blob Stroage has been added as Output Integration. Azure Blob Stroage 已添加为 Output 集成。

Binding Type: Azure Blob Storage
Blob parameter name: outputBlob
Path: {function}/{rand-guid}
Storage Account Connection: myStorageAccount

Any help is appreciated!任何帮助表示赞赏!

Figured it out.弄清楚了。 I need Push-OutputBinding.我需要推送输出绑定。

This worked for me这对我有用

Push-OutputBinding -Name outputBlob -Value 'test' Push-OutputBinding -Name outputBlob -Value 'test'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM