Azure Функции - New-AzContainerGroup: ссылка на объект не установлена ​​для экземпляра объекта - PullRequest
0 голосов
/ 01 апреля 2020

Я пытался создать Azure Экземпляр контейнера, используя активированную httphell PowerShell Azure Функция.

Я написал некоторый код, и он работает ... вроде

using namespace System.Net

param($Request, $TriggerMetadata)

$appId = "appID"
$appPassword = "appPassword"
$secpasswd = ConvertTo-SecureString $appPassword -AsPlainText -Force
$mycred = New-Object System.Management.Automation.PSCredential ($appId, $secpasswd)

$status = [HttpStatusCode]::OK
New-AzContainerGroup -ResourceGroupName "test" -Name "testName" `
    -Image "imageName" `
    -RegistryCredential $mycred `
    -RestartPolicy Never

Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
    StatusCode = $status
    Body = $body
})

Когда я достигаю конечной точки, я всегда получаю 500 кодов ответа, но по какой-то причине экземпляр контейнера создается в любом случае, и он работает. Вот ошибка терминала:

Executed 'Functions.testFuntion' (Failed, Id=240084c5-6aa2-4207-ae84-66f85a03504b)
System.Private.CoreLib: Exception while executing function: Functions.testFuntion. 
System.Private.CoreLib: Result: Failure
Exception: Object reference not set to an instance of an object.
Stack: 
at 
Microsoft.Azure.Functions.PowerShellWorker.Utility.TypeExtensions.
DeriveContentType(HttpResponseContext  
Microsoft.Azure.Functions.PowerShellWorker.Utility.TypeExtensions.DeriveContentType
(HttpResponseContext httpResponseContext, RpcHttp rpcHttp) in C:\projects\azure-functions-powershell- 
worker\src\Utility\TypeExtensions.cs:line 196
at 
Microsoft.Azure.Functions.PowerShellWorker.Utility.TypeExtensions.ToRpcHttp(HttpResponseContext 
httpResponseContext) in C:\projects\azure-functions-powershell- 
worker\src\Utility\TypeExtensions.cs:line 188
at 
Microsoft.Azure.Functions.PowerShellWorker.Utility.TypeExtensions.ToTypedData(Object value) in 
C:\projects\azure-functions-powershell-worker\src\Utility\TypeExtensions.cs:line 242
at 
Microsoft.Azure.Functions.PowerShellWorker.RequestProcessor.BindOutputFromResult(InvocationResponse 
response, AzFunctionInfo functionInfo, Hashtable results) in C:\projects\azure-functions-powershell- 
worker\src\RequestProcessor.cs:line 465
at
Microsoft.Azure.Functions.PowerShellWorker.RequestProcessor.ProcessInvocationRequestImpl
(StreamingMessage request, AzFunctionInfo functionInfo, PowerShellManager psManager,
FunctionInvocationPerformanceStopwatch stopwatch)
in C:\projects\azure-functions-powershell-worker\src\RequestProcessor.cs:line 305.

Это то, о чем мне следует беспокоиться? Несмотря на то, что я получил 500 ответов, похоже, все работает.

...