我在 Powershell 上有一个 BlobTrigger azure 函数。我正在尝试获取blob uri,以便使用以下脚本从此 vhd blob 创建托管磁盘:
$diskConfig = New-AzDiskConfig -AccountType $storageType -Location $location -CreateOption Import -StorageAccountId $storageAccountId -SourceUri $sourceVHDURI
New-AzDisk -Disk $diskConfig -ResourceGroupName $resourceGroupName -DiskName $diskName
从云 shell 中,我可以使用以下代码获取 uri:
$(Get-AzureStorageBlob -Blob myblob -Container 'mycontainer' -Context $StorageContext).ICloudBlob.uri.AbsoluteUri
但是使用 Azure Functions,我不能。我的 AF 代码如下:
# 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! Uri: $($InputBlob.ICloudBlob.uri.AbsoluteUri)"
$InputBlob.ICloudBlob.uri.AbsoluteUri
返回空。我查过blob documentation ,但找不到任何解决方案。
你有什么建议吗?
最佳答案
您可以尝试 $TriggerMetadata.Name
获取名称,或按照 @Anatoli Beliaev 的建议尝试 $TriggerMetadata.Uri
。
作为替代方案,您可以尝试这样的操作(未经测试):
param([Microsoft.Azure.Storage.Blob.ICloudBlob] $myBlob)
这至少在 .NET 中有效,并且文档看起来它的行为可能类似。
For certain bindings like the blob binding, you're able to specify the type of the parameter.
For example, to have data from Blob storage supplied as a string, add the following type cast to my param block:
param([string] $myBlob)
关于azure - 如何使用 Powershell 从 Azure Functions 获取 Azure Blob URI?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63637360/