Azure函数应用程序Blob触发器,读取CSV数据
我正在编写一个Azure Function应用程序,当前当一个.csv文件上载到blob存储时,它会触发。我正在尝试读取此.csv文件/blob中的数据。以下内容似乎不起作用,我正在使用powershell。任何帮助或指导都将不胜感激Azure函数应用程序Blob触发器,读取CSV数据,azure,azure-powershell,azure-function-app,Azure,Azure Powershell,Azure Function App,我正在编写一个Azure Function应用程序,当前当一个.csv文件上载到blob存储时,它会触发。我正在尝试读取此.csv文件/blob中的数据。以下内容似乎不起作用,我正在使用powershell。任何帮助或指导都将不胜感激 #Input parameters are parsed in via param block param([byte[]] $InputBlob, $TriggerMetadata) #write out the blob name and size to t
#Input parameters are parsed in via param block
param([byte[]] $InputBlob, $TriggerMetadata)
#write out the blob name and size to the information log
Write-Host "Powershell Blob Trigger Function Processed! blob Name: $($TriggerMetadata.Name) Size: $($InputBlob.Length) bytes"
import-csv $InputBlob
foreach( $user in $users)
{
$UPN = ($users.UserPrincipalName)
write-host $UPN
}
试试这个:
# Input bindings are passed in via param block.
param([byte[]] $InputBlob, $TriggerMetadata)
# Write out the blob name and size to the information log.
Write-Host "PowerShell Blob trigger function Processed blob! Name: $($TriggerMetadata.Name) Size: $($InputBlob.Length) bytes"
$TempFile = New-TemporaryFile
[io.file]::WriteAllBytes($TempFile.FullName, $InputBlob)
$dataSet = Import-Csv $TempFile.FullName
foreach($data in $dataSet){
$data.Username
}
这是用于测试的.CSV文件的数据:
Username, Identifier,First name,Last name
booker12,9012,Rachel,Booker
grey07,2070,Laura,Grey
johnson81,4081,Craig,Johnson
jenkins46,9346,Mary,Jenkins
smith79,5079,Jamie,Smith
结果:
非常感谢Stanley Gong,他将尝试此功能并让您知道:)