<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Powershell &#8211; My Shitty Code</title>
	<atom:link href="https://myshittycode.com/tag/powershell/feed/" rel="self" type="application/rss+xml" />
	<link>https://myshittycode.com</link>
	<description>Embracing the Messiness in Search of Epic Solutions</description>
	<lastBuildDate>Fri, 06 Jan 2023 16:15:34 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://myshittycode.com/wp-content/uploads/2022/04/cropped-icon-32x32.png</url>
	<title>Powershell &#8211; My Shitty Code</title>
	<link>https://myshittycode.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">205304208</site>	<item>
		<title>Azure: Deploying WAR File to Tomcat</title>
		<link>https://myshittycode.com/2019/05/02/azure-deploying-war-file-to-tomcat/</link>
					<comments>https://myshittycode.com/2019/05/02/azure-deploying-war-file-to-tomcat/#respond</comments>
		
		<dc:creator><![CDATA[Shitty Author]]></dc:creator>
		<pubDate>Fri, 03 May 2019 00:53:14 +0000</pubDate>
				<category><![CDATA[Development Tools]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Azure]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Tomcat]]></category>
		<guid isPermaLink="false">http://myshittycode.com/?p=1106</guid>

					<description><![CDATA[<p>PROBLEM Typically, when using ZipDeploy to push a WAR file (ex: my-app.war) to an Azure instance, we need to:- This zip file will automatically be unzipped under site/wwwroot:- Tomcat detects ROOT.war and will try to unpack the WAR file under ROOT/:- The problem is sometimes Tomcat is unable to fully unpack ROOT.war because some files [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2019/05/02/azure-deploying-war-file-to-tomcat/">Azure: Deploying WAR File to Tomcat</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">PROBLEM</h2>



<p>Typically, when using ZipDeploy to push a WAR file (ex: <b>my-app.war</b>) to an Azure instance, we need to:-</p>



<ul class="wp-block-list">
<li>Rename <b>my-app.war</b> to <b>ROOT.war</b>.</li>



<li>Place <b>ROOT.war</b> under <b>webapps/</b>.</li>



<li>Zip up <b>webapps/</b>.</li>



<li>Use ZipDeploy to push the zip file to an Azure instance.</li>
</ul>



<p>This zip file will automatically be unzipped under <b>site/wwwroot</b>:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; highlight: [2,3]; title: ; notranslate">
D:\home\site\wwwroot
└── webapps
    └── ROOT.war
</pre></div>


<p>Tomcat detects <b>ROOT.war</b> and will try to unpack the WAR file under <b>ROOT/</b>:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; highlight: [3,4,5,6,7]; title: ; notranslate">
D:\home\site\wwwroot
└── webapps
    ├── ROOT
    │   ├── META-INF
    │   │   └── ...
    │   └── WEB-INF
    │       └── ...
    └── ROOT.war
</pre></div>


<p>The problem is sometimes Tomcat is unable to fully unpack <b>ROOT.war</b> because some files may be locked by some running processes. As a result, the web page fails to load and shows 404 error.</p>



<h2 class="wp-block-heading">SOLUTION</h2>



<p>A better and more stable solution is to use WarDeploy to push WAR file to an Azure instance because:-</p>



<ul class="wp-block-list">
<li>It simplifies the deployment process because we don&#8217;t need to create a zip file with <b>webapps/</b> containing a WAR file named <b>ROOT.war</b>.</li>



<li>Instead of relying on Tomcat to unpack the WAR file, WarDeploy will do the unpacking step elsewhere before copying to <b>site/wwwroot/webapps/</b>.</li>
</ul>



<p>To use WarDeploy, you can use <b>curl</b> command or PowerShell script to do so.</p>



<p>Here&#8217;s an example of the PowerShell script:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: powershell; title: ; notranslate">
Param(
    &#x5B;string]$filePath,
    &#x5B;string]$apiUrl,
    &#x5B;string]$username,
    &#x5B;string]$password
)

$base64AuthInfo = &#x5B;Convert]::ToBase64String(&#x5B;Text.Encoding]::ASCII.GetBytes((&quot;{0}:{1}&quot; -f $username, $password)))

Invoke-RestMethod -Uri $apiUrl -Headers @{ Authorization = (&quot;Basic {0}&quot; -f $base64AuthInfo) } -Method POST -InFile $filePath -ContentType &quot;multipart/form-data&quot;
</pre></div>


<p>If the PowerShell script above is called <b>deploy.ps1</b>, to push <b>my-app.war</b> to <b>my-app</b> Azure instance:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: powershell; title: ; notranslate">
deploy.ps1 -filePath D:\my-app.war -apiUrl https://my-app.scm.azurewebsites.net/api/wardeploy -username &#x5B;USER] -password &#x5B;PASSWORD]
</pre></div>


<p>Depending on the size of the WAR file, you may get &#8220;The operation has timed out&#8221; error after 100 seconds:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
Invoke-RestMethod : The operation has timed out
At D:\agent\_work\2ea6e947a\my-app\deploy.ps1:18 char:1
+ Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=(&quot;Basic {0}&quot;  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) &#x5B;Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
</pre></div>


<p>This will most likely to occur if the WAR file is too big (80MB+).</p>



<p>To fix this, increase the time out duration by adding <b>-TimeoutSec</b> option to <b>Invoke-RestMethod</b> statement:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: powershell; title: ; notranslate">
Invoke-RestMethod &#x5B;OTHER_OPTIONS...] -TimeoutSec 300
</pre></div><p>The post <a rel="nofollow" href="https://myshittycode.com/2019/05/02/azure-deploying-war-file-to-tomcat/">Azure: Deploying WAR File to Tomcat</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://myshittycode.com/2019/05/02/azure-deploying-war-file-to-tomcat/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1106</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Lazy Loading (feed)
Database Caching using Disk

Served from: myshittycode.com @ 2026-02-20 22:12:10 by W3 Total Cache
-->