<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Hosam's blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/hosamshobak/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/hosamshobak/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 03:41:28 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>ARM Template MSDeploy Race Condition Issue</title>
      <link>https://docs.microsoft.com/archive/blogs/hosamshobak/arm-template-msdeploy-race-condition-issue</link>
      <pubDate>Thu, 26 May 2016 23:55:51 GMT</pubDate>
      <dc:creator><![CDATA[Hosam Shobak]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hosamshobak/?p=45</guid>
      <description><![CDATA[In Azure Resource Manager ARM Templates, you describe all the resources needed for your project. One...]]></description>
      <content:encoded><![CDATA[In Azure Resource Manager ARM Templates, you describe all the resources needed for your project. One of which could be an Azure App Service. For Azure App Services you can add an MSDeploy Resource, that describes what to publish to the app service. You could also define App Settings, Site Configurations, Connection Strings and many more. For more information about ARM Templates please visit the documentation here <a href="https://azure.microsoft.com/en-us/documentation/articles/resource-group-authoring-templates/ ">https://azure.microsoft.com/en-us/documentation/articles/resource-group-authoring-templates/</a>.

In this post I will touch upon a scenario that might disrupt the flow of a template when dealing with an App Service, MSDeploy with other App configs (App Settings, Site Configurations, or Connection Strings). There are 2 manifestations of the problem:

1- An error from MSDeploy, something like "Deployment was interrupted and the process running it was terminated unexpectedly,..."

2- The deployment hangs and takes a lot of time to fail.

The reason behind this problem is a race condition caused by how the resources are ordered. App Settings changes or connection string changes cause a site restart Asynchronously, if MSDeploy goes after that step, then there is no guarantee that the site will not restart during the deployment. But if you make all steps depend on MSDeploy then you ensure MSDeploy runs first and then any other site restarting activities.

&nbsp;

<a href="https://msdnshared.blob.core.windows.net/media/2016/05/TemplateSnippet.png"><img class="alignnone size-full wp-image-55" src="https://msdnshared.blob.core.windows.net/media/2016/05/TemplateSnippet.png" alt="TemplateSnippet" width="734" height="598" /></a>

&nbsp;

A working example of WordPress deployment template that is implementing this could be found <a href="https://github.com/davidebbo/AzureWebsitesSamples/blob/master/ARMTemplates/WordpressTemplateWebDeployDependency.json">here </a>]]></content:encoded>
    </item>
    <item>
      <title>Azure APIs and equivalent Azure PowerShell cmdlets in Azure Resource Explorer</title>
      <link>https://docs.microsoft.com/archive/blogs/hosamshobak/azure-apis-and-equivalent-azure-powershell-cmdlets-in-azure-resource-explorer</link>
      <pubDate>Mon, 29 Jun 2015 11:53:00 GMT</pubDate>
      <dc:creator><![CDATA[Hosam Shobak]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hosamshobak/2015/06/29/azure-apis-and-equivalent-azure-powershell-cmdlets-in-azure-resource-explorer/</guid>
      <description><![CDATA[Azure Resource Explorer&nbsp;is a very handy service that aims at exposing Azure APIs in a visual...]]></description>
      <content:encoded><![CDATA[<p><a href="https://resources.azure.com">Azure Resource Explorer</a>&nbsp;is a very handy service that aims at exposing Azure APIs in a visual way, to allow customers to know more about the APIs and what they can do with it. To know more about Azure Resource Explorer please follow this <a href="https://azure.microsoft.com/blog/2015/04/02/azure-resource-explorer-a-new-tool-to-discover-the-azure-api/">link</a></p>
<p>Alongside other technologies, Azure SDK team offers PowerShell cmdlets to manage and interact with Azure APIs. Being so powerful, Azure PowerShell has lots of cmdlets and lots of switches and parameters. Hoping to help Azure users learn more about Azure PowerShell, we introduced PowerShell equivalent cmdlets feature in Azure Resource Explorer</p>
<p>.&nbsp;<br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/3252.PowerShellTab.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/3252.PowerShellTab.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/3252.PowerShellTab.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/3252.PowerShellTab.JPG" alt="" border="0" /></a>&nbsp;<br />&nbsp;</p>
<p>The New tab &ldquo;PowerShell&rdquo; starts with providing info on how to download the latest PowerShell version. Then it lists out the equivalent cmdlets you can see in the rest of the tabs, it lists out mainly these category of cmdlets</p>
<ol>
<li>GET/LIST it gets info about the current object or Lists objects in current collection</li>
<li>Actions, that include Deletion of current object, it also includes specific object actions, for example in case of a site object it shows the restart/start/stop actions</li>
<li>SET cmdlets, to show how to change the properties of an object</li>
<li>CREATE, if the current highlighted object is a list, the create new cmdlet is shown with the right parameters&nbsp;<br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/5432.PowerShellGet-CREATE.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/5432.PowerShellGet_2D00_CREATE.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/5432.PowerShellGet-CREATE.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/5432.PowerShellGet_2D00_CREATE.JPG" alt="" border="0" /></a>&nbsp;</li>
</ol>
<div>
<p>The cmdlet created has the specific values populated so you can just copy and paste it into an Azure PowerShell window and it does the right thing.&nbsp;</p>
<p><br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/4810.PowerShellInActionSecured.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/4810.PowerShellInActionSecured.jpg"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/4810.PowerShellInActionSecured.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/4810.PowerShellInActionSecured.jpg" alt="" border="0" /></a></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/1425.PowerShellInActionSecured.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/1425.PowerShellInActionSecured.jpg"><br /></a>&nbsp;The cmdlets that show up do exactly equivalent effect to calling the API, All the PowerShell cmdlets that show up here are the low level cmdlets Get/New/Set/Remove-AzureResource, making the mapping from API calls easier and more transparent.</p>
<p>Quoting from the original post about Azure Resource Explorer</p>
<p style="padding-left: 30px;"><em>Please note that this project is being developed as Open Source, and is hosted on GitHub<a href="https://github.com/projectkudu/ARMExplorer/">here</a>.&nbsp;This makes it easy for anyone to create an issue, track a bug, and even add a feature suggestion. And&nbsp;if you are really eager to see a change happen, you can send a pull request and it may just make it into the official site!</em></p>
</div>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Azure Logic App with simple API App with inputs and outputs</title>
      <link>https://docs.microsoft.com/archive/blogs/hosamshobak/azure-logic-app-with-simple-api-app-with-inputs-and-outputs</link>
      <pubDate>Tue, 31 Mar 2015 13:18:00 GMT</pubDate>
      <dc:creator><![CDATA[Hosam Shobak]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hosamshobak/2015/03/31/azure-logic-app-with-simple-api-app-with-inputs-and-outputs/</guid>
      <description><![CDATA[Logic Apps is a new service offered by Microsoft Azure. It allows users to easily create and manage...]]></description>
      <content:encoded><![CDATA[<p>Logic Apps is a new service offered by Microsoft Azure. It allows users to easily create and manage a flow of triggers and actions. Triggers start when an event happens, it can be periodic triggers or triggers based on an arrival of an Email, etc&hellip; when a trigger kicks in, the actions specified in the Logic App are invoked. All triggers and actions are API Apps, for more details about Logic Apps please visit this&nbsp;<a href="https://azure.microsoft.com/en-us/documentation/articles/app-service-logic-what-are-logic-apps/#why-logic-apps">documentation&nbsp;</a>&nbsp;and for API Apps, you can find documentation <a href="https://azure.microsoft.com/en-us/documentation/articles/app-service-api-apps-why-best-platform/">here&nbsp;</a>&nbsp;</p>
<p>&nbsp;Here I will go through the creation of a simple API App that takes an input and does some processing and has an output. I chose my operation to be ToUpper, it takes a string and converts all characters to upper case. To do that I used Visual studio to create and publish the API App, and then Azure portal to create and manage the Logic App.&nbsp;</p>
<p>Let&rsquo;s start by creating a new API App. To do that I had Visual studio 2013 and I had to install Azure SDK 2.5 for visual studio 2013. (I installed it using Web Platform Installer, search for visual studio azure SDK). Open visual studio, create new project -&gt; visual C# -&gt; Web -&gt; ASP.NET Web Application, you will see these options:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/2112.VSAPIAPPsCreate.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/2112.VSAPIAPPsCreate.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/2112.VSAPIAPPsCreate.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/2112.VSAPIAPPsCreate.JPG" alt="" border="0" /></a></p>
<p>Choose Azure API App and ok.</p>
<p>This will create a new project and then will add 2 main components</p>
<ol>
<li>Web API: Microsoft Framework to create web services based on ASP.NET for more info please visit <a href="https://www.asp.net/web-api">https://www.asp.net/web-api</a></li>
<li>Swashbuckle: a utility that helps create swagger api definitions for your web api for more info please visit <a href="https://github.com/domaindrivendev/Swashbuckle">https://github.com/domaindrivendev/Swashbuckle</a></li>
</ol>
<div>
<p>The new project will have ValuesController I will just rename the controller to ToUpperController, make sure you change the controller name and the file name too to ToUpperController.cs. And this is how my controller looks like&nbsp;</p>
<pre class="scroll"><code class="csharp">public class ToUpperController : ApiController<br /> {<br /> // GET api/values<br /> public string Get(string toConvert)<br /> {<br /> return toConvert.ToUpper();<br /> }<br /> }</code></pre>
<p>In the project go to App_Start, SwaggerConfig class and enable the UI by uncommenting this&nbsp;</p>
<pre class="scroll"><code class="csharp"> /*<br /> })<br /> .EnableSwaggerUi(c =&gt;<br /> {<br /> */</code></pre>
<p>Run your site and go to {localhost:port}/swagger you will see this UI:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/8662.Swagger%20UI.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/8662.Swagger-UI.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/8662.Swagger%20UI.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/8662.Swagger-UI.JPG" alt="" border="0" /></a></p>
<p>And you can pass in any string and &ldquo;try it out!&rdquo; you see that the body will have the string you sent in capitalized letters. If you browse to {localhost:port}/swagger/docs/v1, you will get the swagger API definition file</p>
<p>Now here is the trick that took me some time to figure out, Logic apps only work with the default response and not the 200 response defined in the swagger JSON&nbsp;&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/0247.SwaggerJSON.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/0247.SwaggerJSON.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/0247.SwaggerJSON.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/0247.SwaggerJSON.JPG" alt="" border="0" /></a></p>
<p>So to add default response to all your APIs here is what you need to do is to go to SwaggerConfig.cs and do the following</p>
<ol>
<li>Uncomment<br />
<pre class="scroll"><code class="cplusplus">c.OperationFilter&lt;AddDefaultResponse&gt;();</code></pre>
&nbsp;</li>
<li>Add the following class
<pre class="scroll"><code class="cplusplus">public class AddDefaultResponse: IOperationFilter<br /> {<br /> public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)<br /> {<br /> if (!operation.responses.ContainsKey("default") &amp;&amp; operation.responses.ContainsKey("200"))<br /> {<br /> operation.responses.Add("default", operation.responses["200"]);<br /> }<br /> }<br /> }</code> </pre>
</li>
</ol>
<div>
<p>And that is how the swagger response will look like:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/5661.SwaggerJSONAfter.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/5661.SwaggerJSONAfter.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/5661.SwaggerJSONAfter.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/5661.SwaggerJSONAfter.JPG" alt="" border="0" /></a></p>
<p>Now we are ready to publish to a live API App, right click on the project then hit publish. To do that you need to be signed in to Azure and you need a subscription. Documentation on how to publish API App <a href="https://azure.microsoft.com/en-us/documentation/articles/app-service-dotnet-deploy-api-app/">here&nbsp;</a></p>
<p>Ok now let&rsquo;s play with the new API App that we created, go to the portal and create a new twitter API app, just search Azure marketplace and install the package &ldquo;Twitter Connector&rdquo;.</p>
<p>Once you have all deployed, create a new Logic app, go the designer by clicking triggers and actions.</p>
<p>In my scenario I will trigger this flow manually so I will check the box &ldquo;Run this Logic Manually&rdquo;, now it will ask to drop in an action, from the right list drop in twitterconnector, I will choose search tweets action, and I will search for Azure. Now drop in your API App in and choose the only action you got now &ldquo;ConverToUpper_Get&rdquo; it will ask for input called &ldquo;toConvert&rdquo; let&rsquo;s click on the &ldquo;&hellip;&rdquo; button to get a list or parameters that we can get from the previous action. I will choose Search Tweets Tweeted By as input. Notice here it only shows the &ldquo;variables&rdquo; that are of type string, because we specified that our input to the API is string. This is how the design will look after you are done</p>
<p>&nbsp;<br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/0572.Designer.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/0572.Designer.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/0572.Designer.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/0572.Designer.JPG" alt="" border="0" /></a></p>
<p>Now save your changes, close the designer and go back to the Logic App blade and click &ldquo;Run Now&rdquo; you will see in the operation part a new run shows up, if you click on that you can get to the results of the run&nbsp;</p>
<p><br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/5707.RunLogicAppJPG.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/5707.RunLogicAppJPG.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/5707.RunLogicAppJPG.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/5707.RunLogicAppJPG.JPG" alt="" border="0" /></a>&nbsp;</p>
<p>Now if you open the logs for each action you will see 2 links &ldquo;INPUTS LINK&rdquo; and &ldquo;OUTPUTS LINK&rdquo; each will open JSON data files that contain the information. If you go to your ToUpperApp input links you will see something similar to this:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/1374.ToUpperInputs.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/1374.ToUpperInputs.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/1374.ToUpperInputs.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/1374.ToUpperInputs.JPG" alt="" border="0" /></a></p>
<p>And to outputs link you will see that the name DanWahlin was transformed to Capital letters and is sent back in the body.</p>
<span style="font-family: monospace;"><span style="white-space: pre;"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/1805.ToUpperOutputs.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/1805.ToUpperOutputs.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/1805.ToUpperOutputs.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/1805.ToUpperOutputs.JPG" alt="" border="0" /></a><br /></span></span></div>
<p>Now you have created the API App from scratch and it can take in parameters and send back ouputs. That opens up the gate for lots of innovative Logic apps you can easily and rapidly develop.</p>
<p>&nbsp;</p>
</div>]]></content:encoded>
    </item>
    <item>
      <title>Azure WebSites: how to change PHP ini settings.</title>
      <link>https://docs.microsoft.com/archive/blogs/hosamshobak/azure-websites-how-to-change-php-ini-settings</link>
      <pubDate>Fri, 20 Mar 2015 12:25:00 GMT</pubDate>
      <dc:creator><![CDATA[Hosam Shobak]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hosamshobak/2015/03/20/azure-websites-how-to-change-php-ini-settings/</guid>
      <description><![CDATA[Azure Websites aims at creating a web hosting platform that balances between simplicity and...]]></description>
      <content:encoded><![CDATA[<p>Azure Websites aims at creating a web hosting platform that balances between simplicity and flexibility. Especially for PHP development this is challenging, as the technology includes lots of configurations that enables different scenarios. In this post, I will go through the process of overwriting and/or adding PHP.ini configurations.</p>
<p>In Azure web sites, there are many ways you can change PHP default configurations. You can enable custom extensions, you can use a .user.ini to change the non system-level-only directives or you can even bring in your own runtime bits of PHP. For more details read this <a href="https://azure.microsoft.com/en-us/documentation/articles/web-sites-php-configure/">article</a>.</p>
<p>This post is to add another way to customize your PHP.ini configuration. To understand how it works there are 2 concepts we need to go through</p>
<ol>
<li>Azure Websites is a shared hosting environment, where multiple sites can exist in the same host machine. &nbsp;When a site comes up, a dedicated PHP.ini file gets created. This file is used only by that site. If you want to go through that file to see the default values you can do so through your scm site. Go to &lt;your site name&gt;.scm.azurewebsites.net, sign in with your Microsoft account, then you get to Kudu interface (Kudu is an awesome tool that comes with Azure Websites, if you do not know about it, here is a brief intro in this <a href="https://blogs.msdn.com/b/benjaminperkins/archive/2014/03/24/using-kudu-with-windows-azure-web-sites.aspx">post</a>). Using Kudu you can navigate to the location where your PHP.ini exists.</li>
<ol>
<li>Go to Debug Console -&gt; cmd</li>
<li>Click on the globe icon, then navigate to config folder, PHP version you are using</li>
<li>Click the edit button and you get an editor that has all the content of the php.ini used for your site.<br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/4478.Kudu.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/4478.Kudu.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/4478.Kudu.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/4478.Kudu.JPG" alt="" border="0" /><br /></a>&nbsp;Note: these config files files are read only.</li>
</ol>
<li>In PHP you can specify a location, and PHP runtime will look at all .ini files in that directory and append it to the configurations in the main PHP.ini. I really could not find any documentation whatsoever to that feature, but it exists :)</li>
</ol>
<p>Combining this knowledge with the knowledge on how to add appSettings to the Azure Websites, we can make advantage of that PHP hidden treasure and here is how.</p>
<p>In the <a href="https://manage.windowsazure.com/">portal</a> or the <a title="https://portal.azure.com" href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/preview portal">preview portal</a>, you can do all of these steps but for the purpose of that post I will use only the preview portal.</p>
<ol>
<li><span style="line-height: 0px;">Go to your website -&gt; All settings, you will find a section called App settings.<br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/8420.ChangeAppSettings_Anonimized.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/8420.ChangeAppSettings_5F00_Anonimized.jpg"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/8420.ChangeAppSettings_Anonimized.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/8420.ChangeAppSettings_5F00_Anonimized.jpg" alt="" border="0" /></a><br />&nbsp;</span></li>
<li>
<p>Add this app setting <strong>PHP_INI_SCAN_DIR</strong> with a value that is a directory in your site, in this case I decided to put it in D:\home\site which is a directory that is not in the serve-able wwwroot folder, but you still can publish to it either using FTP or by using the awesome magic of Kudu. Do not forget to save the changes.</p>
</li>
<li>
<p>publish a simple site with an index.php that has this content&nbsp;</p>
<pre class="scroll"><code class="php">&lt;?php<br /> <br /> phpinfo();<br /> <br /> ?&gt; </code>&nbsp;</pre>
<p>This will print out PHPInfo page<br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/4431.PHPINI.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/4431.PHPINI.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/4431.PHPINI.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/4431.PHPINI.JPG" alt="" border="0" /><br /></a></p>
<p>You can see that now it shows the &ldquo;scan this dir for additional .ini files&rdquo; is pointing to D:\home\site.&nbsp;</p>
</li>
</ol>
<p>Now you can put any .ini files in that location and they will be simply appended to the PHP ini configurations. Let&rsquo;s play with that a little<br />I will first try to drop an empty .ini file make sure it was loaded by PHP runtime. I do this by opening Kudu and then drag and drop the file in the folder I want to publish to, cool huh!<br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/0361.KuduUpload.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/0361.KuduUpload.jpg"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/0361.KuduUpload.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/0361.KuduUpload.jpg" alt="" border="0" /><br /></a>&nbsp;Now restart the site and refresh the index.php and here you go, the empty ini shows up.<br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/3660.EmptyINI%20Added.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/3660.EmptyINI-Added.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/3660.EmptyINI%20Added.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/3660.EmptyINI-Added.JPG" alt="" border="0" /><br /></a>&nbsp;<br />Now let&rsquo;s add another ini file that really does something, I will add a file &nbsp;NewConfig.ini and the content will be</p>
<pre class="scroll"><code class="cplusplus">mysql.max_links=5</code></pre>
<p>and again use Kudu magic to just drop it in D:\home\site. Here is the output of phpinfo before and after</p>
<p>Before:<br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/2620.MySQlMAXLinksBefore.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/2620.MySQlMAXLinksBefore.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/2620.MySQlMAXLinksBefore.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/2620.MySQlMAXLinksBefore.JPG" alt="" border="0" /><br /></a></p>
<p>After adding the file and restarting the site:<br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/7612.MySQlMAXLinksAfter.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/7612.MySQlMAXLinksAfter.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/70/12/7612.MySQlMAXLinksAfter.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-70-12/7612.MySQlMAXLinksAfter.JPG" alt="" border="0" /><br /></a></p>
<p>Then I added this to my new ini file</p>
<pre class="scroll"><code class="php">upload_tmp_dir=D:\home\site\uploads</code></pre>
<p>restarted the site, then I see the change reflected in phpinfo page.</p>
<p>Using this method you can even enable new extensions by adding an ini file that has the content</p>
<pre class="scroll"><code class="cplusplus">zend_extension=D:\home\site\php-ext\php_xdebug-2.3.1-5.4-vc9-nts.dll</code></pre>
<p>or</p>
<pre class="scroll"><code class="cplusplus">extension=D:\home\site\php-ext\php_gd2.dll</code></pre>
<p>Make sure you upload the extensions in the right directory and that would effectively enable your custom extensions.</p>
<p>In conclusion, hosting a PHP site on Azure Websites platform is easy and reliable. In addition, you can get higher level of control on your PHP site by setting the PHP configurations you like.</p>
<p>Related resources that I found useful:<br /><a href="https://microsoftazurewebsitescheatsheet.info/">https://microsoftazurewebsitescheatsheet.info/</a>&nbsp;&nbsp;</p>]]></content:encoded>
    </item>
  </channel>
</rss>