This project is read-only.


WarmupUrls after deploy but before "AfterDeploy"


I figure the title says it all, but my issue is that I am installing a bunch of solutions in a single bundle and when AfterDeploy fires I am Installing and enabling some of the solutions.

The issue is some of them are custom fields so I need to reset iis AND warmupurls to get them to load so that later features that are enabled can leverage the new columns.

I tried just calling WarmUpUrl directly with my site url, but I am getting a .ctor error and I am not sure what else to do.


matein78 wrote Jan 28, 2016 at 8:54 AM

Unfortunately I can't reproduce that issue.
WarmUpUrl -url "http://xxxx" should do the trick.

You can check in the script line 211
how it is done.

Basically the script is doing a simple webrequest and creates a web proxy for it
        $proxy = New-Object system.Net.WebProxy($proxyuri, $bypassonlocal)
Maybe this is the Constructor Call that is failing. Can you try that separately in your AfterDeploy Script?

maxmanzero wrote Jan 28, 2016 at 12:40 PM

I will give that a try. Thanks for looking at it.

maxmanzero wrote Jan 28, 2016 at 12:48 PM

Ok I looked at the log as well and the problem I am getting is Invalid URI: The hostname could not be parsed.

I am calling WarmUpUrl -url "http://maxz800a:8080/" So the entire deploy works and it hits the AfterDeploy event then gives me the error above. Could it be the port number?

maxmanzero wrote Jan 28, 2016 at 1:30 PM

Ok I just debugged it and when I call the method directly there is a line in there that reads:
        $proxyuri = "http://" + $server
But looking at it in debug the $server variable is blank so I guess the error makes perfect sense.

Could the issue be that I need to call a different method that will feed the WarmUpUrl method?

matein78 wrote Jan 28, 2016 at 1:34 PM

Actually the above code was the wrong location in the source.
SPSD is using the WebProxy to work around the load balancer in multi server farms.
At the end the site should be hit on all webfrontends with their local urls.

The actual request is a HttpWebRequest
            $proxyuri = "http://" + $server
            $proxy = New-Object system.Net.WebProxy($proxyuri, $bypassonlocal)
            $Request = [System.Net.HttpWebRequest]::Create($url); 
            $Request.Proxy = $proxy
The request should be able to resolve the port, so I don't believe this is the issue

What happens if you run
$Request = [System.Net.HttpWebRequest]::Create($url); 
$Request.UseDefaultCredentials = $true 
$Request.UserAgent     = "SPSD Warmup script"
$Response = $Request.GetResponse(); 
directly in your AfterDeploy target?
Maybe the proxy is not possible to create in your case.

maxmanzero wrote Jan 28, 2016 at 1:42 PM

I will give that a try.

When I run the install without interfering it seems to have no problem warming up Central admin and my site, but I am curious why when I call the method directly that $server variable is blank, but if I foreach the $servers variable there is an entry in there for MAXZ800A.

Let me try calling the request directly first. I may actually need the proxy for our production environment though I am not sure.

matein78 wrote Jan 28, 2016 at 2:34 PM

Alright, found the issue.

When writing the code I didn't think of running the WarmUpUrl -$url function outside of the controlled context.

Hence it is not iterating through the $servers array by itself and relies on setting the $servers variable before.
This does not happen in your case of course.

Have a look in Function RunAction([System.Xml.XMLElement]$action) of
line 264

The following action does the necessary task
                    foreach ($server in $servers){ 
                        Log -message "Warming up urls from server $server" -type $SPSD.LogTypes.Information -Indent
                            CustomEnter-PSSession $server
                            if((GetBoolAttribute -node $action -attribute "AllWebApps")){
                            if((GetBoolAttribute -node $action -attribute "AllSites")){
                            WarmUpUrls -urls ($action.WarmUp | ForEach-Object {$_.Url})
                            CustomExit-PSSession $server
So either you set the $server variable manually to
$server = $env:COMPUTERNAME
before calling WarmUpUrl,

or you iterate through the array and run the warmup on all servers in your farm like in the code above (with entering the PS Remoting Session)

Hope that makes sense

maxmanzero wrote Jan 28, 2016 at 3:27 PM

That makes perfect sense! Thanks very much for your help. This is going to streamline my installer down to one SPSD package which will make my hosting enclave very happy.

Thanks again:


matein78 wrote Jan 28, 2016 at 4:57 PM

Happy to hear :)

For future requests, kindly use GitHub to submit issues, because I have moved the entire source code there too. This will allow others to find the information much easier.

Best Regards and thank you for using SPSD