<?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>Head in the Cloud</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/hmahrt/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/hmahrt/feed.xml</link>
    <description>Sharing my PaaSion (oh, and I like silly puns)</description>
    <lastBuildDate>Tue, 16 Apr 2019 05:10:21 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Azure Active Directory B2C and Azure Functions</title>
      <link>https://docs.microsoft.com/archive/blogs/hmahrt/azure-active-directory-b2c-and-azure-functions</link>
      <pubDate>Tue, 07 Mar 2017 09:00:29 GMT</pubDate>
      <dc:creator><![CDATA[Helge Mahrt]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hmahrt/?p=366</guid>
      <description><![CDATA[Hello everyone, 

In the light of my recent post about B2C and ASP.NET Core web APIs, I thought...]]></description>
      <content:encoded><![CDATA[Hello everyone, 

In the light of my <a href="https://blogs.msdn.microsoft.com/hmahrt/2017/03/06/azure-active-directory-b2c-build-an-asp-net-core-mvc-web-api/" target="_blank">recent post about B2C and ASP.NET Core web APIs</a>, I thought I'd shed some light on how to make <a href="https://docs.microsoft.com/en-us/azure/azure-functions/functions-overview" target="_blank">Azure Functions</a> work with B2C, because it may not be immediately obvious from the portal's interface. Actually, all the information is already in this article, and it still applies: <a href="https://blogs.msdn.microsoft.com/appserviceteam/2016/06/22/app-service-auth-and-azure-ad-b2c/" target="_blank">https://blogs.msdn.microsoft.com/appserviceteam/2016/06/22/app-service-auth-and-azure-ad-b2c/</a>

&nbsp;
Setting up B2C authentication for your Azure Functions App is actually really easy:
<ol>
<li><p style="font-size:large">Create your <b>Azure Functions App</b> and write down the URL</p></p>
<ol type="a">
<li>E.g. <i>https://myazurefunctions.azurewebsites.net</i> (make sure to make it a HTTPS URL)</li>
</ol>

&nbsp;

</li>
<li><p style="font-size:large">Configure your application in <b>Azure Active Directory B2C</b>:</p>
<ol type="a">
<li>Write down the <b>Application ID</b></li>
<li>Add a reply URL for your Functions App, adding the suffix <b>/.auth/login/aad/callback</b>. E.g. <i>https://myazurefunctions.azurewebsites.net/.auth/login/aad/callback</i></li>
</ol>
<p>

&nbsp;

The configuration should look something like this:
<img src="https://msdnshared.blob.core.windows.net/media/2017/03/030617_1846_AzureActive1.png" alt="" />

&nbsp;

</p>
</li>
<li><p style="font-size:large">Get the Metadata Endpoint URL for your Sign-in policy</p>
<ol type="a">
<li>
If you open the details of your sign-in policy, you'll find it right at the top. E.g.:
<p>
<img src="https://msdnshared.blob.core.windows.net/media/2017/03/030617_1846_AzureActive2.png" alt="" />

&nbsp;

</p>
</li>
</ol>
</li>
<li><p style="font-size:large">In your Functions App, on the bottom left select "Function app settings" and go to "Configure authentication":</p>
<p>
<img src="https://msdnshared.blob.core.windows.net/media/2017/03/030617_1846_AzureActive3.png" alt="" />

&nbsp;

</p>
</li>
<li><p style="font-size:large">Turn on authentication and select <b>Azure Active Directory</b>:</p>
<p>
<img src="https://msdnshared.blob.core.windows.net/media/2017/03/030617_1846_AzureActive4.png" alt="" />

&nbsp;

</p>
</li>
<li><p style="font-size:large">Select the <b>advanced</b> settings and enter the following values:</p>
<ol type="a">
<li>Client ID: The <b>Application ID</b> which you copied in step 2. a.</li>
<li>Issuer Url: The Metadata Endpoint URL from step 3.</li>
</ol>

&nbsp;

</li>
<li><p style="font-size:large">Save your settings and you're done!</p>
</li>
</ol>

&nbsp;

Once the changes have taken effect, if you try to test your Azure Function without an <b>Authorization</b> header, you'll get the following error – as expected:
<img src="https://msdnshared.blob.core.windows.net/media/2017/03/030617_1846_AzureActive5.png" alt="" />

&nbsp;

However, with a valid bearer token, you're up and running again:
<img src="https://msdnshared.blob.core.windows.net/media/2017/03/030617_1846_AzureActive6.png" alt="" />

&nbsp;

I hope this made your life a little bit easier.

Cheers,
Helge Mahrt]]></content:encoded>
    </item>
    <item>
      <title>Azure Active Directory B2C: Build an ASP.NET Core MVC web API</title>
      <link>https://docs.microsoft.com/archive/blogs/hmahrt/azure-active-directory-b2c-build-an-asp-net-core-mvc-web-api</link>
      <pubDate>Mon, 06 Mar 2017 09:00:09 GMT</pubDate>
      <dc:creator><![CDATA[Helge Mahrt]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hmahrt/?p=356</guid>
      <description><![CDATA[Hello everyone,

[Update]: I shared a sample solution on GitHub:...]]></description>
      <content:encoded><![CDATA[Hello everyone,

[Update]: I shared a sample solution on GitHub: <a target="_blank" href="https://github.com/helgemahrt/aspnetcore-api-with-b2c">https://github.com/helgemahrt/aspnetcore-api-with-b2c</a>

&nbsp;
The Azure Active Directory B2C documentation features a list of awesome quick-start guides for different scenarios: <a target="_blank" href="https://docs.microsoft.com/en-us/azure/active-directory-b2c/">https://docs.microsoft.com/en-us/azure/active-directory-b2c/</a> 
Unfortunately, there are only guides for good old .NET - but none about .NET Core yet (at least not at the time of writing). If you search the internet for B2C and aspnetcore, you'll find plenty of articles covering ASP.NET Core web apps (basically the equivalent to this guide: <a target="_blank" href="https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-devquickstarts-web-dotnet">https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-devquickstarts-web-dotnet</a>) but only very little on ASP.NET Core web APIs. 

&nbsp;
I spent a lot of time in the past couple of days trying to find the right combination of libraries and settings to make the OAuth Bearer authentication against B2C work in an ASP.NET Core web API. To save you that effort, here are the equivalents to the classic ASP.NET web API quick start guide, <a target="_blank" href="https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-devquickstarts-api-dotnet">https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-devquickstarts-api-dotnet</a>. Once you know what you have to do, it's actually pretty straight-forward. :)

&nbsp;
The only library you'll need is the following:
[sourcecode language="xml"]
    &quot;Microsoft.AspNetCore.Authentication.JwtBearer&quot;: &quot;1.0.0&quot;,
[/sourcecode]

&nbsp;
In your <b>Startup.cs</b>, add the following lines to your <b>Configure</b> function:
[sourcecode language="csharp"]
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    ...

    app.UseJwtBearerAuthentication(new JwtBearerOptions()
    {
        MetadataAddress = string.Format(AadInstance, Tenant, Policy),
        Audience = ClientId,
    });

    ...
}
[/sourcecode]

&nbsp;
In my case, I only added my B2C SignIn policy and it worked like a charm. I hope this saved you a headache searching for the right way to set this up.

Cheers,
Helge Mahrt]]></content:encoded>
    </item>
    <item>
      <title>Reducing the volume (and cost) of data sent to Application Insights</title>
      <link>https://docs.microsoft.com/archive/blogs/hmahrt/reducing-the-volume-and-cost-of-data-sent-to-application-insights</link>
      <pubDate>Wed, 01 Mar 2017 10:16:52 GMT</pubDate>
      <dc:creator><![CDATA[Helge Mahrt]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hmahrt/?p=305</guid>
      <description><![CDATA[Hello everyone,

In a project I have been working on recently we relied on Application Insights to...]]></description>
      <content:encoded><![CDATA[Hello everyone,

In a project I have been working on recently we relied on Application Insights to gather trace logging on the data which was being processed in our system. To achieve 100% traceability we disabled any kind of sampling on the client side and set Application Insights to ingest 100% of the data. After a couple of days of intensely testing the system, we realized that the data volume had gotten out of control: (as we might have expected)

<a href="https://msdnshared.blob.core.windows.net/media/2017/02/AI-high-cost.jpg"><img width="561" height="266" title="AI high cost" style="padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px" alt="AI high cost" src="https://msdnshared.blob.core.windows.net/media/2017/02/AI-high-cost_thumb.jpg" border="0" /></a><a href="https://msdnshared.blob.core.windows.net/media/2017/02/AI-high-volume.jpg"><img width="550" height="369" title="AI high volume" style="padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px" alt="AI high volume" src="https://msdnshared.blob.core.windows.net/media/2017/02/AI-high-volume_thumb.jpg" border="0" /></a>

&nbsp;
Oups.

As you can see, within just three days we generated 475 GB of data. Looking at the composition, I realized that we didn’t even look at most of this data. For example, let’s talk about the 180 GB of event data:

In our application, we used events to track when important things happened in our system – e.g. when a piece of data was queued for processing and when it was actually processed. With this information we set up a couple of graphs to quickly check a couple of things:
<ul>
 	<li>Was data being ingested by the system?</li>
 	<li>Was data being processed by the system?</li>
 	<li>Did the rate of ingestion / processing match?</li>
 	<li>Were there any unexpected spikes?</li>
</ul>
This is an example of such a graph:

<a href="https://msdnshared.blob.core.windows.net/media/2017/02/image475.png"><img width="373" height="224" title="image" style="padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/02/image_thumb424.png" border="0" /></a>

&nbsp;
Most of these events consisted only of the name of the function which was called, without any additional parameters - which meant that every single time we called TrackEvent we sent an exact copy. To top if off, we didn’t even look at the unique events themselves. And that got me thinking: If the individual events are not important, why bother sending them to Application Insights? Why not just send a single copy of every unique event to Application Insights (so we don’t lose data), count the number of times we try to send a duplicate telemetry offline and then, in regular intervals, send those numbers as metric data to Application Insights?

Enter the <a target="_blank" href="https://github.com/helgemahrt/EnhancedApplicationInsights/blob/master/helgemahrt.EnhancedAI/Shared/TelemetryProcessors/TelemetryToMetrics.cs"><strong>TelemetryToMetrics</strong></a> telemetry processor, which I developed to do just that. 

&nbsp;
You can set it up in just a few lines in the <em>ApplicationInsights.config</em> file:

[sourcecode language="xml"]
&lt;TelemetryProcessors&gt;
  &lt;Add Type=&quot;helgemahrt.EnhancedAI.TelemetryProcessors.TelemetryToMetrics, helgemahrt.EnhancedAI&quot;&gt;
    &lt;SendInterval&gt;30&lt;/SendInterval&gt;
    &lt;PrefixMetricsWithType&gt;true&lt;/PrefixMetricsWithType&gt;
    &lt;TelemetryTypesToTrack&gt;EventTelemetry,TraceTelemetry&lt;/TelemetryTypesToTrack&gt;
  &lt;/Add&gt;
&lt;/TelemetryProcessors&gt;
[/sourcecode]

The parameters:
<ul>
 	<li><strong>SendInterval</strong>: The interval (in seconds) at which the processor sends metrics it has gathered to Application Insights.</li>
 	<li><strong>PrefixMetricsWithType</strong>: When sending metrics to Application Insights, it will appear under “<em>Custom</em>” (in the Metrics Explorer) or “<em>customMetrics</em>” (in Analytics) and, at first sight, we won’t know which type of telemetry this data came from. (E.g. events called “<em>MyEvent</em>” will appear as if you had sent a <strong>MetricTelemetry</strong> item called “<em>MyEvent</em>”) If you set <em>PrefixMetricsWithType</em> to <strong>true</strong>, the <strong>TelemetryToMetrics</strong> processor will add a prefix, corresponding to the telemetry type, to the data it uploads. (E.g. events called “<em>MyEvent</em>” will appear as “<em>Event.MyEvent</em>”)</li>
 	<li><strong>TelemetryTypesToTrack</strong>: The types of telemetry you’d like the processor to track, separated by commas. (<strong>MetricTelemetry</strong> is not supported at this time)</li>
</ul>

&nbsp;
Once configured, the processor will set up buffers for the different types to track. When it receives a telemetry item, it will do the following:
<ul>
 	<li>Check whether the item is a duplicate and has been sent before (by comparing the name/message and – if present – the properties)
<ul>
 	<li>An item will only be passed on to the next processor (i.e. sent to Application Insights) if it is new (<strong>important</strong>: only a single copy of each unique telemetry item is sent to Application Insights, so make sure it’s not lost anywhere else – e.g. by client-side sampling or ingestion filtering)</li>
</ul>
</li>
 	<li>Independently of the previous step, all items passed to the <strong>TelemetryToMetrics</strong> processor are counted</li>
 	<li>Once every X seconds (determined by the <strong>SendInterval</strong> parameter), the processor will send the numbers it has collected to Application Insights and reset its counters</li>
</ul>
If you’re sending telemetry to multiple Application Insights instances, <strong>TelemetryToMetrics</strong> will create a different set of buffers for each Application Insights instance and track and count items separately.

&nbsp;
To view your telemetry data in Application Insights when using <strong>TelemetryToMetrics</strong> go to the Metrics Explorer, add a graph and select “Sum” as the aggregation method for the metrics sent by the processor. You should get something which looks like this:

<a href="https://msdnshared.blob.core.windows.net/media/2017/02/image476.png"><img width="1179" height="462" title="image" style="padding-top: 0px;padding-left: 0px;padding-right: 0px;border: 0px" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/02/image_thumb425.png" border="0" /></a>

&nbsp;
The first graph shows the events received, the second the custom metrics. Only one <b>EventTelemetry</b> item actually made it to Application Insights. The rest was converted to metrics data.
Looking at Analytics for the same period above, we can see that Application Insights barely received 34 <b>MetricTelemetry</b> items for those 7.75k events. If that’s not a reduction in data volume then I don’t know what is!

<a href="https://msdnshared.blob.core.windows.net/media/2017/02/image477.png"><img width="979" height="293" title="image" style="padding-top: 0px;padding-left: 0px;padding-right: 0px;border: 0px" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/02/image_thumb426.png" border="0" /></a>

&nbsp;
I’ve made the source code of the <strong>TelemetryToMetrics</strong> processor available on GitHub here: <a target="_blank" href="https://github.com/helgemahrt/EnhancedApplicationInsights" title="https://github.com/helgemahrt/EnhancedApplicationInsights">https://github.com/helgemahrt/EnhancedApplicationInsights</a> (together with my <a target="_blank" href="https://blogs.msdn.microsoft.com/hmahrt/2017/02/17/richer-exception-details-in-application-insights-custom-exceptions/">exception enhancer</a>) Please feel free to comment, share and/or contribute.

I also published the Enhanced Application Insights solution in a NuGet package: <a target="_blank" href="https://www.nuget.org/packages/helgemahrt.EnhancedAI" title="https://www.nuget.org/packages/helgemahrt.EnhancedAI">https://www.nuget.org/packages/helgemahrt.EnhancedAI</a>

&nbsp;
I hope this helps you in your projects!

Cheers,

Helge Mahrt]]></content:encoded>
    </item>
    <item>
      <title>Richer exception details in Application Insights (custom exceptions!)</title>
      <link>https://docs.microsoft.com/archive/blogs/hmahrt/richer-exception-details-in-application-insights-custom-exceptions</link>
      <pubDate>Fri, 17 Feb 2017 15:25:21 GMT</pubDate>
      <dc:creator><![CDATA[Helge Mahrt]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hmahrt/?p=245</guid>
      <description><![CDATA[Hello everyone,

[Update]: I thought a great place for this code to run would be a telemetry...]]></description>
      <content:encoded><![CDATA[Hello everyone,

[Update]: I thought a great place for this code to run would be a telemetry processor, so I created one. I shared it on GitHub: <a target="_blank" href="https://github.com/helgemahrt/EnhancedApplicationInsights/blob/master/helgemahrt.EnhancedAI/Shared/TelemetryProcessors/ExceptionTelemetryEnhancer.cs">https://github.com/helgemahrt/EnhancedApplicationInsights/blob/master/helgemahrt.EnhancedAI/Shared/TelemetryProcessors/ExceptionTelemetryEnhancer.cs</a>
Additionally, I packed it into a NuGet package, which you can find here: <a target="_blank" href="https://www.nuget.org/packages/helgemahrt.EnhancedAI">https://www.nuget.org/packages/helgemahrt.EnhancedAI</a>

While working on a project recently I encountered a situation where we needed to report custom exceptions to Application Insights. To keep things simple, they looked something like this:

[sourcecode language="csharp"]
public class CustomException : Exception
{
    public String AdditionalInformation { get; set; }

    public CustomException()
    {
    }

    public CustomException(string message) : base(message)
    {
    }

    public CustomException(string message, string additionalInformation) : base(message)
    {
        AdditionalInformation = additionalInformation;
    }
[/sourcecode]

When throwing them we would provide addition context information, which was important to understand the failure. Something along these lines:

[sourcecode language="csharp"]
throw new CustomException(&quot;Something went wrong.&quot;, 
    &quot;A piece of information I need to see in Application Insights.&quot;);
[/sourcecode]

Unfortunately, by default - apart from the stack trace - all you get in Application Insights is the type of the exception and the message:
<a href="https://msdnshared.blob.core.windows.net/media/2017/02/Capture4.jpg"><img width="590" height="584" title="Capture" style="padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px" alt="Capture" src="https://msdnshared.blob.core.windows.net/media/2017/02/Capture_thumb.jpg" border="0" /></a>

Luckily, the <a target="_blank" href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.applicationinsights.datacontracts.exceptiontelemetry">ExceptionTelemetry</a> object accepts additional parameters, and with a bit of .NET reflection magic we can easily get all properties of any exception, serialize them and ship them off to Application Insights. Here’s an example of how to do this:

[sourcecode language="csharp"]
// ignore cyclic references
private static JsonSerializerSettings jsonSettings = 
    new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore };

void LogException(Exception exception)
{
    ExceptionTelemetry telemetry = new ExceptionTelemetry(exception);

    // serialize properties that an exception may have and send them to application insights
    Type exceptionType = exception.GetType();
    if (exceptionType != null)
    {
        foreach (PropertyInfo property in exceptionType.GetProperties())
        {
            if (string.Equals(property.Name, &quot;StackTrace&quot;) ||
                string.Equals(property.Name, &quot;Message&quot;) ||
                string.Equals(property.Name, &quot;TargetSite&quot;))
            {
                // skip duplicate data
            }
            else
            {
                telemetry.Properties[$&quot;{exceptionType.Name}.{property.Name}&quot;] 
                    = JsonConvert.SerializeObject(property.GetValue(exception), jsonSettings);
            }
        }
    }

    client.TrackException(telemetry);
}
[/sourcecode]

If we now report our CustomException to Application Insights, we get a lot more context information. It’ll show up in the “Custom Data” section in the Application Insights dashboard:
<a href="https://msdnshared.blob.core.windows.net/media/2017/02/Capture21.jpg"><img width="591" height="785" title="Capture2" style="padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px" alt="Capture2" src="https://msdnshared.blob.core.windows.net/media/2017/02/Capture2_thumb.jpg" border="0" /></a>

In our project, we used this custom logging function in a Web Job which was a plain console application. However, if you’re using Application Insights in a Web App, you can <a target="_blank" href="https://docs.microsoft.com/en-us/azure/application-insights/app-insights-asp-net-exceptions">create a custom exception filter</a> to easily add this information to all exceptions reported to AI.

I hope this helps you troubleshoot your issues!

Cheers,

Helge Mahrt]]></content:encoded>
    </item>
    <item>
      <title>Rebranding my blog</title>
      <link>https://docs.microsoft.com/archive/blogs/hmahrt/rebranding-my-blog</link>
      <pubDate>Thu, 16 Feb 2017 13:32:50 GMT</pubDate>
      <dc:creator><![CDATA[Helge Mahrt]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hmahrt/?p=195</guid>
      <description><![CDATA[Hello everyone,

In 2014 I changed into the Windows Reliability support team within Microsoft,...]]></description>
      <content:encoded><![CDATA[Hello everyone,

In 2014 I changed into the Windows Reliability support team within Microsoft, leaving behind the development world for a while, and stopped posting here. I have recently moved on from that position - returning to the light - and I expect to be blogging more often again. I am now a Premier Field Engineer in the Modern Apps domain, focusing on Azure PaaS, and so I adjusted the branding of this blog to reflect this change.

Expect to be hearing more from me soon.

Cheers,

Helge Mahrt]]></content:encoded>
    </item>
    <item>
      <title>My experience with .NET Native Preview</title>
      <link>https://docs.microsoft.com/archive/blogs/hmahrt/my-experience-with-net-native-preview</link>
      <pubDate>Wed, 21 May 2014 08:31:00 GMT</pubDate>
      <dc:creator><![CDATA[Helge Mahrt]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hmahrt/2014/05/21/my-experience-with-net-native-preview/</guid>
      <description><![CDATA[Hello everyone,
I just published this new post on our team blog over here:...]]></description>
      <content:encoded><![CDATA[<p>Hello everyone,</p>
<p>I just published this new post on our team blog over here: <a href="https://aka.ms/Oz6rgn">https://aka.ms/Oz6rgn</a></p>
<p>Cheers,</p>
<p>Helge Mahrt</p>]]></content:encoded>
    </item>
    <item>
      <title>Failed the WACK Test – How do I get more information?</title>
      <link>https://docs.microsoft.com/archive/blogs/hmahrt/failed-the-wack-test-how-do-i-get-more-information</link>
      <pubDate>Thu, 11 Apr 2013 09:37:00 GMT</pubDate>
      <dc:creator><![CDATA[Helge Mahrt]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hmahrt/2013/04/11/failed-the-wack-test-how-do-i-get-more-information/</guid>
      <description><![CDATA[&nbsp;
Hello everyone,
So you finished your Windows Store app and are eager to get it into the...]]></description>
      <content:encoded><![CDATA[<pre class="code">&nbsp;</pre>
<p>Hello everyone,</p>
<p>So you finished your Windows Store app and are eager to get it into the Store &ndash; but it failed the Windows App Certification Kit (WACK) test and the results do not provide sufficient information about the reason of the failure. What can you do to get more details?</p>
<p>The first thing to look at are the internal logs of WACK. You can find them in the following folder: <strong>C:\Users\&lt;user&gt;\AppData\Local\Microsoft\AppCertKit </strong>(Especially interesting are the .txt files. Look out for the name of the test that your app failed.)</p>
<p>If you need to review the content of the <strong>xperfTemp.txt</strong> file, e.g. for the performance launch test, you may find that it is empty, or that its content does not reflect the output from the test anymore. That is because it is a temporary file and gets overwritten by different tests. In this case, you have two options:</p>
<ol>
<li>You can run exactly the same command that is listed in the (internal) log file, which WACK used to extract the timing information from the .ETL file</li>
<li>You can run the test that failed manually, and only that test</li>
</ol>
<p>To run a single test manually, you can use the following command: <strong>Appcert.exe test -apptype windowsstoreapp -packagefullname <em>&lt;full package id&gt; </em>-reportoutputpath c:\temp\testpackage.xml &ndash;testid <em>&lt;test id&gt;</em></strong></p>
<p>You can look up the test id here: <strong>C:\Program Files (x86)\Windows Kits\8.0\App Certification Kit\configuration.xml</strong> (E.g. the index for the <em>Performance Launch</em> test is 43)</p>
<p>I hope this helps, should your app ever fail a test in WACK and you don&rsquo;t know why.</p>
<p>Cheers,</p>
<p>Helge Mahrt</p>]]></content:encoded>
    </item>
    <item>
      <title>Asynchronous Programming in .NET 4.5 – in Spanish</title>
      <link>https://docs.microsoft.com/archive/blogs/hmahrt/asynchronous-programming-in-net-4-5-in-spanish</link>
      <pubDate>Fri, 22 Feb 2013 06:51:00 GMT</pubDate>
      <dc:creator><![CDATA[Helge Mahrt]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hmahrt/2013/02/22/asynchronous-programming-in-net-4-5-in-spanish/</guid>
      <description><![CDATA[Hello everyone,
My colleague Jos&eacute; Ortega and I just published some articles about the new...]]></description>
      <content:encoded><![CDATA[<p>Hello everyone,</p>
<p>My colleague Jos&eacute; Ortega and I just published some articles about the new .NET 4.5 keywords <span style="color: #0000ff;"><a href="https://msdn.microsoft.com/en-us/library/vstudio/hh156528.aspx">await</a> </span>and <span style="color: #0000ff;"><a href="https://msdn.microsoft.com/en-us/library/vstudio/hh156513.aspx">async</a></span>, and about the <a href="https://msdn.microsoft.com/en-us/library/dd460717.aspx">Task Parallel Library (TPL)</a>. As they are in Spanish we put them on his blog. If you are interested, please have a look here: <a title="https://blogs.msdn.com/b/desarrolloweb/archive/2013/02/22/asincronia-en-net-4-5.aspx" href="https://blogs.msdn.com/b/desarrolloweb/archive/2013/02/22/asincronia-en-net-4-5.aspx">https://blogs.msdn.com/b/desarrolloweb/archive/2013/02/22/asincronia-en-net-4-5.aspx</a></p>
<p>Cheers,</p>
<p>Helge Mahrt</p>]]></content:encoded>
    </item>
    <item>
      <title>Be careful when making DataTransferManager.DataRequested an async function</title>
      <link>https://docs.microsoft.com/archive/blogs/hmahrt/be-careful-when-making-datatransfermanager-datarequested-an-async-function</link>
      <pubDate>Tue, 20 Nov 2012 08:02:00 GMT</pubDate>
      <dc:creator><![CDATA[Helge Mahrt]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hmahrt/2012/11/20/be-careful-when-making-datatransfermanager-datarequested-an-async-function/</guid>
      <description><![CDATA[Hello everyone,
Update: Thanks to Nigel Sampson for correcting my post. :)
As you probably already...]]></description>
      <content:encoded><![CDATA[<p>Hello everyone,</p>
<p>Update: Thanks to Nigel Sampson for correcting my post. :)</p>
<p>As you probably already know, .NET Framework 4.5 introduced two new keywords: <a href="https://msdn.microsoft.com/en-us/library/hh156513.aspx">async</a> and <a href="https://msdn.microsoft.com/en-us/library/hh156528.aspx">await</a>. (Look <a href="https://msdn.microsoft.com/en-us/library/vstudio/hh191443.aspx">here</a> for information about how to use them.)</p>
<p>If you are adding the possibility to <a href="https://msdn.microsoft.com/en-us/library/windows/apps/xaml/Hh871368(v=win.10).aspx">share content of your Windows Store application</a>, you will have to implement the <a href="https://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.applicationmodel.datatransfer.datatransfermanager.datarequested.aspx">DataTransferManager.DataRequested</a> callback. From the MSDN documentation:</p>
<blockquote>
<p>This event is fired when a sharing operation starts&mdash;typically when the user taps the Share charm, although it is also fired if your app starts a share operation programmatically.</p>
</blockquote>
<p>As with the callbacks on the App class (<a href="https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.application.onlaunched.aspx">OnLaunched</a>, <a href="https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.application.onactivated.aspx">OnActivated</a> etc.), you can just convert this function into an asynchronous one. However, take the following sample implementation:</p>
<table style="background-color: #dcdcdc;" border="0">
<tbody>
<tr>
<td>
<pre class="scroll"><code class="csharp">async void App_DataRequested(DataTransferManager sender, DataRequestedEventArgs args) <br />{<br />&nbsp;&nbsp;&nbsp;&nbsp; DataRequest req = args.Request;<br />&nbsp;&nbsp;&nbsp;&nbsp; await Task.Delay(500);<br />&nbsp;&nbsp;&nbsp;&nbsp; req.Data.Properties.Title = "Test";<br />&nbsp;&nbsp;&nbsp;&nbsp; req.Data.SetText("Hello World!");<br />&nbsp;&nbsp;&nbsp;&nbsp; req.GetDeferral().Complete(); <br />}</code></pre>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>If you use this code, when you are sharing data from your application, you will get a message like one of the following:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/47/88/metablogapi/4263.image_55373D06.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-47-88-metablogapi/4263.image_5F00_55373D06.png"><img style="margin: 0px; display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/47/88/metablogapi/5153.image_thumb_33D7976A.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-47-88-metablogapi/5153.image_5F00_thumb_5F00_33D7976A.png" alt="image" width="244" height="121" border="0" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/47/88/metablogapi/0044.image_32FF3180.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-47-88-metablogapi/0044.image_5F00_32FF3180.png"><img style="margin: 0px; display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/47/88/metablogapi/3000.image_thumb_40654486.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-47-88-metablogapi/3000.image_5F00_thumb_5F00_40654486.png" alt="image" width="244" height="128" border="0" /></a></p>
<p>&nbsp;</p>
<p>&ldquo;What happened?&rdquo;, you may ask. Well, there is a trick to making this callback asynchronous.</p>
<p>If we think about <a href="https://msdn.microsoft.com/en-us/magazine/hh456403.aspx">the consequences of using async and await</a>, and about the nature of the share operation, we can explain this behavior easily: Once the call to <strong>DataRequested</strong> returns, it expects the <strong>DataRequest</strong> to contain the information we want to share. However, if our callback is marked with <strong>async</strong> and we add a call using <strong>await</strong>, it will cause the execution flow to leave the function until we are notified by the awaiter that we can continue. <strong>DataTransferManager</strong>, however, does not know about this and will assume that we have completed the request correctly.</p>
<p>Fortunately, there is a way to tell <strong>DataTransferManager</strong> to wait for us: using the <a href="https://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.applicationmodel.datatransfer.datarequest.getdeferral.aspx">GetReferral</a> method. Before, we only called it at the end of our callback, to mark the DataRequest as complete. However, if we call it at the beginning we will be able to call asynchronous methods:</p>
<table style="background-color: #dcdcdc;" border="0">
<tbody>
<tr>
<td>
<pre class="scroll"><code class="csharp">async void App_DataRequested(DataTransferManager sender, DataRequestedEventArgs args) <br />{&nbsp;&nbsp;&nbsp;&nbsp; DataRequest req = args.Request;&nbsp;&nbsp;&nbsp;&nbsp; DataRequestDeferral deferral = req.GetDeferral();&nbsp;&nbsp;&nbsp;&nbsp; await Task.Delay(500);&nbsp;&nbsp;&nbsp;&nbsp; req.Data.Properties.Title = "Test";&nbsp;&nbsp;&nbsp;&nbsp; req.Data.SetText("Hello World!");&nbsp;&nbsp;&nbsp;&nbsp; deferral.Complete(); <br />}</code></pre>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>Please note that if the asynchronous operations will take more than 200ms you have to <a href="https://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.applicationmodel.datatransfer.datapackage.setdataprovider.aspx">use a DataProviderHandler</a> to prevent the operation from timing out.</p>
<p>I hope this helps you.</p>
<p>Cheers,</p>
<p>Helge Mahrt</p>]]></content:encoded>
    </item>
    <item>
      <title>How to avoid “The directory data type cannot be converted to/from a native DS data type” (0x8000500C) in managed code</title>
      <link>https://docs.microsoft.com/archive/blogs/hmahrt/how-to-avoid-the-directory-data-type-cannot-be-converted-tofrom-a-native-ds-data-type-0x8000500c-in-managed-code</link>
      <pubDate>Wed, 01 Aug 2012 09:56:00 GMT</pubDate>
      <dc:creator><![CDATA[Helge Mahrt]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/hmahrt/2012/08/01/how-to-avoid-the-directory-data-type-cannot-be-converted-tofrom-a-native-ds-data-type-0x8000500c-in-managed-code/</guid>
      <description><![CDATA[Hello everyone,
We may find ourselves in the situation where we need to access custom properties...]]></description>
      <content:encoded><![CDATA[<p>Hello everyone,</p>
<p>We may find ourselves in the situation where we need to access custom properties that have been defined for objects in our Active Directory. However, using the managed class <code class="csharp"><a href="https://msdn.microsoft.com/en-us/library/system.directoryservices.directoryentry.aspx"> DirectoryEntry</a></code> we may receive an exception with the error code <b>0x8000500CL</b> when accessing the custom property the following way:</p>
<p><code class="csharp">myDirectoryEntry.Properties["myProperty"]</code></p>
<p>As the error text indicates, the cause for this issue is the lack of information about how to convert the value of our custom property into a managed object. <code class="csharp">DirectoryEntry</code> does not offer the possibility to specify this meta information, so how can we access our custom properties?</p>
<p>Luckily there is COM library, <b>ActiveDS</b>, which exposes (amongst others) the following two functions:</p>
<ul>
<li><code class="csharp"><a href="https://msdn.microsoft.com/en-us/library/aa706103(VS.85).aspx">IADsPropertyList::GetPropertyItem</a></code></li>
<li><code class="csharp"><a href="https://msdn.microsoft.com/en-us/library/aa706108(v=VS.85).aspx">IADsPropertyList::PutPropertyItem</a></code></li>
</ul>
<p>Once we add a reference to the library to our Visual Studio project, selecting it from the COM tab (it appears as "<b>Active DS Type Library</b>"), we can implement a wrapper like the following:</p>
<p></p>
<p><code class="csharp">class PropertyHelper<br /> {<br /> &nbsp;&nbsp;&nbsp;&nbsp;public static List<object> GetProperty(DirectoryEntry entry, String propertyName, ADSTYPEENUM adsType)<br /> &nbsp;&nbsp;&nbsp;&nbsp;{<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// make sure to get the properties from the DC<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entry.RefreshCache(new String[] { propertyName });<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// get the property list from the underlying native object<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IADsPropertyList propList = (IADsPropertyList)entry.NativeObject;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// return values<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;List<object> values = new List<object>();<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// get the native property object<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IADsPropertyEntry propEntry = (IADsPropertyEntry)propList.GetPropertyItem(propertyName, (int)adsType);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// iterate over the values set for the property<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach (IADsPropertyValue propValue in propEntry.Values)<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch (adsType)<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING:<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;values.Add(propValue.CaseIgnoreString);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case ADSTYPEENUM.ADSTYPE_CASE_EXACT_STRING:<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;values.Add(propValue.CaseExactString);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case ADSTYPEENUM.ADSTYPE_DN_STRING:<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;values.Add(propValue.DNString);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case ADSTYPEENUM.ADSTYPE_INTEGER:<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;values.Add(propValue.Integer);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case ADSTYPEENUM.ADSTYPE_BOOLEAN:<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;values.Add(propValue.Boolean);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case ADSTYPEENUM.ADSTYPE_LARGE_INTEGER:<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;values.Add(propValue.LargeInteger);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case ADSTYPEENUM.ADSTYPE_OCTET_STRING:<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;values.Add(propValue.OctetString);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default:<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw new System.NotImplementedException("Handling of this ADSTYPE is not implemented");<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return values;<br /> &nbsp;&nbsp;&nbsp;&nbsp;}<br /> }<br /> </object></object></object></code></p>
<p>We can then access our custom property using the following call:</p>
<p><code class="csharp">var sReturnValues = PropertyHelper.GetProperty(entry, "sAttribute", ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING);</code></p>
<p>Implementing a similar wrapper for setting the values of our custom property should be straightforward from here. I hope this helps.</p>
<p>Cheers,</p>
<p>Helge Mahrt</p>]]></content:encoded>
    </item>
  </channel>
</rss>