Issues deploying .net core site via IIS

Errors13's Avatar

Errors13

31 Jan, 2018 04:05 AM

I am able to deploy the nuget packages, retrieved from the teamcity nuget feed, however I can't seem to deploy the website as the following error keeps occurring. IIS is running and installed on the server.

Deploying package 'C:\Octopus\Files\ppp.16.nupkg-d2c7b7b4-f1e0-4fa5-8174-4b60518e92ea' to machine 'https://10.44.130.72:10933/'
January 31st 2018 16:57:30Info
Deploying package: C:\Octopus\Files\ppp.16.nupkg-d2c7b7b4-f1e0-4fa5-8174-4b60518e92ea
January 31st 2018 16:57:38Info
Making sure a Website "plzwork" is configured in IIS...
January 31st 2018 16:57:39Error
foreach-object : You cannot call a method on a null-valued expression.
January 31st 2018 16:57:39Error
At C:\Octopus\Applications\PGSTrial1\ppp\16_60\Octopus
January 31st 2018 16:57:39Error
.Features.IISWebSite_BeforePostDeploy.ps1:464 char:59
January 31st 2018 16:57:39Error
+ ... indings | where-object { $_.protocol -eq "https" } | foreach-object {
January 31st 2018 16:57:39Error
+ ~~~~~~~~~~~~~~~~
January 31st 2018 16:57:39Error
    + CategoryInfo : InvalidOperation: (:) [ForEach-Object], RuntimeE
January 31st 2018 16:57:39Error
   xception
January 31st 2018 16:57:39Error
    + FullyQualifiedErrorId : InvokeMethodOnNull,Microsoft.PowerShell.Commands
January 31st 2018 16:57:39Error
   .ForEachObjectCommand
January 31st 2018 16:57:39Error
 
January 31st 2018 16:57:39Error
Script 'C:\Octopus\Applications\PGSTrial1\ppp\16_60\Octopus.Features.IISWebSite_BeforePostDeploy.ps1' returned non-zero exit code: 1
January 31st 2018 16:57:39Error
Running rollback conventions...
January 31st 2018 16:57:39Error
Script 'C:\Octopus\Applications\PGSTrial1\ppp\16_60\Octopus.Features.IISWebSite_BeforePostDeploy.ps1' returned non-zero exit code: 1
January 31st 2018 16:57:39Fatal
The remote script failed with exit code 1
January 31st 2018 16:57:39Fatal
sitesitesite on Errors

additionally, the raw log has this bit for the error, everything else is fine:

16:57:38 Verbose | Call to Get-WindowsFeature Web-WebServer failed.
16:57:38 Verbose | Unable to determine if IIS is installed on this server but will optimistically continue.
16:57:38 Info | Making sure a Website "plzwork" is configured in IIS...
16:57:39 Error | foreach-object : You cannot call a method on a null-valued expression.
16:57:39 Error | At C:\Octopus\Applications\PGSTrial1\ppp\16_60\Octopus
16:57:39 Error | .Features.IISWebSite_BeforePostDeploy.ps1:464 char:59
16:57:39 Error | + ... indings | where-object { $_.protocol -eq "https" } | foreach-object {
16:57:39 Error | + ~~~~~~~~~~~~~~~~
16:57:39 Error | + CategoryInfo : InvalidOperation: (:) [ForEach-Object], RuntimeE
16:57:39 Error | xception
16:57:39 Error | + FullyQualifiedErrorId : InvokeMethodOnNull,Microsoft.PowerShell.Commands

  1. 1 Posted by Errors13 on 01 Feb, 2018 02:02 AM

    Errors13's Avatar

    Hi, any help would be appreciated thanks

  2. Support Staff 2 Posted by Daniel Fischer on 01 Feb, 2018 04:07 AM

    Daniel Fischer's Avatar

    Hi,

    Thanks for getting in touch! We will need to get a little bit more information to better troubleshoot this issue. Would you be able to attach the full raw deployment log where you are seeing this error?

    Could you also let me know what version of Octopus you are using, and the PowerShell version your deployment target is currently running?

    Looking forward to hearing from you. :)

    Best regards,
    Daniel

  3. 3 Posted by Errors13 on 01 Feb, 2018 08:06 PM

    Errors13's Avatar

    Hi Daniel,

    Octopus v4.1.8
    PSVersion 5.1.15063.786

  4. Support Staff 4 Posted by Daniel Fischer on 08 Feb, 2018 12:57 AM

    Daniel Fischer's Avatar

    Hi,

    Thanks for the information there! It looks like this could potentially be a permissions issue for the account running the Tentacle service.

    14:11:35   Verbose  |       CurrentUser: NT AUTHORITY\SYSTEM
    

    Octopus executes the deployment on the Tentacle with the account the Tentacle service is set to run as. It looks to be executing PowerShell fine, yet has trouble with Get-WindowsFeature Web-WebServer. We often see this issue when this account does not have all the permissions required for the entire deployment. We have a small section in our documentation on the required permissions for basic functionality.

    Could you confirm this account has access to configure IIS on this server?

    Another option is to configure a user for the Tentacle which has the permissions you require.

    Let me know if you have any questions here or run into any more issues. :)

    Best regards,
    Daniel

  5. 5 Posted by Errors13 on 08 Feb, 2018 09:15 AM

    Errors13's Avatar

    I made changes to the acc used for the octopus tentacle (am now using my admin acc) and I now receive a new error:

    We failed to load the WebAdministration module. This usually resolved by doing one of the following:
    February 8th 2018 16:26:32Warning
    1. Install IIS via Add Roles and Features, Web Server (IIS)
    February 8th 2018 16:26:32Warning
    2. Install .NET Framework 3.5.1
    February 8th 2018 16:26:32Warning
    3. Upgrade to PowerShell 3.0 (or greater)
    February 8th 2018 16:26:32Warning
    4. On Windows 2008 you might need to install PowerShell SnapIn for IIS from http://www.iis.net/downloads/microsoft/powershell#additionalDownloads
    February 8th 2018 16:26:32Error
    Import-Module : The specified module 'WebAdministration' was not loaded
    February 8th 2018 16:26:32Error
    because no valid module file was found in any module directory.
    February 8th 2018 16:26:32Error
    At C:\Octopus\Applications\PGSTrial1\pppInternalAPI\55_7\Octopus.
    February 8th 2018 16:26:32Error
    Features.IISWebSite_BeforePostDeploy.ps1:37 char:4
    February 8th 2018 16:26:32Error
    + Import-Module WebAdministration -ErrorAction Stop
    February 8th 2018 16:26:32Error
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    February 8th 2018 16:26:32Error
        + CategoryInfo : ResourceUnavailable: (WebAdministration:String)
    February 8th 2018 16:26:32Error
       [Import-Module], FileNotFoundException
    February 8th 2018 16:26:32Error
        + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Comm
    February 8th 2018 16:26:32Error
       ands.ImportModuleCommand

    When I look at the raw log, I see these lines as well:
    Call to Get-WindowsFeature Web-WebServer failed.
    16:26:32 Verbose | Unable to determine if IIS is installed on this server but will optimistically continue.
    16:26:32 Warning | We failed to load the WebAdministration module. This usually resolved by doing one of the following:
    ...
    I have installed .NET Framework 3.5.1, I have a ver of PS higher than 3.0 and I have installed IIS (I can deploy sites via IIS locally on my machine without the use of Octopus just fine)
    I can't seem to install PowerShell SnapIn (windows 10) or import in the webAdministration module

  6. 6 Posted by Errors13 on 08 Feb, 2018 09:32 PM

    Errors13's Avatar

    I am now trying to import the module IISAdministration and receiving the following error:

    Import-Module : The specified module 'IISAdministration' was not loaded
    February 9th 2018 10:09:17Error
    because no valid module file was found in any module directory.
    February 9th 2018 10:09:17Error
    At E:\Octopus\Tentacle\Work\20180208210915-1618-116\Script.ps1:3 char:1
    February 9th 2018 10:09:17Error
    + Import-Module IISAdministration
    February 9th 2018 10:09:17Error
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    February 9th 2018 10:09:17Error
        + CategoryInfo : ResourceUnavailable: (IISAdministration:String)
    February 9th 2018 10:09:17Error
       [Import-Module], FileNotFoundException
    February 9th 2018 10:09:17Error
        + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Comm
    February 9th 2018 10:09:17Error
       ands.ImportModuleCommand
    February 9th 2018 10:09:17Error
     
    February 9th 2018 10:09:17Fatal
    The remote script failed with exit code 1
    February 9th 2018 10:09:17Fatal
    idk on Sams Machine

  7. Support Staff 7 Posted by Daniel Fischer on 09 Feb, 2018 01:26 AM

    Daniel Fischer's Avatar

    Hi,

    Thanks for the extra information here. It does looks like this is due to the Import-Module WebAdministration not running properly on windows 10. We have a blog post which covers the requirements here.

    I found the following StackOverflow question which seems to have some extra information you can reference in order to get this working on Windows 10.

    For Windows 7 to 10 you will need to install the feature IIS Management Scripts and tools under  Internet Information Services >> Web Management Tools.
    

    Let me know if the above helps here. :)

    Best regards,
    Daniel

  8. 8 Posted by Errors13 on 09 Feb, 2018 04:08 AM

    Errors13's Avatar

    Hi Daniel,

    I have already viewed the linked blog post and turned on the IIS management scripts and tools features, but still seem to encounter the given error.

    I'm not too sure how to proceed

    Thanks!
    Sam

  9. Support Staff 9 Posted by Daniel Fischer on 15 Feb, 2018 02:44 AM

    Daniel Fischer's Avatar

    Hi Sam,

    Sorry for the delay in getting back to you! I have run this past some team members and we are a little stumped. So I believe we may need to get some additional information here to better explore what could be happening.

    First, could you please let me know what your set up looks like? Where is your Octopus server, Tentacle, IIS server in relation to each other, what Operating systems and versions each is running.

    Could you re-confirm which account is listed as the run-as account for both the Octopus Server service and Octopus Tentacle service?

    Earlier you confirmed that the deployment worked manually, can you confirm that the account you are using for the Octopus Tentacle is able to successfully do the manual deployment and execute these scripts without error?

    Looking forward to hearing from you.

    Best regards,
    Daniel

Reply to this discussion

Internal reply

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

Attaching KB article:

»

Already uploaded files

  • 1.PNG 48.9 KB
  • 2.PNG 41.9 KB
  • 3.PNG 40.7 KB
  • 4.PNG 34.3 KB
  • 5.PNG 57.8 KB

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