Reputation: 133
I am trying to create a PowerShell function app that contains a function - a timer trigger that can start and stop another function app at a specific time.
I was motivated to try out the personal project after coming across this blog about automating start and stop time for Virtual Machine on Azure using timer trigger function.
The issue is from the Az.Functions module which I need to run a line of code
$fnapps = Get-AzFunctionApp
It runs well for the first time (No known or seen error in the logs and the output is correct). But at the second instance and other instances of running on the CRON schedule I set, I see this exception error from the module.
The error code is:
You cannot call a method on a null-valued expression.Exception :Type : System.Management.Automation.RuntimeExceptionErrorRecord :Exception :Type : System.Management.Automation.ParentContainsErrorRecordExceptionMessage : You cannot call a method on a null-valued expression.HResult : -2146233087CategoryInfo : InvalidOperation: (:) [], ParentContainsErrorRecordExceptionFullyQualifiedErrorId : InvokeMethodOnNullInvocationInfo :ScriptLineNumber : 450OffsetInLine : 24HistoryId : -1ScriptName :
I want to know if there's something I'm missing about Az.Functions Module.
Also want to know if what I am trying to do is possible.
Note: I've confirmed the modules are installed correctly, and no issue in the other parts of the code.
Thanks.
Upvotes: 0
Views: 575
Reputation: 2440
Thankyou Anand-Sowmithiran. Posting your suggestion as an answer so that it will be helpful for other community members who face similar kind of issues.
As per the document you need to use the context across sessions
Below is the sample Save-AzContext
syntax
Save-AzContext
[[-Profile] <AzureRmProfile>]
[-Path] <String>
[-Force]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
for further information check the az.accounts module
Upvotes: 1