我想在函数应用中部署 C# azure 计时器触发函数。我的 Azure 存储容器中有 zip 文件。现在我想使用该 zip 在函数应用程序中部署计时器触发函数。这个过程需要通过调用rest API来完成。这样我们就可以动态部署尽可能多的功能。
我已经通过powershell脚本尝试过了。但由于某些原因,在 azure runbook 中,某些 powershell 命令不受支持。所以我想通过 Rest API 使其成为可能。
最佳答案
I have tried it by powershell script. But for some reason in azure runbook, some powershell command is not supported.
作为替代方法,我已经使用 Azure PowerShell 尝试过此操作,并且可以使用 Invoke-WebRequest
来实现此目的,它将内容下载到本地文件夹,然后使用 Publish- AzWebapp
从上传的 .zip 文件推送部署。出于演示目的,我使用以下脚本部署了 3 个函数应用程序。
$context = New-AzStorageContext -StorageAccountName "<STORAGE_ACCOUNT_NAME>" -StorageAccountKey "<STORAGE_ACCOUNT_KEY>"
$a = Get-AzStorageBlob -Context $context -Container "<CONTAINER_NAME>"
for($i=0; $i -le $a.Count-1; $i++)
{
$Uri = "https://<STORAGE_ACCOUNT_NAME>.blob.core.windows.net/<CONTAINER_NAME>/"+$a[$i].Name
$Outfile = "/home/*****/"+$a[$i].Name
Invoke-WebRequest -Uri $Uri -OutFile $Outfile
Publish-AzWebapp -ResourceGroupName <RESOURCE_GROUP> -Name $a[$i].Name.substring(0, ($a[$i].Name).IndexOf(".")) -ArchivePath $a[$i].Name
}
结果:
关于c# - 如何通过API通过blob zip文件动态部署azure功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75035020/