Service fabric deployment "You cannot call a method on a null-valued expression"

Lukasz's Avatar

Lukasz

30 Oct, 2017 04:50 PM

Hi There,
We get above error during deployment to remote azure service fabric cluster.
I'm attaching the snippet of the logs from deployment below, does anyone experienced similar issues?
We've can confirm that both service fabric sdk 2.7.221 and powershell 5.1 are installed (windows server 2016 standard) and we've enabled PowerShell script execution as per instructions here

LOG:

16:19:03   Verbose  |       ----                           -----
16:19:03   Verbose  |       PSVersion                      5.1.14393.1770
16:19:03   Verbose  |       PSEdition                      Desktop
16:19:03   Verbose  |       PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
16:19:03   Verbose  |       BuildVersion                   10.0.14393.1770
16:19:03   Verbose  |       CLRVersion                     4.0.30319.42000
16:19:03   Verbose  |       WSManStackVersion              3.0
16:19:03   Verbose  |       PSRemotingProtocolVersion      2.3
16:19:03   Verbose  |       SerializationVersion           1.1.0.1
16:19:04   Verbose  |       PowerShell Environment Information:
16:19:04   Verbose  |       OperatingSystem: Microsoft Windows NT 10.0.14393.0
16:19:04   Verbose  |       OsBitVersion: x64
16:19:04   Verbose  |       Is64BitProcess: True
16:19:04   Verbose  |       CurrentUser: DOMAIN\DEV-SYS
16:19:04   Verbose  |       MachineName: DEV-OD
16:19:04   Verbose  |       ProcessorCount: 8
16:19:04   Verbose  |       CurrentDirectory: C:\Octopus\Work\20171030161837-508-2\staging
16:19:04   Verbose  |       CurrentLocation: C:\Octopus\Work\20171030161837-508-2\staging
16:19:04   Verbose  |       TempDirectory: C:\Users\DEV-SYS\AppData\Local\Temp\
16:19:04   Verbose  |       HostProcessName: powershell
16:19:04   Verbose  |       TotalPhysicalMemory: 4092956 KB
16:19:04   Verbose  |       AvailablePhysicalMemory: 1262324 KB
16:19:04   Verbose  |       Connecting to Service Fabric unsecurely.
16:19:04   Verbose  |       Authenticating with Service Fabric.
16:19:04   Verbose  |       Using ConnectionParameters:
16:19:04   Verbose  |       ConnectionEndpoint=[REMOVED].cloudapp.azure.com:19000
16:19:06   Verbose  |       Invoking target script "C:\Octopus\Work\20171030161837-508-2\staging\DeployToServiceFabric.ps1" with  parameters.
16:19:07   Error    |       Invoke-Expression : You cannot call a method on a null-valued expression.
16:19:07   Error    |       At C:\Octopus\Work\20171030161837-508-2\staging\Octopus.AzureServiceFabricContext.ps1:227 char:1
16:19:07   Error    |       + Invoke-Expression ". $OctopusFabricTargetScript $OctopusFabricTargetS ...
16:19:07   Error    |       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16:19:07   Error    |       + CategoryInfo          : InvalidOperation: (:) [Invoke-Expression], RuntimeException
16:19:07   Error    |       + FullyQualifiedErrorId : InvokeMethodOnNull,Microsoft.PowerShell.Commands.InvokeExpressionCommand
16:19:07   Error    |       Script 'C:\Octopus\Work\20171030161837-508-2\staging\DeployToServiceFabric.ps1' returned non-zero exit code: 1
16:19:07   Error    |       Running rollback conventions...
16:19:07   Error    |       Script 'C:\Octopus\Work\20171030161837-508-2\staging\DeployToServiceFabric.ps1' returned non-zero exit code: 1
16:19:08   Verbose  |       Updating manifest with output variables
16:19:08   Verbose  |       Updating manifest with action evaluated variables
16:19:08   Error    |       The remote script failed with exit code 1
  1. 1 Posted by wez.nagwama on 31 Oct, 2017 02:17 AM

    wez.nagwama's Avatar

    Hey mate,

    Anecdotally, when this happens to me, it's because a variable isn't resolving to what you expect. 99 times out of 100.

    There's 2 things you can do to figure it out:

    • Enable variable logging

    • Create a step that outputs all your variables as a PS script

    1. https://octopus.com/docs/how-to/debug-problems-with-octopus-variables -> configure the 2x octopus variables.

    2. Create a process step, to run a powershell script, which simply outputs all your variables. See if they match.

  2. Support Staff 2 Posted by Mark Siedle on 31 Oct, 2017 02:38 AM

    Mark Siedle's Avatar

    Hi Lukasz,

    Thanks for getting in touch and thanks for the log.

    That's a interesting one. Based on your log and the output from this line in Calamari, it looks like the step parameters are not being passed down to that script correctly.

    We definitely agree with the advice from Wez. If you have variable substitution happening in your step, enabling print variables and running a Service Fabric PowerShell step against your cluster may help figure out what's not resolving.

    If that doesn't help, can you please send us a screenshot of your step (and any variables you have setup for substitution), as well as a full task log for the failed task (after print variables has been enabled) and we'll see if we can reproduce.

    Thanks
    Mark

  3. 3 Posted by Lukasz on 31 Oct, 2017 10:06 AM

    Lukasz's Avatar

    Hi Guys,
    Currently we do not have any variable substitution enabled (nor any other features yet)
    Here are screenshots of our step details:

    1. https://cl.ly/nQKm
    2. https://cl.ly/nQ67

    We previously had 1 variable configured called "SfClientCert" which consisted of
    self-signed certificate we uploaded to OD and used for connecting to dev secured sf cluster, this has now been removed and reconfigured for connect to unsecured cluster - just to eliminate possible issues with that...

    The only ones configured now are:
    * OctopusPrintEvaluatedVariables = True * OctopusPrintVariables = True

    Release screenshot: https://cl.ly/nPUa

    I've attached full log of failed task, looking forward to hear from you soon

    Thanks
    Lukasz

  4. Support Staff 4 Posted by Mark Siedle on 01 Nov, 2017 04:57 AM

    Mark Siedle's Avatar

    Hi Lukasz,

    Thanks for the additional information and logs.

    From your screenshots, you appear to be referencing the ApplicationManifest.xml file instead of the publish profile file (typically located at `PublishProfiles\Cloud.xml'), which will cause this error because it's unable to find the parameters from that other xml file.

    Also, could you confirm if your SF package is structured correctly for use with Octopus (as per the example structure in this documentation)?

    For SF packages to work in Octopus, they need to be structured a certain way (because when deploying straight from Visual Studio, the profile and parameters files are referenced from the source code, but when deploying through Octopus, they must be included in the NuGet/Zip package so they are available at deployment time).

    If you haven't already, we recommend reading through that whole packaging guide to make sure your package includes all the files/folders needed for SF deployments with Octopus, then you can address that publish profile file correctly and you should be good to go.

    Let me know how you go.

    Thanks
    Mark

  5. 5 Posted by Lukasz on 09 Nov, 2017 01:18 PM

    Lukasz's Avatar

    Hi Mark, thanks for the tip, it was indeed misconfiguration from our end, pointing it into correct publish profile file solves the issue, however it appears that variables from ApplicationParameters/Cloud.Production.xml which is referenced by PublishProfiles/Cloud.Production.xml we use does not appear to be substituted, may I assume that as long as param name match the OD variable substitution will occur?

    Based on the docs any *.config and *.xml are subject for substitution by default.

    Strangely we can see this in the logs:

    12:13:49   Verbose  |       Performing variable substitution on 'C:\Octopus\Work\20171109121323-1080-33\staging\PublishProfiles\Cloud.Production.xml'
    12:13:49   Verbose  |       Performing variable substitution on 'C:\Octopus\Work\20171109121323-1080-33\staging\ApplicationParameters\Cloud.Production.xml'
    

    but when we check service fabric explorer application details variables are still taken from ApplicationParameters\Cloud.Production.xml instead of being overriden by OD variables defined.

    I hope this makes sense
    Lukasz

  6. Support Staff 6 Posted by Mark Siedle on 10 Nov, 2017 12:30 AM

    Mark Siedle's Avatar

    Hi Lukasz,

    Yes, those files should have their variables substituted (and those logs indicate it went through the variable substitution method in Calamari as expected (eg. this guy).

    Would you be able to send us a copy of your PublishProfiles and ApplicationParameters (showing the variable substitution syntax you're using), and a screenshot showing your project's variables that should be substituted, and we'll try and reproduce to see what's going wrong (note: you can mark this thread as private, so only Octopus staff will see the contents of your files if that helps).

    Thanks
    Mark

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac