使用 Azure Powershell Function App 修改存储帐户中的文件
Modify file in storage account using Azure Powershell Function App
我正在使用逻辑应用程序将 CSV 文件转换为 XML 文件,但目前输出全部在一行中。所以我想也许我可以创建一个函数应用程序来打开文件,[xml] 它并保存文件,希望它能美化它,基本上是这样的:
$xml = [xml] (gc "filelocation")
$xml.Save("filelocation")
当我创建函数应用程序(称为 ParseXML)时,它已经具有默认的 powershell 代码:
using namespace System.Net
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
# Write to the Azure Functions log stream.
Write-Host "PowerShell HTTP trigger function processed a request."
# Interact with query parameters or the body of the request.
$name = $Request.Query.Name
if (-not $name) {
$name = $Request.Body.Name
}
$body = "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
if ($name) {
$body = "Hello, $name. This HTTP triggered function executed successfully."
}
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $body
})
如何修改此代码和逻辑应用程序以尝试做我想做的事,我想我首先需要在 powershell 脚本中创建参数来定义我的文件的位置和名称,我可以得到从逻辑应用程序:
这不再是必需的,因为事实证明逻辑应用程序中有一个默认情况下未设置的额外设置,只需设置 Apply XSLT 输出属性即可完成工作:
我正在使用逻辑应用程序将 CSV 文件转换为 XML 文件,但目前输出全部在一行中。所以我想也许我可以创建一个函数应用程序来打开文件,[xml] 它并保存文件,希望它能美化它,基本上是这样的:
$xml = [xml] (gc "filelocation")
$xml.Save("filelocation")
当我创建函数应用程序(称为 ParseXML)时,它已经具有默认的 powershell 代码:
using namespace System.Net
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
# Write to the Azure Functions log stream.
Write-Host "PowerShell HTTP trigger function processed a request."
# Interact with query parameters or the body of the request.
$name = $Request.Query.Name
if (-not $name) {
$name = $Request.Body.Name
}
$body = "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
if ($name) {
$body = "Hello, $name. This HTTP triggered function executed successfully."
}
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $body
})
如何修改此代码和逻辑应用程序以尝试做我想做的事,我想我首先需要在 powershell 脚本中创建参数来定义我的文件的位置和名称,我可以得到从逻辑应用程序:
这不再是必需的,因为事实证明逻辑应用程序中有一个默认情况下未设置的额外设置,只需设置 Apply XSLT 输出属性即可完成工作: