无法从 Azure 函数连接到存储帐户。需要通过 Azure 函数将文件存储在存储帐户中

时间:2021-07-18 10:47:51

标签: azure azure-functions

要求是通过 PowerShell 中的 Azure Functions 将文件存储在存储帐户中。 下面是代码

$todaydate = Get-Date -Format MM-dd-yy 
$LogFull = "AzureScan-$todaydate.log" 
$LogItem = New-Item -ItemType File -Name $LogFull

"  Text to write" | Out-File -FilePath $LogFull -Append

#Get key to storage account
$acctKey = (Get-AzureRmStorageAccountKey -Name amsaccount1 - 
ResourceGroupName RGAMS).Value[0]

#Map to the reports BLOB context
$storageContext = New-AzureStorageContext -StorageAccountName 
"amsaccount1" -StorageAccountKey $acctKey

#Copy the file to the storage account
Set-AzureStorageBlobContent -File $LogFull -Container "files" -BlobType 
"Block" -Context $storageContext -Verbose

0 个答案:

没有答案