[英]How to use .NET Core 3.x with Azure Function App Powershell Runtime?
我使用模板中的以下資源創建了一個新的 Function 應用程序:
{
"apiVersion": "2015-08-01",
"type": "Microsoft.Web/sites",
"name": "[parameters('caAppName')]",
"location": "[parameters('location')]",
"kind": "functionapp",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
],
"identity": {
"type": "SystemAssigned"
},
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]",
"siteConfig": {
"appSettings": [
{
"name": "AzureWebJobsStorage",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
},
{
"name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
},
{
"name": "WEBSITE_CONTENTSHARE",
"value": "[toLower(parameters('caAppName'))]"
},
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "~3"
},
{
"name": "WEBSITE_NODE_DEFAULT_VERSION",
"value": "~10"
},
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference(resourceId('microsoft.insights/components/', variables('applicationInsightsName')), '2015-05-01').InstrumentationKey]"
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "powershell"
},
]
}
}
我在門戶Write-Host "$([System.Security.Cryptography.X509Certificates.X509Certificate2].Assembly.Location)"
的 function 應用程序中運行以下代碼
我得到 D:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.2.8\System.Security.Cryptography.X509Certificates.dll
但如果我使用 Function App 控制台:
D:\Program Files\dotnet\shared\Microsoft.NETCore.App> ls
2.2.8
2.2.8.installed
3.0.3
3.0.3.installed
3.1.3
3.1.3.installed
所以 3.1.3 存在,但 function 沒有與它一起執行。
我什至只注意到,因為我嘗試使用 System.Security.Cryptography.PbeParameters 並且缺少類型(以及其他一些 AsymmetricAlgorithm 的東西)
我該如何解決這個問題?
The .NET Core version is determined by the Azure PowerShell worker, which depends on the PowerShell SDK. PowerShell 6 is the only version currently available in Azure Functions, and it depends on .NET Core 2.x, this is why your PowerShell Function is executed in this context. 為了使用 .NET Core 3.x,您有以下選項:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.