<?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>Azure World!</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/myazureworld/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/myazureworld/feed.xml</link>
    <description>Explore Azure</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:25:01 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>WCF Federation with ACS v2</title>
      <link>https://docs.microsoft.com/archive/blogs/myazureworld/wcf-federation-with-acs-v2</link>
      <pubDate>Fri, 12 Aug 2011 13:19:00 GMT</pubDate>
      <dc:creator><![CDATA[Zafar Mohammed - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/myazureworld/2011/08/12/wcf-federation-with-acs-v2/</guid>
      <description><![CDATA[Recently I worked on WCF Federation with ACS v2. The developer who approached me was trying to...]]></description>
      <content:encoded><![CDATA[<p>Recently I worked on WCF Federation with ACS v2. The developer who approached me was trying to authenticate the WCF service (on-premise/azure hosted) using Azure Appfabric Access Control (ACS ).&nbsp; He wanted to use an Identity provider (Windows LiveID or Facebook) as listed in the msdn magazine article below.</p>
<p>Re-Introducing the Windows Azure AppFabric Access Control Service - <a href="https://msdn.microsoft.com/en-us/magazine/gg490345.aspx">https://msdn.microsoft.com/en-us/magazine/gg490345.aspx</a></p>
<p>By Design,&nbsp; ACS supports active (WCF) federation with 3rd party identity providers such as ADFS, however LiveID does not offer an active endpoint. You can only do LiveID authentication through ACS using passive (browser redirect based) based federation. This works great for ASP.Net but not for WCF due to the design limitation mentioned.</p>
<p>(Source: <a href="https://social.msdn.microsoft.com/Forums/en-NZ/windowsazuresecurity/thread/f3bc5461-cdfe-4f69-a3ac-9a743d12ca85">https://social.msdn.microsoft.com/Forums/en-NZ/windowsazuresecurity/thread/f3bc5461-cdfe-4f69-a3ac-9a743d12ca85</a>)</p>
<p>So the only option that WCF has for federation is to using&nbsp;ACS Service. Zulfiqar has a good blog on this - <a href="https://zamd.net/2010/10/05/web-services-federation-with-acs-v2/">https://zamd.net/2010/10/05/web-services-federation-with-acs-v2/</a></p>
<p>With the help from this blog, I was able to use ACS hosted STS and authenticate&nbsp; to on-premise WCF service using ACS Service Identities (username/certificate) as the client credentials. You will basically pass through all the claims. All you have to do to&nbsp; switch between different client authentications is change bindings for ACS STS, which is listed under secureConversationBootstrap in customBinding section for the on-remise/azure<br />WCF service&nbsp; as explained in the above blog. As you can see below, I've enabled username authentication.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #339966;">&lt;!--&lt;issuer address=<a href="https://alphawif.accesscontrol.windows.net/v2/wstrust/13/issuedtoken-symmetric"><span style="color: #339966;">https://alphawif.accesscontrol.windows.net/v2/wstrust/13/issuedtoken-symmetric</span></a>&nbsp;binding="customBinding"</span><br /><span style="color: #339966;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bindingConfiguration="https://alphawif.accesscontrol.windows.net/v2/wstrust/13/issuedtoken-symmetric"/&gt;</span></p>
<p><span style="color: #339966;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;issuerMetadata address="https://alphawif.accesscontrol.windows.net/v2/wstrust/mex"/&gt;--&gt;</span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #ff0000;">&lt;issuer address=<a href="https://alphawif.accesscontrol.windows.net/v2/wstrust/13/username"><span style="color: #ff0000;">https://alphawif.accesscontrol.windows.net/v2/wstrust/13/username</span></a>&nbsp;&nbsp;bindingConfiguration="https://alphawif.accesscontrol.windows.net/v2/wstrust/13/username"</span><br /><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; binding="ws2007HttpBinding" /&gt;</span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<span style="color: #339966;">&lt;!--&lt;issuer address="https://alphawif.accesscontrol.windows.net/v2/wstrust/13/certificate bindingConfiguration="https://alphawif.accesscontrol.windows.net/v2/wstrust/13/certificate"</span><br /><span style="color: #339966;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; binding="ws2007HttpBinding" /&gt;--&gt;</span></p>
<p>Here's the binding that will be picked to connect to ACS in order to authenticate with username.</p>
<p><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ws2007HttpBinding&gt;</span><br /><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;binding name="<a href="https://alphawif.accesscontrol.windows.net/v2/wstrust/13/username"><span style="color: #ff0000;">https://alphawif.accesscontrol.windows.net/v2/wstrust/13/username</span></a>"</span><br /><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"</span><br /><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false"</span><br /><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"</span><br /><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8"</span><br /><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;useDefaultWebProxy="true" allowCookies="false"&gt;</span><br /><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"</span><br /><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;</span><br /><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;reliableSession ordered="true" inactivityTimeout="00:10:00"&nbsp;enabled="false" /&gt;</span><br /><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;security mode="TransportWithMessageCredential"&gt;</span><br /><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&lt;transport clientCredentialType="None" proxyCredentialType="None"&nbsp;realm="" /&gt;</span><br /><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&lt;message clientCredentialType="UserName" negotiateServiceCredential="true"&nbsp;algorithmSuite="Default" establishSecurityContext="false" /&gt;</span><br /><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/security&gt;</span><br /><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&lt;/binding&gt;</span><br /><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&lt;ws2007HttpBinding&gt;</span></p>
<p>Zulfiqar's blog explains username authentication, certificate authentication is no different. You have to add a certificate for the client authentication as shown in the screenshots below.</p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/46/05/6433.ServiceId.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-46-05/6433.ServiceId.jpg"><img style="margin-right: auto; margin-left: auto; display: block;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/46/05/6433.ServiceId.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-46-05/6433.ServiceId.jpg" width="717" height="535" /></a></p>
<p>&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/46/05/1882.addServiceID.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-46-05/1882.addServiceID.jpg"><img style="margin-right: auto; margin-left: auto; display: block;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/46/05/1882.addServiceID.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-46-05/1882.addServiceID.jpg" width="726" height="440" /></a></p>
<p></p>
<p>Once everything is set, you provide the client credentials like you do to while calling any other WCF service.</p>
<p>Username Authentication:</p>
<p><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var client = new ServiceReference1.ServiceClient();</span></p>
<p><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;client.ClientCredentials.UserName.UserName = "user";</span></p>
<p><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;client.ClientCredentials.UserName.Password = "pwd#123";</span></p>
<p><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(client.GetData(33));</span></p>
<p>Certificate Authentication:</p>
<p><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var client = new ServiceReference1.ServiceClient();</span></p>
<p><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;client.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.My, X509FindType.FindBySubjectName, "DefaultApplicationCertificate");</span></p>
<p><span style="color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(client.GetData(33));</span></p>
<p>I tried issued token (symmetric -&nbsp; <a href="https://alphawif.accesscontrol.windows.net/v2/wstrust/13/issuedtoken-symmetric">https://alphawif.accesscontrol.windows.net/v2/wstrust/13/issuedtoken-symmetric</a>) but ran into some issue. I still have to figure out how to make it work , hopefully will come in my next blog part for this topic.</p>
<p>The sample is uploaded for your convenience. Otherwise, the blog (<a href="https://zamd.net/2010/10/05/web-services-federation-with-acs-v2/">https://zamd.net/2010/10/05/web-services-federation-with-acs-v2/</a>&nbsp;) itself let's you create a sample yourself very quickly.</p>
<p>Note: alphawif is my ACS namespace, this is something you need to take care of when you use the sample.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/19/53/09/WCFFederation-ACSv2.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-19-53-09/WCFFederation_2D00_ACSv2.zip">WCFFederation-ACSv2.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Securing Azure hosted ASP.Net/WCF with SSL</title>
      <link>https://docs.microsoft.com/archive/blogs/myazureworld/securing-azure-hosted-asp-netwcf-with-ssl</link>
      <pubDate>Fri, 05 Aug 2011 11:06:00 GMT</pubDate>
      <dc:creator><![CDATA[Zafar Mohammed - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/myazureworld/2011/08/05/securing-azure-hosted-asp-netwcf-with-ssl/</guid>
      <description><![CDATA[The exercise below details the steps to secure azure with SSL really well.
Exercise 4: Securing...]]></description>
      <content:encoded><![CDATA[<p>The exercise below details the steps to secure azure with SSL really well.</p>
<p>Exercise 4: Securing Windows Azure with SSL</p>
<p><a href="https://msdn.microsoft.com/en-us/gg271302">https://msdn.microsoft.com/en-us/gg271302</a></p>
<p>In the exercise above, it uses self-signed certificates. Everything should work smoothly until developer decides to use certificate issued by certificate authorities in production. When using certificates from certificate authorities, you might see certificate errors like below in the browser when accessing the web site if all the certificates are not installed at the required certificate&nbsp; stores.</p>
<p>The security certificate presented by this website was not issued by a trusted certificate authority.</p>
<p>The security certificate presented by this website was issued for a different website's address.</p>
<p>When you view the certificate, it might show up something like this.</p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/46/05/8203.certificate%20detail.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-46-05/8203.certificate-detail.jpg"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/46/05/8203.certificate%20detail.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-46-05/8203.certificate-detail.jpg" /></a></p>
<p></p>
<p>What the above error means is that the certificate chain building failed as it is not able to locate its issuer details and trust the certification authority.</p>
<p>You can avoid this error by simply making sure that all the certificates are deployed/installed on the azure VM. This can be done by adding all the relevant certificates in the "Certificates" tab for the web role in cloud project before deploying to azure as shown below.</p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/46/05/5736.azuredeploymentcerts.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-46-05/5736.azuredeploymentcerts.jpg"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/46/05/5736.azuredeploymentcerts.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-46-05/5736.azuredeploymentcerts.jpg" width="638" height="203" /></a></p>
<p>&nbsp;</p>
<p></p>
<p>&nbsp;</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Azure DiagnosticMonitor - Custom Logs</title>
      <link>https://docs.microsoft.com/archive/blogs/myazureworld/azure-diagnosticmonitor-custom-logs</link>
      <pubDate>Thu, 28 Jul 2011 09:36:00 GMT</pubDate>
      <dc:creator><![CDATA[Zafar Mohammed - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/myazureworld/2011/07/28/azure-diagnosticmonitor-custom-logs/</guid>
      <description><![CDATA[Azure Diagnostics custom logs are not moving to the storage account.&nbsp; I've configured the...]]></description>
      <content:encoded><![CDATA[<p>Azure Diagnostics custom logs are not moving to the storage account.&nbsp; I've configured the diagnostics as follows for custom logs.</p>
<p><span style="background-color: #ffff00;">Code in OnStart method:</span></p>
<p>// Get the default initial configuration for DiagnosticMonitor.</p>
<p>DiagnosticMonitorConfiguration diagnosticConfiguration = DiagnosticMonitor.GetDefaultInitialConfiguration();</p>
<p>// Set scheduled transfer interval for infrastructure logs to 1 minute</p>
<p>diagnosticConfiguration.DiagnosticInfrastructureLogs.ScheduledTransferPeriod = System.TimeSpan.FromMinutes(10);</p>
<p>// Specify a logging level to filter records to transfer</p>
<p>diagnosticConfiguration.DiagnosticInfrastructureLogs.ScheduledTransferLogLevelFilter = LogLevel.Error;</p>
<p>// Create a new DirectoryConfiguration object.</p>
<p>DirectoryConfiguration directoryConfiguration = new DirectoryConfiguration();</p>
<p>// Add the name for the blob container in Windows Azure storage.</p>
<p>directoryConfiguration.Container = "wad-custom-logs";</p>
<p>// Add the directory size quota.</p>
<p>directoryConfiguration.DirectoryQuotaInMB = 2048;</p>
<p>// Add the log path for the role using RoleEnvironment.GetLocalResource().</p>
<p>directoryConfiguration.Path = RoleEnvironment.GetLocalResource("MyCustomLogs").RootPath;</p>
<p>// Add the directoryConfiguration to the Directories collection.</p>
<p>diagnosticConfiguration.Directories.DataSources.Add(directoryConfiguration);</p>
<p>// Schedule a transfer period of 5 minutes.</p>
<p>diagnosticConfiguration.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(5.0);</p>
<p>diagnosticConfiguration.Logs.ScheduledTransferPeriod = System.TimeSpan.FromMinutes(10);</p>
<p>// Start the DiagnosticMonitor using the diagnosticConfig and our connection string.</p>
<p>DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagnosticConfiguration);</p>
<p>&nbsp;</p>
<p><span style="background-color: #ffff00;">Configuration in Service Definition file:</span></p>
<p>&lt;LocalResources&gt;</p>
<p>&lt;LocalStorage name="DiagnosticStore" sizeInMB="8192" cleanOnRoleRecycle="false"/&gt;</p>
<p>&lt;LocalStorage name="MyCustomLogs" sizeInMB="2048" cleanOnRoleRecycle="false" /&gt;</p>
<p>&lt;/LocalResources&gt;</p>
<p>&nbsp;</p>
<p><span style="background-color: #ffff00;">ServiceConfiguraiton.csfg content:</span></p>
<p>&lt;ServiceConfiguration serviceName="CustomLogDiagnostics" xmlns="https://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="1" osVersion="*"&gt;</p>
<p>&lt;Role name="WebRole1"&gt;</p>
<p>&lt;Instances count="1" /&gt;</p>
<p>&lt;ConfigurationSettings&gt;</p>
<p>&lt;Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=wcftracesample;AccountKey=QW340M3uUVGc3Y9CEkg2hZ1VIhuWGX8ZLbaDY97FJI+tPguwrFlpmf5i13Rq2Mcb1J1SeIfUs4ce9PQc4/WA3w==" /&gt;</p>
<p>&lt;Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled" value="true" /&gt;</p>
<p>&lt;Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountUsername" value="RemoteUser" /&gt;</p>
<p>&lt;Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountEncryptedPassword" value="MIIBnQYJKoZIhvcNAQcDoIIBjjCCAYoCAQAxggFOMIIBSgIBADAyMB4xHDAaBgNVBAMME1dpbmRvd3MgQXp1cmUgVG9vbHMCEEVj/zzTXtqlSuKR51zsoVswDQYJKoZIhvcNAQEBBQAEggEAOLeYLcBlAX88/9SU1Z2b7wlgGd6AWqwU7I4t7Lv4KTEhNNLrnqrshNSSbqISRVpWycx66dbMoJUJ2nxAvyN0TFt0uocAjivnFU1/rUvaSCaBXOCUhHe4OfHh1wUSRjzMn/H177y0elMC+/AwFILbMwakVxgFrqCFBroE6K9CpD1yYH7q9Ic9YMGAukRo7HgOJ5nq24hfCZ0G2CyT5mEMb09j6/4IhtYiYNsVYNSpaq+bQdvrXEEzRIVdMdZsAtNfP/2gFCt/tTHcavsoOeHZYgZ3GIeo+bihOKFRJTOWsECyPNr9fgFR9TeDdK8IOU42IyBmhUHvTVeVnf8YbmVmuzAzBgkqhkiG9w0BBwEwFAYIKoZIhvcNAwcECNHwIT0gVndfgBA9CD+sBmMV0EcGMdwVaqn/" /&gt;</p>
<p>&lt;Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration" value="2011-08-22T23:59:59.0000000-05:00" /&gt;</p>
<p>&lt;Setting name="Microsoft.WindowsAzure.Plugins.RemoteForwarder.Enabled" value="true" /&gt;</p>
<p>&lt;/ConfigurationSettings&gt;</p>
<p>&lt;Certificates&gt;</p>
<p>&lt;Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="C8CB8231FA78C369D48BC23F690EC23A97CBD815" thumbprintAlgorithm="sha1" /&gt;</p>
<p>&lt;/Certificates&gt;</p>
<p>&lt;/Role&gt;</p>
<p>&lt;/ServiceConfiguration&gt;</p>
<p>As you can see above, everything is configured correct but the logs do not move to the storage account.</p>
<p>-&nbsp;&nbsp; Through some research, I was able to find that there are some permission issues in SDK 1.3 and 1.4 which would not let the diagnostics read the logs and move it to storage account.</p>
<p>-&nbsp;&nbsp; I used CACLS in the startup task to resolve the issue, basically gave everyone full rights on Resources folder.</p>
<p>CACLS C:\Resources /E /T /C /G "Everyone":F</p>
<p>CACLS in startup task can be used as a workaround until the problem is resolved in future versions of Azure SDK.</p>]]></content:encoded>
    </item>
    <item>
      <title>Hosting ASP.Net Application Services in Azure and Implement ClientApplicationServices</title>
      <link>https://docs.microsoft.com/archive/blogs/myazureworld/hosting-asp-net-application-services-in-azure-and-implement-clientapplicationservices</link>
      <pubDate>Thu, 28 Jul 2011 08:50:00 GMT</pubDate>
      <dc:creator><![CDATA[Zafar Mohammed - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/myazureworld/2011/07/28/hosting-asp-net-application-services-in-azure-and-implement-clientapplicationservices/</guid>
      <description><![CDATA[ASP.NET application services are built-in Web services that provide access to features such as forms...]]></description>
      <content:encoded><![CDATA[<p>ASP.NET application services are built-in Web services that provide access to features such as forms authentication, roles, and profile properties. These services are part of a service-oriented architecture (SOA), in which an application consists of one or more services provided on the server, and one or more clients.</p>
<p>Client applications for ASP.NET application services can be of different types and can run on different operating systems. These include these following types of clients:</p>
<ul>
<li>AJAX clients. These are ASP.NET Web pages (.aspx files) that run in the browser and that access application services from client script. AJAX clients typically use JSON format to exchange data. For more information, see <a href="https://msdn.microsoft.com/en-us/library/bb515101.aspx">Using Web Services in ASP.NET AJAX</a>.</li>
<li>.NET Framework clients. These are .NET Framework Windows applications that access application services over HTTP by using the provider model infrastructure, and that use JSON protocol to exchange data. For more information, see <a href="https://msdn.microsoft.com/en-us/library/bb384339.aspx">Client Application Services Overview</a>.</li>
<li>SOAP clients. These are clients that can access application services through SOAP 1.1. This is useful for clients that are running on other operating systems or using other technologies, such as Java applications. For more information, see <a href="https://msdn.microsoft.com/en-us/library/bb515342.aspx">Walkthrough: Using ASP.NET Application Services</a>.</li>
</ul>
<p>Hosting ASP.Net application Services in Azure is no different from hosting in on-premise server.&nbsp; The scenario that I've discussed in this blog is ASP.Net Client Application Services set-up and it's handling of cookies.</p>
<ol>
<li>Set up Membership Database in SQL Azure - <a href="https://support.microsoft.com/kb/2006191/">https://support.microsoft.com/kb/2006191/</a></li>
<li>Set up ASP.Net Application Services in Azure: Add/Edit the web.config (before deploying it to Azure) for the web role project to enable authentication and role service.</li>
</ol>
<p style="padding-left: 60px;">&nbsp;&nbsp;&lt;connectionStrings&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp; &lt;remove name="myConnection"/&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp; &lt;add name="myConnection" connectionString="Server=tcp:blah.database.windows.net,1433;Database=ASPNetDatabase;User ID=user@blah;Password=blah;Trusted_Connection=False;Encrypt=True;" providerName="System.Data.SqlClient"/&gt;</p>
<p style="padding-left: 60px;">&nbsp; &lt;/connectionStrings&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&lt;authentication mode="Forms"&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;forms protection="Validation" cookieless="UseDeviceProfile" timeout="1" slidingExpiration="false" /&gt;</p>
<p style="padding-left: 60px;">&nbsp;&lt;/authentication&gt;</p>
<p style="padding-left: 60px;">&nbsp;&lt;roleManager enabled="true" defaultProvider="CustomSqlRoleProvider"&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;providers&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add name="CustomSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="myConnection" applicationName="myApplication" /&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/providers&gt;</p>
<p style="padding-left: 60px;">&nbsp;&lt;/roleManager&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&lt;membership defaultProvider="SqlMembershipProvider" hashAlgorithmType="SHA1"&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;providers&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add applicationName="myApplication" connectionStringName="myConnection"</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enablePasswordReset="true" enablePasswordRetrieval="false" passwordFormat="Hashed"</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7"</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; minRequiredNonalphanumericCharacters="0" requiresQuestionAndAnswer="false"</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; requiresUniqueEmail="false" passwordAttemptWindow="5" passwordStrengthRegularExpression=""</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name="SqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" /&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/providers&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&lt;/membership&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&lt;system.web.extensions&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp; &lt;scripting&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;webServices&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;authenticationService enabled="true"/&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;roleService enabled="true"/&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/webServices&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp; &lt;/scripting&gt;</p>
<p style="padding-left: 60px;">&nbsp; &lt;/system.web.extensions&gt;</p>
<p>&nbsp;</p>
<ol>
<li value="3">Confiugre Client Application Services (Windows Forms Client) as per the MSDN documentation - <a href="https://msdn.microsoft.com/en-us/library/bb384312.aspx">https://msdn.microsoft.com/en-us/library/bb384312.aspx</a></li>
<li>With the above three steps, you are all set to use the ASP.Net application services from a Windows Forms Client. Now comes the most interesting part, how do we handle authentication cookies in ClientApplicationServices? If it were ASP.Net client, when the cookie expires the application would automatically be redirected to the login page. There's no way windows forms application using client application services would have some functionality like that. However, there's a solution that exists and documented well on MSDN.</li>
</ol>
<p style="padding-left: 60px;">&nbsp;There are two steps to it, first make sure that cookie timeout is properly set in the forms element as shown below.</p>
<p style="padding-left: 60px;">&nbsp;&lt;authentication mode="Forms"&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;forms protection="Validation" cookieless="UseDeviceProfile" timeout="1" slidingExpiration="false" /&gt;</p>
<p style="padding-left: 60px;">&nbsp;&lt;/authentication&gt;</p>
<p style="padding-left: 60px;">Note: slidingExpiration should be set to false. Otherwise, for every successful login (like user validation) attempt by the user - last activity time and hence cookie time out gets reset. For more information, read MSDN documentation <a href="https://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.slidingexpiration.aspx">here</a>.</p>
<p style="padding-left: 60px;">The next step is to check for the cookie expiration and one of the ways to do it is to call GetRolesForUser for the logged in user. The key to this is that all the valid users should be assigned to roles.&nbsp; If no roles are returned, the login has expired. For more information, read MSDN documentation <a href="https://technet.microsoft.com/en-us/library/bb546195(VS.90).aspx">here</a>.</p>
<p style="padding-left: 60px;">Here's some sample code:</p>
<p style="padding-left: 60px;">&nbsp;System.Security.Principal.IIdentity identity =</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Threading.Thread.CurrentPrincipal.Identity;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Return if the authentication type is not "ClientForms".</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // This indicates that the user is logged out.</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!identity.AuthenticationType.Equals("ClientForms")) return;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ClientRoleProvider provider =</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (ClientRoleProvider)System.Web.Security.Roles.Provider;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String userName = identity.Name;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Determine whether the user login has expired by attempting</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // to retrieve roles from the service. Call the ResetCache method</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // to ensure that the roles are retrieved from the service. If no</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // roles are returned, then the login has expired. This assumes</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // that every valid user has been assigned to one or more roles.</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; provider.ResetCache();</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String[] roles = provider.GetRolesForUser(userName);</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (roles.Length == 0)</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MessageBox.Show(</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Your login has expired. Please log in again to access " +</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "the roles service.", "Attempting to access user roles...");</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (provider.IsUserInRole(userName, "Power Users"))</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MessageBox.Show("User is still active");</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (System.Net.WebException)</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MessageBox.Show(</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Unable to access the remote service. " +</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Cannot retrieve user roles.", "Warning",</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MessageBoxButtons.OK, MessageBoxIcon.Warning);</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p style="padding-left: 60px;">&nbsp;</p>
<p style="padding-left: 60px;">Note: Some developers would try IsInRole method of the role service to check for expiration but it doesn't work always. The IsInRole method will always return false if the user login has expired. This will not occur if your application calls the IsInRole method one time shortly after authentication.</p>
<p>&nbsp;The sample project that I used is available for download!</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/19/07/55/ASPNetAJAXAuthentication.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-19-07-55/ASPNetAJAXAuthentication.zip">ASPNetAJAXAuthentication.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Azure Deployment Aborted - DiagnosticMonitorConfiguration.OverallQuotaInMB</title>
      <link>https://docs.microsoft.com/archive/blogs/myazureworld/azure-deployment-aborted-diagnosticmonitorconfiguration-overallquotainmb</link>
      <pubDate>Fri, 22 Jul 2011 14:49:00 GMT</pubDate>
      <dc:creator><![CDATA[Zafar Mohammed - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/myazureworld/2011/07/22/azure-deployment-aborted-diagnosticmonitorconfiguration-overallquotainmb/</guid>
      <description><![CDATA[I ran into an interesting issue today while configuring custom log directory in Azure...]]></description>
      <content:encoded><![CDATA[<p>I ran into an interesting issue today while configuring custom log directory in Azure Diagnostics.&nbsp; The role was aborting with the following code in OnStart method.</p>
<p>public override bool OnStart()<br />{<br />&nbsp;&nbsp;&nbsp; // Get the default initial configuration for DiagnosticMonitor.<br />&nbsp;&nbsp;&nbsp; DiagnosticMonitorConfiguration diagnosticConfiguration = DiagnosticMonitor.GetDefaultInitialConfiguration();</p>
<p>// Create a new DirectoryConfiguration object.<br />&nbsp;&nbsp;&nbsp; DirectoryConfiguration directoryConfiguration = new DirectoryConfiguration();</p>
<p>// Add the name for the blob container in Windows Azure storage.<br />&nbsp;&nbsp;&nbsp; directoryConfiguration.Container = "wad-custom-logs";</p>
<p>// Add the directory size quota.<br />&nbsp;&nbsp;&nbsp; directoryConfiguration.DirectoryQuotaInMB = 2048;</p>
<p>// Add the log path for the role using RoleEnvironment.GetLocalResource().<br />&nbsp;&nbsp;&nbsp; directoryConfiguration.Path = RoleEnvironment.GetLocalResource("MyCustomLogs").RootPath;</p>
<p>// Add the directoryConfiguration to the Directories collection.<br />&nbsp;&nbsp;&nbsp; diagnosticConfiguration.Directories.DataSources.Add(directoryConfiguration);</p>
<p>// Schedule a transfer period of 30 minutes.<br />&nbsp;&nbsp;&nbsp; diagnosticConfiguration.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(30.0);</p>
<p>// Start the DiagnosticMonitor using the diagnosticConfig and our connection string.<br />&nbsp;&nbsp;&nbsp; DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagnosticConfiguration);</p>
<p>return base.OnStart();<br />}</p>
<p>The code itself is pretty straight forward and you wouldn't expect any kind of failures in deployment. However, it failed. After several hours of troubleshooting, I thought of checking what would happen if I use development storage, so changed the DiagnosticMonitor.Start <span style="background-color: #ffff00;">from DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagnosticConfiguration) to DiagnosticMonitor.Start(CloudStorageAccount.DevelopmentStorageAccount, diagnosticConfiguration)</span></p>
<p>&nbsp;</p>
<p>The local deployment failed with the below exception:</p>
<p><span style="background-color: #ffff00;">System.ArgumentException was unhandled</span></p>
<p><span style="background-color: #ffff00;">&nbsp; Message=OverallQuotaInMB is 4080MB but sum of requested sub-quotas is 5120MB.</span></p>
<p>Parameter name: initialConfiguration</p>
<p>&nbsp; Source=Microsoft.WindowsAzure.Diagnostics</p>
<p>&nbsp; ParamName=initialConfiguration</p>
<p>&nbsp; StackTrace:</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitor.StartWithExplicitConfiguration(DiagnosticMonitorStartupInfo startupInfo, DiagnosticMonitorConfiguration initialConfiguration)</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitor.Start(CloudStorageAccount storageAccount, DiagnosticMonitorConfiguration initialConfiguration)</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at WebRole1.WebRole.OnStart() in D:\VS Projects\Visual Studio 2010\Projects\CustomLogDiagnostics\WebRole1\WebRole.cs:line 64</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(RoleType roleTypeEnum)</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRole(RoleType roleType)</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.&lt;InitializeRole&gt;b__0()</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Threading.ExecutionContext.runTryCode(Object userData)</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.Threading.ThreadHelper.ThreadStart()</p>
<p>It was a good breakthrough after several hours of troubleshooting. I then checked the documentation for OverAllQuotaInMB for diagnostic monitor and found it to be default value of 4GB as stated in the exception.</p>
<p><a href="https://msdn.microsoft.com/en-us/library/microsoft.windowsazure.diagnostics.diagnosticmonitorconfiguration.overallquotainmb.aspx">https://msdn.microsoft.com/en-us/library/microsoft.windowsazure.diagnostics.diagnosticmonitorconfiguration.overallquotainmb.aspx</a></p>
<p>Looking at the exception, you would think I can increase the OverAllQuotaInMB for the diagnostic monitor and resolve the issue. However, that's not it. <span style="background-color: #ffff00;">The catch is OverallQuotaInMB can only be set to a lower value but not higher.</span> The actual solution lies in the service definition file under LocalResources section. Here's a service definition&nbsp;configuration that should work.</p>
<p>&lt;LocalResources&gt;</p>
<p>&nbsp;&nbsp;&nbsp;<span style="background-color: #ffff00;"> &lt;LocalStorage name="DiagnosticStore" sizeInMB="8192" cleanOnRoleRecycle="false"/&gt;</span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&lt;LocalStorage name="MyCustomLogs" sizeInMB="2048" cleanOnRoleRecycle="false" /&gt;</p>
<p>&lt;/LocalResources&gt;</p>]]></content:encoded>
    </item>
    <item>
      <title>How to restrict unwanted IPs to access your site in Azure environment?</title>
      <link>https://docs.microsoft.com/archive/blogs/myazureworld/how-to-restrict-unwanted-ips-to-access-your-site-in-azure-environment</link>
      <pubDate>Thu, 21 Jul 2011 15:52:00 GMT</pubDate>
      <dc:creator><![CDATA[Zafar Mohammed - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/myazureworld/2011/07/21/how-to-restrict-unwanted-ips-to-access-your-site-in-azure-environment/</guid>
      <description><![CDATA[This is a very frequently asked question, not just in the Azure world!
How to restrict unwanted IPs...]]></description>
      <content:encoded><![CDATA[<p>This is a very frequently asked question, not just in the Azure world!</p>
<p>How to restrict unwanted IPs to access your site in Azure environment?</p>
<p>There are two parts to it, as listed below:</p>
<p>1. Static IP Restriction - where you know the list of IPs that you would like to restrict.</p>
<p>Follow this blog - <a href="https://www.iis.net/ConfigReference/system.webServer/security/ipSecurity">https://www.iis.net/ConfigReference/system.webServer/security/ipSecurity</a> &nbsp;<br /><br />Command script to enable static IPSecurity on Azure role: <br />@echo off <br />@echo <br />Installing "IPv4 Address and Domain Restrictions" feature <br /><br />%windir%\System32\ServerManagerCmd.exe -install Web-IP-Security <br />@echo <br />Unlocking configuration for "IPv4 Address and Domain Restrictions" feature <br /><br />%windir%\system32\inetsrv\AppCmd.exe unlock config <br />-section:system.webServer/security/ipSecurity</p>
<p>2. Dynamic IP Restriction - where you would be able to&nbsp;monitor the unwanted IPs actively and then apply the restriction</p>
<p>Follow this blog - <a href="https://learn.iis.net/page.aspx/548/using-dynamic-ip-restrictions">https://learn.iis.net/page.aspx/548/using-dynamic-ip-restrictions</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Hosting PHP/ZEND Framework applications in Windows Azure Web Role (Full IIS)</title>
      <link>https://docs.microsoft.com/archive/blogs/myazureworld/hosting-phpzend-framework-applications-in-windows-azure-web-role-full-iis</link>
      <pubDate>Wed, 20 Jul 2011 12:01:00 GMT</pubDate>
      <dc:creator><![CDATA[Zafar Mohammed - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/myazureworld/2011/07/20/hosting-phpzend-framework-applications-in-windows-azure-web-role-full-iis/</guid>
      <description><![CDATA[Symptom: Unable to host application using ZEND framwork and PHP.&nbsp; The role gets started but...]]></description>
      <content:encoded><![CDATA[<p style="margin: 0in; color: black; font-family: Tahoma; font-size: 10pt;">Symptom: Unable to host application using ZEND framwork and PHP.&nbsp; The role gets started but runtime issues occur. Here's one of the errors logged in the application event log &amp; browser indicating PHP prcess in crashing.</p>
<p style="margin: 0in; color: black; font-family: Tahoma; font-size: 10pt;">&nbsp;</p>
<p style="margin: 0in; color: black; font-family: Tahoma; font-size: 10pt;">Log Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Application<br />Source:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Application<br />Error<br />Date:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />4/21/2011 9:12:11 PM<br />Event ID:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1000<br />Task Category: (100)<br />Level:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Error<br />Keywords:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Classic<br />User:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />N/A</p>
<p>Computer:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RD00155D38277C<br />Description:<br /><span style="background-color: #ffff00;">Faulting</span><br /><span style="background-color: #ffff00;">application php-cgi.exe, version 5.3.1.0, time stamp 0x4b06c42f, faulting module php-cgi.exe, version 5.3.1.0, time stamp 0x4b06c42f, exception code 0xc0000005, fault offset 0x0000191a, process id 0x618, application start time 0x01cc0068c7d3bcdd.</span></p>
<p style="margin: 0in; color: black; font-family: Tahoma; font-size: 10pt;">Upon running processmon, found out that ZEND framework files were not being located. &nbsp;Process monitor basically complained about not finding the path for zend specific files. I could see that, F:\approot\php\php.ini (configuration file) is where it has configured all the paths listed below. I would expect them to be directed somewhere under F:\approot\php directory instead.</p>
<p style="margin: 0in; color: black; font-family: Tahoma; font-size: 10pt;">29:20.3 php-cgi.exe 2324 CreateFile C:\xampp\php\extras\ PATH NOT FOUND</p>
<p style="margin: 0in; color: black; font-family: Tahoma; font-size: 10pt;">29:20.3 php-cgi.exe 2324 CreateFile C:\xampp\php\ PATH NOT FOUND</p>
<p style="margin: 0in; color: black; font-family: Tahoma; font-size: 10pt;">29:20.3 php-cgi.exe 2324 CreateFile C:\xampp\php\extras\browscap.ini PATH NOT FOUND}</p>
<p style="margin: 0in; color: black; font-family: Tahoma; font-size: 10pt;">&nbsp;</p>
<p style="margin: 0in; color: black; font-family: Tahoma; font-size: 10pt;">Here's a good video and corresponding blog that lets you put PHP on IIS.</p>
<p style="margin: 0in; color: black; font-family: Tahoma; font-size: 10pt;"><a href="https://channel9.msdn.com/posts/php-azure">https://channel9.msdn.com/posts/php-azure</a></p>
<p style="margin: 0in; color: black; font-family: Tahoma; font-size: 10pt;"><a href="https://rhizohm.net/irhetoric/post/2011/04/18/How-To-Do-PHP-Deployment-To-Windows-Azure.aspx">https://rhizohm.net/irhetoric/post/2011/04/18/How-To-Do-PHP-Deployment-To-Windows-Azure.aspx</a></p>
<p style="margin: 0in; font-family: Calibri; font-size: 11pt;">&nbsp;</p>
<p style="margin: 0in; color: black; font-family: Tahoma; font-size: 10pt;">Just go through the above video and blog, find the section where it talks about copying the files using the Start-up task. Since the issue is with not being able to find the zend framework specific files and folders as indicated above, you can also create a startup task to copy all the files and folders under &ldquo;c:\xampp\php&rdquo; to &ldquo;F:\approot\php&rdquo;</p>
<p style="margin: 0in; font-family: Calibri; font-size: 11pt;">&nbsp;</p>
<p style="margin: 0in; color: black; font-family: Tahoma; font-size: 10pt;">Here&rsquo;s how you can do it:</p>
<p style="margin: 0in; font-family: Calibri; font-size: 11pt;">&nbsp;</p>
<p style="margin: 0in; color: black; font-family: Tahoma; font-size: 10pt;">My research led me to conclude that the ZEND framework is generally installed at C:\xmapp\php (at least in case of using apache server, it could be a different location if installing for IIS), copy all the files and sub-folders under &ldquo;C:\xmapp\php&rdquo; or any relevant location&nbsp;to a folder call &ldquo;putmoduleshere&rdquo; within your application folder on the development machine like explained in the blog/video above. You can then use a similar startup task of copy files and do an xcopy as below.</p>
<p style="margin: 0in; font-family: Calibri; font-size: 11pt;">&nbsp;</p>
<p style="margin: 0in; color: black; font-family: Tahoma; font-size: 10pt;">xcopy "..\putmoduleshere\*.*" "%approot%\PHP\"</p>]]></content:encoded>
    </item>
    <item>
      <title>WCF Tracing in Windows Azure SDK 1.3 or higher</title>
      <link>https://docs.microsoft.com/archive/blogs/myazureworld/wcf-tracing-in-windows-azure-sdk-1-3-or-higher</link>
      <pubDate>Wed, 20 Jul 2011 11:41:00 GMT</pubDate>
      <dc:creator><![CDATA[Zafar Mohammed - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/myazureworld/2011/07/20/wcf-tracing-in-windows-azure-sdk-1-3-or-higher/</guid>
      <description><![CDATA[WCF Tracing in on-premise servers - https://msdn.microsoft.com/en-us/library/ms733025.aspx
WCF...]]></description>
      <content:encoded><![CDATA[<ul>
<li>WCF Tracing in on-premise servers - <a href="https://msdn.microsoft.com/en-us/library/ms733025.aspx">https://msdn.microsoft.com/en-us/library/ms733025.aspx</a></li>
<li>WCF Tracing in on-premise servers with intermittent failures &ndash; Enable Circular tracing: <a href="https://msdn.microsoft.com/en-us/library/aa395205.aspx">https://msdn.microsoft.com/en-us/library/aa395205.aspx</a></li>
<li>&nbsp;WCF Tracing in Azure:</li>
<ul>
<li>As most of you already know, WCF Service Web Role implements WCF tracing by default and puts it in the local storage. However, it's disabled by default. All you have to do to enable is to uncomment certain configuration in web.config as shown below.</li>
<ul>
<li>&nbsp;<span style="background-color: #ffff00;">Change &lt;system.diagnostics&gt; tag from:</span></li>
</ul>
</ul>
</ul>
<p style="padding-left: 120px;">&lt;!--&lt;system.diagnostics&gt;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&lt;sharedListeners&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add name="AzureLocalStorage" type="WCFServiceWebRole1.AzureLocalStorageTraceListener, WCFServiceWebRole1"/&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp; &lt;/sharedListeners&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp; &lt;sources&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;source name="System.ServiceModel" switchValue="Verbose, ActivityTracing"&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;listeners&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add name="AzureLocalStorage"/&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/listeners&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/source&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;source name="System.ServiceModel.MessageLogging" switchValue="Verbose"&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;listeners&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add name="AzureLocalStorage"/&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/listeners&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/source&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp; &lt;/sources&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&lt;/system.diagnostics&gt;--&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&lt;system.diagnostics&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp; &lt;trace autoflush="true"&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;listeners&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name="AzureDiagnostics"&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;filter type="" /&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/add&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/listeners&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp; &lt;/trace&gt;</p>
<p style="padding-left: 120px;">&nbsp; &lt;/system.diagnostics&gt;</p>
<p>&nbsp;</p>
<ul>
<ul>
<ul>
<li><span style="background-color: #ffff00;">To:</span></li>
</ul>
</ul>
</ul>
<p style="padding-left: 120px;">&nbsp; &lt;system.diagnostics&gt;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&lt;sharedListeners&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add name="AzureLocalStorage" type="WCFServiceWebRole1.AzureLocalStorageTraceListener, WCFServiceWebRole1"/&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp; &lt;/sharedListeners&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp; &lt;sources&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;source name="System.ServiceModel" switchValue="Verbose, ActivityTracing"&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;listeners&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add name="AzureLocalStorage"/&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/listeners&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/source&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;source name="System.ServiceModel.MessageLogging" switchValue="Verbose"&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;listeners&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add name="AzureLocalStorage"/&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/listeners&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/source&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp; &lt;/sources&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&lt;trace autoflush="true"&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;listeners&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name="AzureDiagnostics"&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;filter type="" /&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/add&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/listeners&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp; &lt;/trace&gt;</p>
<p style="padding-left: 120px;">&nbsp; &lt;/system.diagnostics&gt;</p>
<p>&nbsp;</p>
<ul>
<ul>
<ul>
<li>And add the diagnostics tag in &lt;system.servicemodel&gt;</li>
</ul>
</ul>
</ul>
<p style="padding-left: 120px;">&lt;system.serviceModel&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp; &lt;diagnostics&gt;&lt;messageLogging maxMessagesToLog="3000" logEntireMessage="true" logMessagesAtServiceLevel="true" logMalformedMessages="true" logMessagesAtTransportLevel="true" /&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/diagnostics&gt;</p>
<p style="padding-left: 120px;">&nbsp;&nbsp;&nbsp; &lt;behaviors&gt;</p>
<p style="padding-left: 120px;">&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;</p>
<p style="padding-left: 90px;">&nbsp;</p>
<ul>
<li>Now, what if you decided to deploy the WCF service web role without enabling WCF trace in the local storage? The answer is, we can still enable WCF tracing like any other non-Azure application and write it on the web/worker role. Here&rsquo;s the configuration:</li>
</ul>
<p style="padding-left: 60px;">&nbsp;&nbsp; &lt;system.diagnostics&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp; &lt;sources&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;source name="System.ServiceModel" switchValue="Information,ActivityTracing,Warning" propagateActivity="true"&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;listeners&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add name="xml" /&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/listeners&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/source&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;source name="System.ServiceModel.MessageLogging"&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;listeners&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add name="xml" /&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/listeners&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/source&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp; &lt;/sources&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp; &lt;sharedListeners&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add initializeData="C:\CTS\WCFTrace.svclog" type="System.Diagnostics.XmlWriterTraceListener"</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name="xml" /&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp; &lt;/sharedListeners&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp; &lt;trace autoflush="true" &gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;listeners&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name="AzureDiagnostics"&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;filter type="" /&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/add&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/listeners&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp; &lt;/trace&gt;</p>
<p style="padding-left: 60px;">&nbsp; &lt;/system.diagnostics&gt;</p>
<p style="padding-left: 60px;">&nbsp;</p>
<p style="padding-left: 60px;">&nbsp; &lt;system.serviceModel&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp; &lt;diagnostics&gt;</p>
<p style="padding-left: 60px;">&nbsp;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;messageLogging logEntireMessage="true"</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxMessagesToLog="300"</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; logMessagesAtServiceLevel="true"</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; logMalformedMessages="true"</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; logMessagesAtTransportLevel="true" /&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp; &lt;/diagnostics&gt;</p>
<p style="padding-left: 60px;">&nbsp;&nbsp;&nbsp; &lt;behaviors&gt;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;</p>
<p style="padding-left: 60px;">&nbsp;</p>
<p style="padding-left: 30px;">However, the trace will not be generated just with the above configuration. If you run procmon, you would see &ldquo;Access Denied&rdquo; on CreateFile for &ldquo;C:\CTS\WCFTrace.svclog&rdquo; that I&rsquo;ve in the configuration for logging WCF trace. Open up task manager and you would see w3wp.exe (remember &ndash; it&rsquo;s full IIS) running under Network Service account. This account needs to have permissions to write on the folder configured to store WCF traces. Just give &ldquo;Everyone&rdquo; write permissions on the folder and get it to work!!</p>
<p style="padding-left: 30px;">Since regular tracing works, I don&rsquo;t expect any issues running circular (rolling) tracing in the Azure environment.</p>]]></content:encoded>
    </item>
  </channel>
</rss>