Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.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/3/flash/4.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触发器,读取CSV数据_Azure_Azure Powershell_Azure Function App - Fatal编程技术网

Azure函数应用程序Blob触发器,读取CSV数据

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

我正在编写一个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 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,他将尝试此功能并让您知道:)