Test Availability and Inspect Web Pages using Powershell


Have you ever wanted to test the availability of a URL or web page?  or check for the presence of content or links on a page?  even clicking through a flow of web pages automatically?

Well, these things are not necessarily new concepts or challenges.  In fact, in the Application Testing space this is the type of thing we do day in and out.

I have recently been messing around with Selenium and Python web test scripts, and just for kicks wondered if similar things could be achieved using Powershell.  Funnily enough, the answer is yes, and quite easily too for anyone familiar with Powershell scripting.

So here are some basics just for fun, to get things going...   the magic sauce is in the Invoke-WebRequest cmdlet.  Let's check up on this blog's main page as follows by feeding the URL we want to check to the Invoke-WebRequest cmdlet, and assigning the resulting object to a variable called $webpage:

$webpage = Invoke-WebRequest https://blazingtm.com

Nice.  Exciting. Maybe not 😃

What can we do with this thing called $webpage you might ask.  Well, first let's see what type this object actually is.  You can do this calling

$webpage.GetType()

It's a thing called HtmlWebResponseObject.  Ok, so not just a simple "webpage", but an object.  Well, so it may have associated member properties we can inspect, maybe that could be interesting.  We can do this using the following cmdlet

$webpage| Get-Member

The result should look something like follows, listing all member properties and methods for the webpage:

Name MemberType Definition
---- ---------- ----------
Dispose Method void Dispose(), void IDisposable.Dispose()
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
AllElements Property Microsoft.PowerShell.Commands.WebCmdletElementCollection
BaseResponse Property System.Net.WebResponse BaseResponse {get;set;}
Content Property string Content {get;}
Forms Property Microsoft.PowerShell.Commands.FormObjectCollection Forms
Headers Property System.Collections.Generic.Dictionary[string,string] Hea
Images Property Microsoft.PowerShell.Commands.WebCmdletElementCollection
InputFields Property Microsoft.PowerShell.Commands.WebCmdletElementCollection
Links Property Microsoft.PowerShell.Commands.WebCmdletElementCollection
ParsedHtml Property mshtml.IHTMLDocument2 ParsedHtml {get;}
RawContent Property string RawContent {get;set;}
RawContentLength Property long RawContentLength {get;}
RawContentStream Property System.IO.MemoryStream RawContentStream {get;}
Scripts Property Microsoft.PowerShell.Commands.WebCmdletElementCollection
StatusCode Property int StatusCode {get;}
StatusDescription Property string StatusDescription {get;}

Let's have a little look at that StatusCode property.  To see what it is, use

$statuscode = $webpage.StatusCode

You would have guessed, if we look at the value of $statuscode we will see it's 200.  Provided the webpage was available earlier of course. 200 is good when it comes to web page availability.

We can test for this using something along the lines of

if ($statuscode -eq 200) {Write-Output("Brilliant, this page is available :)")}
else {Write-Output("Well, that did not work :(")}

Equally, we might want to make sure the page is not only available (ie a Status Code 200), but that it has a certain content on the page.  That is often useful to know to ensure a page has rendered the right results.

This is where the Content property comes in handy.  Let's say we wanted to check that the page contains the phrase "Late night musings".  Too easy, do this

$webpage.Content.Contains("Late night musings")

Now this will simply return True, or False, depending on whether the phrase is found.  Of course you can have further logic on the back of this, but you can see the basics of some interesting web tests evolving here.

That's all for tonight, but following on from this wouldn't it be great if we could script up a whole user flow navigating web pages to test availability of a web site, not just a page.  That's however a topic for another time.

Enjoy.

MB


AdSenseAccountStats App Reborn As AdsAccountStats - Finally

Is there a Windows app that can quickly show you the key metrics for your Google AdSense account?



Ah yes, wait a minute, there was this app called AdSenseAccountStats...  what happened to it again?Just kidding, check this post from a while back for an explanation why I had to pull it from the Microsoft Store.

AdSenseAccountStats Is Back - With A New Name


As mentioned in the previous post, I ended up simply renaming the app.  There is a bit of a process to step through, but luckily one can always find decent Microsoft knowledge articles on the interweb. If you are interested, check this blog post from the Windows App Consult Team.

In simple terms, follow these high level steps:

  1. Reserve new app name in the developer dashboard
  2. Update your manifest and app package, logos etc
  3. Create new store packages
  4. Create new submission and upload new packages
  5. Update your store listing details in the new submission
  6. Submit to store
  7. When approved and published, delete old app name
Refer to the above mentioned blog post for exact steps.  They all worked as described, although the 3rd step - creating new store packages - gave me some grief.   I experienced errors when building the release packages, complaining about the Display Name in the appxmanifest file.

The solution in the end was to re-create the package.xml file and re-associate the app with the Store, picking the new name (it eventually was visible and selectable in Visual Studio).  It did take a few attempts to get this right, but eventually came good.

Goodbye AdSenseAccountStats - Hello AdsAccountStats


Following this process should ensure that you don't lose the linkage of your app/packages and your app install base.  It is important to increment your version so that older packages will be deleted and apps updated to reflect the name name.

What next?  Go and get the app from the Microsoft Store of course 😀 if you don't have it already.  For now, there is no new or additional functionality, but when time permits there are a couple of improvements I would like to make and features to add.

Until then, enjoy the app once again as it stands.

MB.

Instagram Microphone Access Fix For Windows Phone Lumia 950


Hey fellow die-hard Windows Phone aficionados... If you are reading this you are most likely still using a Microsoft Windows Phone, such as the Lumia 950 or similar running Windows 10 and the Instagram app, correct? Me too 😁

Now, I thought I'd share the solution to a small but annoying issue with the latest version of the Instagram app on Windows 10 mobile. Whenever you start the app, Instagram asks for access to the camera and microphone of your phone. Sure, hey to get the most out of Insta these things are required so why not.

The Issue - Prompt for Microphone Access


The problem is that the screen pops with a couple of text links, which when tapped should change the relevant settings for camera and microphone access permissions. While the camera one works fine, the one for the microphone does not. Calamity. And here is the annoying part, the screen pops every time on start up, driving you crazy just a little bit...


The Solution - Grant Permissions Manually


Do not despair, the solution is very simple.  You can just add the required app permissions manually the old fashioned way.  Go into Settings - tap Microphone - find Instagram and flick the toggle switch to On



Voila.  Try and start the Instagram app and you will no longer see the annoying screen above prompting you for Microphone access.  Enjoy, and feel free to comment if this little gem has helped you.

#SaveWindowsPhone #Microsoft 😜

How to Connect your iPad to wired Ethernet


Wired internet connection for your iPad? Anyone?


Have you ever wondered whether it is possible to connect your iPad to a wired network using an Ethernet cable? Sure... but why would you want to do that in the first place you may ask.

Well, maybe you are just curious, and it's a personal challenge to see if it actually can be done.  Maybe your WiFi coverage in your home is not great in some areas, but you have access to wired Ethernet. Or you might even be a little concerned that young kids using iPads for lengthy periods - often in their laps - essentially have a wireless transmitter running near vulnerable body parts.

Either way we've had a go at it and the process was surprisingly simple and easy. Not cheap, but hey it's all good.

What gadgets do you need to make this work?


Firstly, you need your iPad. Then you need the Apple Camera Adapter, followed by an Apple Ethernet adapter. Be warned, neither of these are cheap. They will set you back a bit of money. Now, it may be possible to get cheaper non-Apple branded components and still make this work, but we decided to stick with Apple accessories to ensure success.

Here is what these two gadgets look like:


Cool, but how do we connect it all up?


Pretty simple, really. Grab your iPad, plug in the Camera Adapter into the lightning port of the iPad. Then, grab the Ethernet Adapter and plug it into the USB port of the camera adaptor. This whole setup needs to be powered, so connect your Apple charger cable to the lightning port on the Camera Adapter. Lastly, plug your Ethernet cable into the Ethernet adapter. You are good to go. Try it, put your iPad into flight mode, disabling all WiFi and Bluetooth connectivity. Yet you can still get to the Internet, App Store etc. Works like a charm.

Hope you enjoyed the post and maybe even found it useful.

Cheers

MB


AdSense Account Stats App Temporarily Unavailable in Microsoft Store


What happened to the AdSense Account Stats App in the Microsoft Store?


A couple of weeks ago I was notified by Microsoft that a third party agent working on behalf of Google has lodged a claim that the title of my AdSense Account Stats App in the Microsoft Store is infringing on a Google owned trademark.

The actual app title is AdSenseAccountStats, and I guess that has the word AdSense in it.  AdSense of course is indeed a Google owned trademark registered in the US, and quite possibly in many other countries.  Doing the right thing, I immediately removed the app from the store listing and download.

Now, I am neither a lawyer nor an expert with regard to trademarks, but one of the main aspects when it comes to trademark infringements is about potential consumer confusion.  Meaning that consumers might reasonably but incorrectly assume that a product or service is provided by the trademark owner when in reality that is not the case. Another aspect is about commerciality of the product or services infringing on a trademark.

You be the judge - is AdSenseAccountStats confusing?


Certainly a very interesting situation.  My app is of course available for free so there is no commercial benefit.  Additionally, Google do not have their own app in the Microsoft Store that one could use to access one's AdSense account.  On Android and Apple iOS such an official Google AdSense app exists, but not for Windows mobiles. Which incidentally was the key reason I put together the app in the first place.  I wanted an easy way to access my AdSense account from my Windows mobile.

As far as trademark infringement defenses go, there may be three interesting aspects here:
  • No real confusion of customers - title is simply describing what the app's purpose is
  • No commercial gain - the app is available free of charge and currently not ad supported
  • Abandonment of the Windows mobile platform - Google not providing its own app

Either way - Stand by for re-launch


Never mind, I have neither the time nor inclination to have an argument with the third party agent, so I guess I'll just rename the app and re-publish it with a more generic name.  In some ways, it is almost flattering that there is this much interest in an app I created.  It makes for a good story at the pub 😀

It is going to take a little while to relaunch the app however, so don't hold your breath.  There is a specific process to step through before the app can be re-enabled in the store.  Legal forms to submit, authorisation to be obtained, repackaging of the app with a new title (how does AdsAccountStats sound - generic enough?), submission update to the store and ultimately making the app available for download again.

Now if only I had a little spare time to do all the above...   I'll post again once the app is back and available.

'til then, have a great day.

MB

Fix Discord Muted Microphone Problem For Logitech G430 Gaming Headset

Battling microphone issues in Discord voice chats?


Since you are reading this post, I will assume that you are currently experiencing issues with your microphone when using Discord for voice chats, right?  Maybe like us you are using a Logitech G430 Gaming Headset. And maybe you are trying to have a conversation with your gaming buddies right now and you can hear them just fine, but they cannot hear you... oh calamity.

I'm sure you have searched the Internet for a fix to the problem, and have most likely found many articles on this topic and tried the various suggestions - unsuccessfully maybe.  So firstly, let me tell you that you are not alone.  In my experience it is always comforting to know that others are in the same boat 😉

Now, in my case the kids had this exact issue, and were getting progressively more irritated. Of course the expectation was that dad would fix it - and fast 😀

Plenty of blog posts with suggested fixes and things to try


While there are many articles and blog posts out there that have great suggestions on how to fix the dreaded microphone problems I found all of them not quite hitting the mark and resolving things for us.

So in case you are in the same situation, and have tried some or all of the following...
  • ensure Windows 10 is fully patched and up to date
  • update sound card drivers
  • applied the latest firmware update to the Logitech G430 headset
  • unplugged the headset, rebooted and plugged it back in
and things are still not working, here is the fix that did the trick for us in the end.

The simple fix in the end


It's always simple once you know the answer.  The thing that resolved the issue for us in the end was simply to reset the Discord voice settings.  Here is how:
  • Start Discord
  • Click the little cog wheel for User Settings
  • On the left hand navigator click Voice & Video
  • On the right hand panel scroll right down to the end until you see the Reset Voice Settings button
  • Click it!


And voila, there you have it.  The kids were happy, dad was a hero and the crisis was averted.

Feel free to comment and share your experience whether this solution helped you resolve things.

Cheers

MB

Heads Or Tails UWP App Update 1.2.2 Released



Just a quick post tonight to spruik 😀 the latest release of this handy little app.  In this release I have added a feature to track lifetime stats for heads and tails, as well as the longest streaks for both options.

As silly as it sounds, it is actually quite intriguing to keep tossing that virtual coin and see how over time the numbers for heads and tails even out as they should.  While at other times you can get really long streaks of just heads or just tails, skewing the total number one way or the other.

I can't post with just useless information though, so I will share one tidbit I recently observed that may be of interest to anyone looking to monetize their apps using the Microsoft Advertising Framework.

Low ad fill rates?  There may be a reason...

When I created the new Lifetime Stats page in the app and added a new ad unit, I accidentally selected a COPPA (Children's Online Privacy Protection Act) compliance rating that indicated the app was directed at children under 13 years of age.  This of course is not the case - it is for general consumption for young and old.

However, the learning is that the COPPA compliance rating for the one ad actually applies to all ads for the one app.  This then changes the ad serving algorithms that Microsoft applies for the app and all its ad units. In return, my ad fill rate went south...

By way of explanation Microsoft will only serve non-targeted ads to apps that are directed at Children under 13 years of age.

At this point I need to stress that you absolutely must select the appropriate COPPA compliance setting for your app.  At no point should ad fill rate considerations influence your declaration.  Just do the right thing, okay?

What's next for this app?

It was initially just a learning piece for myself as to how the Microsoft Advertising Framework actually works.  See this recent post if you want to read about it a bit more.

But now I'm actually thinking of putting in a feature that will aggregate data from all users across the world, by country, and then display it back in the app as a sort of "World Cup of Coin Toss" ladder.  Why, you ask?  Just for fun really.  And it could be an interesting learning on how to create the web APIs and database backend required for such a feature.

Anyway, feel free to comment if you like the idea.  Not much spare time at the moment but with enough encouragement it might just happen one day 😀

Get it from Microsoft

Hope you enjoyed the post

MB



Heads Or Tails UWP App - Sample For Using Microsoft Advertising AdUnits To Monetize Your Apps

A Quick Sample App For Monetizing Apps With Microsoft Advertising AdUnits


Just a quick post in case anyone is wondering how to monetize their UWP apps using Microsoft's Advertising framework.

The good news? I found it to be very simple and straight forward, although there are a couple of caveats to be aware of.

It's Easy - Let's get started


First, log into your Windows Dev Center account. On the left hand navigation bar click on Monetize - In-app ads.  Then click on the Create ad unit button.  Fill in a handful of self explanatory parameters for your new ad unit, and click the Create ad unit button to save.  Congratulation, you have just created your first live AdUnit.



Download and install the Microsoft Advertising SDK for XAML


Grab the SDK from the Microsoft web site, and run the installer.  Once done, open up your app's project in Visual Studio and add a Reference to the Microsoft Advertising SDK for XAML. To do this right click References - Add Reference - Universal Windows - Extensions.  Tick the box for the SDK and click OK.

Bake your shiny new ad unit into your UWP XAML App


This step is easy.  But don't be tempted to embed your live ad unit while still developing/debugging your app.  It is against Microsoft policy to run live ad units in the debugger and I am pretty sure they would not be pleased - so just don't do it.

Instead, use a test ad unit. Microsoft thankfully provide such a test ad unit with generic IDs.  So the XAML will look something like this:

  xmlns:UI="using:Microsoft.Advertising.WinRT.UI"

  <!-- Test AdControl -->
  <UI:AdControl
      ApplicationId="3f83fe91-d6be-434d-a0ae-7351c5a997f1"
      AdUnitId="test"
      Height="50"
      Width="320"
      Margin="0,20,0,20"/>

The key pieces here are the using: statement referencing Microsoft.Advertising.WinRT.UI, and the ApplicationId and AdUnitId tags. The values here are the generic test ones which you can use exactly as they are. These will tell the Microsoft Advertising framework to serve up test ads so you can ensure it all works.

For mobile apps, there are a couple of banner sizes that are recommended specifically, as they work best.  I am relatively sure you can use any of the approved sizes, but maybe best stick to the recommended ones for Windows Phone apps.

Voila, you are ready to earn money with your App - Almost, anyway


Pretty close...   A couple of extra steps are required first. Once you are happy with your app and you are ready to submit it to the Microsoft Store, change the XAML for your AdControl to use live ApplicationID and AdUnitId tags.  Where do you get these from you might ask?  Aha, since you paid attention to this post, you know that you can get the live Id tags from your Windows Dev Center, right?

Put the live Id tags into your app, and then follow the standard processes to package and submit the app to the Microsoft Store.  Visual Studio makes this very easy, and there is excellent documentation available from Microsoft on the whole end to end process.

Once your submission is fully approved, your app will be available to customers for download, ready for you to start making money.

Wrapping Up - Grab Heads-Or-Tails app from the Microsoft Store


Hope you enjoyed this post.  Any questions just leave a comment or send me an email.

Oh, and if you feel like it, go grab the app from the Store and use it to help you make those tricky decisions in life - after all, it's a tricky, age old question:   Heads Or Tails?

Cheers

MB


Further Information


Monetize your App with Ads - Windows Developer Documentation




To Splunk or not to Splunk - Either Way Listen to Your Machine Data


Listen to your Machine Data. Yes, Do.

Machine data and log analytics is all the rage these days, but should it be, and why should you invest to gather, centralise and analyse something as boring and mundane as machine data and logs?

Structured, Semi-Structured and Unstructured

We are used to structured data, and storing such in relational databases and more recently in file and blob based data stores. This kind of data has always been interesting, and used in a business and application context. However, today we are starting to latch on to the power inherent in semi-structured and unstructured data. There are a number of innovative things we can do if we index, store, correlate and analyse all kinds of machine generated data. This will only get more interesting with the proliferation of IoT devices gathering telemetry data.

So what can you do with Machine Data and Logs?

Well, there is no definitive list, and really it's quite open to imagination. Data rules the world. Data driven businesses with new business models are popping up everywhere. In short, data has currency.

For the purpose of this post, let's focus on a common and popular use case in Digital/IT making use of machine and log data in an IT Operations context. Leveraging and mining data to improve IT service delivery, availability and performance makes sense, and adds to an IT department's capability and service offering.

Drivers for IT Ops Analytics

Through correlation and analysis of all our machine data we may be able to
  • proactively identify issues
  • predict time and point of potential future failures
  • pinpoint root cause and reduce mean time to restore
  • reduce cost through smarter delivery of services
  • gain insights into environments in new ways to drive digital innovation
to name just a few key points.

So this sounds good, right? We want a piece of that for sure. But how do we go about it, and what kind of tools would we need to deliver such new capabilities for IT Operations Management?

Tools that can help us meet the IT Operations Analytics challenge

The good news is that there are a number of mature products and solutions out there. There are both commercial and open source options readily available. The following table lists a few popular options that are worth looking into in my opinion. It is in no particular order nor an exhaustive list.


Products
Commercial / Open Source
On Premise / Cloud
Commercial
Both
Commercial
Cloud
Commercial
Cloud
Open Source
On Premise
Commercial
Both
Commercial
On Premise


On Premise vs Cloud

Depending on what is important to you and/or your organisation, there is no definite answer on what is the best delivery model for a log analytics solution - on premise or cloud.

Some of the reasons as to why you would go on premise are:
  • Retain full control of your data
  • Flexibility of customisation
  • Data sovereignty, data security and backup concerns
  • Unreliable or low bandwidth links to cloud providers
  • Frequent need to bring back data on premise, egress costs
On the other hand, most of the above cloud log analytics providers are pretty mature, highly available and secure by design these days. In other words, they are Enterprise ready. And of course there is the promise of infinite capacity, so you can ingest data to your heart's content and not have to worry about investing into costly, capital intensive on premise infrastructure.

So unless you are facing major regulatory or compliance hurdles, I'd suggest to give the cloud a go. But do your homework on your projected data volumes and associated costs to avoid bill shock and make sure going into the cloud is indeed the most cost effective path for your business. Major organisations may be able to build their own infrastructure and run at lesser cost than cloud providers.

The Wrap

Hopefully the above thoughts have provided some hints and pointers to get you started on your log analytics journey. Personally, I think the potential is significant, and investing in this space is the right thing to do.

Make sure you have people who are interested in using the technology creatively. Define your use cases, then actively get answers to your burning questions by driving value through analysis and visualisation of your existing log and machine data.

Ah yes, to Splunk or not to Splunk…


Cheers

MB

AdSense Account Stats UWP App Released

Introducing AdSenseAccountStats App

For all those AdSense account owners with Windows mobiles or tablets out there, I recently released a new UWP app that may come in handy. This simple app will allow you to quickly and easily check up on your AdSense performance.

Watch your monetization efforts pay off and your earnings grow

After logging in with your AdSense account and authorising the app for read-only access, you can easily see metrics such as:
  • Earnings Clicks, Cost Per Click
  • Page Views, Click Through Rate and RPM
  • Coverage

Code components that make it work

The app simply leverages Google APIs, specifically the AdSense Management API v1.4, and Google OAuth v2 for authentication of the user.  Basically, all calls to the AdSense APIs have to be authenticated or else they won't work.

So the first problem was to tackle Google OAuth v2 for a UWP app.  There are complexities around the Google provided libraries and support for UWP, and I have touched on these in another blog post.

OAuth v2 Authentication

The following code snippet deals with authentication successfully:

            UserCredential credential;
            try
            {
                using (var stream = new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
                {
                    credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
                        GoogleClientSecrets.Load(stream).Secrets,
                        new[] { AdSenseService.Scope.AdsenseReadonly },
                        "user",
                        CancellationToken.None,
                        new PasswordVaultDataStore()
                        );
                }
            }
            catch (UwpCodeReceiver.AuthenticateException ex)
            {
                // Login failed or authorisation not granted
                credential = null;
                await LoginFailed(ex);
            }
            catch (Exception ex)
            {
                credential = null;
                await SomethingWrong(ex);
            }

Creating a client service for your API calls

Once the user has logged on and authenticated their AdSense account, and granted permissions to the app so it can access the user's AdSense details, you then create a client service to use for your API calls.  Pass the credential object created by the code above to the http initializer.

            var adSenseService = new AdSenseService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "AdSense Accounts Stats",
            });

Setting up and executing an API request

After the user has logged on and allowed access for the app, the next piece is to construct a valid API request, execute it and handle the response in a meaningful way.  This can be achieved along the following lines:

            var earningsRequest = adSenseService.Reports.Generate(startString, endString);
            earningsRequest.Dimension = dimensionString;
            earningsRequest.UseTimezoneReporting = true;
            earningsRequest.Metric = new List<string>{ "earnings","page_views","individual_ad_impressions","clicks",
                                                "page_views_ctr","individual_ad_impressions_ctr",
                                                "page_views_rpm","individual_ad_impressions_rpm","cost_per_click",
                                                "ad_requests_coverage" };

            var earningsResponse = await earningsRequest.ExecuteAsync();

Once you have that response object, you can use it in any way you see fit, for example use its member items as a list source etc.

Hope you enjoyed this post and if you like go grab the app from the Microsoft Store.

Cheers

MB



Google OAuth2 for UWP C# XAML Apps Example

I have previously posted on consuming Google YouTube APIs in UWP C# XAML apps, showing how to consume Google APIs using the API key technique for authentication.

That technique works well, but has its drawbacks.  Mainly, you can't access any of the non-public user specific information that the APIs expose.  In other words, to get to the juicy bits you need to make authenticated Google API calls.  To do that, you need to work out Google OAuth2 authorisation flows.

Now, that's easier said than done if you are a part time hack like myself, and not a serious developer.  Through lack of skill I need to rely on the dotnet API libraries that Google kindly provides.  There are a good number of blog posts out there that detail the API key method, but not many that have a working example for using Google OAuth2 as per Google's developers API reference samples..

This is where this post kicks in.  But it also comes with a disclaimer (see below).  The following code snippet is an actual working example for a Google API OAuth2 authentication flow.  It uses the Google provided libraries which can readily be downloaded from Nuget and implemented in your project in Visual Studio.  Just use the Nuget Package Manager and search available packages for Google.Apis.

The magic sauce here is that the good folk at Google have fixed the OAuth flow for UWP C# only in a beta release of their dotnet libraries.  Specifically version 1.31.0 beta 01.  In the package manager, make sure to tick the box to include pre-releases, or else you won't get the beta on the list of available packages.


And here is the disclaimer... the mainstream release - currently up to 1.32.0 - does NOT work.  The code will build but fail at run time.

Enough said.  Following is the example code that will manage your Google OAuth2 authentication flow for you.  It prompts the user to log in with a Google account, authorise our example App, access the user's AdSense account, grab a list of payments for the account and finally display the results as the items source on a XAML ListView. Sounds tough?  Not really, just a few lines of code 😃

Of course, instead of accessing the AdSense Management API we could access the YouTube Data API or any of the other Google APIs presumably. I have only tested AdSense and YouTube, though.

     private async void PopulateAdsenseList()
     {
         UserCredential credential;
         using (var stream = new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
         {
             credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
                 GoogleClientSecrets.Load(stream).Secrets,
                 new[] { AdSenseService.Scope.AdsenseReadonly },
                 "user",
                 CancellationToken.None
                 );
         }
         var adSenseService = new AdSenseService(new BaseClientService.Initializer()
         {
             HttpClientInitializer = credential,
             ApplicationName = "Your App Name",
         });
         var myPayments = adSenseService.Payments.List().Execute();
         MyList.ItemsSource = myPayments.Items;
     }

Of course you will have to have a XAML page with a ListView (in this case called "MyList") to display the retrieved list of payments.

Just remember, don't be tempted to upgrade your Google.Api Nuget packages.  Stick with the 1.31.0. beta 01 release, or your code will break!  We'll have to wait until the devs at Google fix the libraries properly for UWP support.

Hopefully the above makes sense and you enjoyed reading this post.  If you have any questions or comments, why not drop me a line via email or comment below.

Cheers

MB


YouTube Channel Stats UWP App Update 1.3.3 Released

Release 1.3.3 for YouTube Channel Stats UWP App


Just a quick update on the progress of the app.  It has been in the Microsoft Store now for around five months, and has had two additional releases since its inception.

In November I added channel search functionality which made it much easier to obtain the channel ID for your YouTube channel that you wanted to get stats for.  While it all worked pretty well, the app was in dire need of a bit of a UI style makeover 😃

Well, the December release was aimed at exactly addressing this shortcoming.  The search page results list is now styled with channel thumbnails and a more appealing list item layout.  I'll show how this was done in a separate post shortly.  The main page got a makeover as well and now works better in portrait layout on smaller mobile phone screens. It also sports the addition of a channel thumbnail.

You might wonder how the app is tracking.  Here are a few current stats:
  • 5 months in the Microsoft Store
  • Over 1200 acquisitions
  • Over 1800 installations
  • Retention approx. 5% (Daily Active Users / Monthly Active Users)
All pretty interesting for something that started out as a learning exercise.  But what is next for the app?  Some interesting functionality I think would be to get some of the available analytics data into graphical views and charts, and possibly also some revenue metrics as many users of the app are likely to be content creators with monetized videos.  All in good time...

Best of all, the app is still available completely free of charge, with no annoying ads or in-app purchases.

If you are a Windows phone user who has a YouTube channel, this app is for you.  Grab it from the Microsoft Store and enjoy.

Wishing everyone a Merry Christmas 🎄

MB

Cool Custom Dashboards with IBM Tivoli Monitoring 6.3


Here is a little gem for those out there who actually use IBM Tivoli Monitoring v6.3 (aka ITM) and are looking for a simple way to add decent graphical dashboard views to your Tivoli Enterprise Portal (aka TEPS).

Let me say upfront this is not the only way to add dashboards to your ITM installation. In fact ITM has a data provider for IBM Dashboard Application Services Hub, or DASH in short, that will allow you to create good looking dashboards for big screens mounted in your operations center, or stakeholder areas. But this takes a bit of setting up, and sometimes the good old simple tricks still have some merit, right? So let's see how it could be done. Ah yes, and I'm assuming you have ITM running on Linux servers...

4 Easy Steps to Create Your Custom Dashboard

At a high level, there are 4 simple steps to create your custom dashboard . You will need to already have Tivoli Enterprise Portal (TEPS) access, with the relevant permissions to create your own custom workspaces.

  1. Build a PowerPoint backdrop and save as .png 
  2. Upload to TEPS Linux server using WinSCP 
  3. Log into TEPS and create Custom Navigator 
  4. Configure Custom Workspace with Graphic View 

More Detailed Instructions...

The following instructions and screenshots should be sufficiently detailed so that you can follow along and set up your own custom dashboards. The steps do assume a familiarity with Tivoli Monitoring and workspace customisation. Uploading of custom background images requires administrative privileges on the TEPS.

1. Build your PowerPoint backdrop

Open PowerPoint, grab a blank slide and insert some shapes to mimic the topology or logical grouping of your server environment. For example, you might do something like the following that shows a small R server deployment for production and non-production:


When you have all the objects arranged to your liking, jazz it all up with some logos or any other images that are appropriate. Finally, select and group all your objects, then right click and save as a .png image file. You have just created the backdrop for your dashboard. Nice work.

2. Upload to TEPS server using WinSCP

This step requires administrative privileges on the TEPS server. Start WinSCP, enter your server name, user name and password to log in.


Acknowledge any warnings and info messages and continue login. Once in WinSCP, on the left hand side, find the path to the .png image backdrop file you created. On the right hand side, find the path to your ITM installation directory, for example /opt/ibm/itm/lx8266/cw/classes/candle/fw/resources/backgrounds/


Drag and drop the desired image backdrop file from left to right, and acknowledge any prompts (default transfer settings should be okay). Note that the .png file extension needs to be lower case for this to work. Seems to be a quirk with Linux and/or maybe more likely the TEPS.

3. Log into the TEPS and create a Custom Navigator

The idea here is to log into the TEPS and set up a custom workspace view. Start with creating a new custom navigator. Click on the Edit icon.

This will give you a new window with two sides. The left hand Target View is the view you are about to build out with the same logical grouping / topology you used in the PowerPoint backdrop. An example could be Web, App and Database tier groupings.

Change the right hand side Source View to Physical in the drop down. Then find the servers you want and drag and drop them over to the left into the respective tier’s folder. When all is done, save and close.


4. Configure Custom Workspace with Graphic View

You should now have your custom navigator showing up on the left back in the TEPS. Ensure you highlight the top level of your custom navigator structure. This is the workspace we are about to build out with a Graphic View.

Note that custom workspaces can be built on each level of the navigator, meaning you can have different views for each folder, aggregation group, server, agent etc. You get the idea.

With the top level of the custom navigator highlighted, click on the Graphic View icon in the TEPS toolbar. Then move your mouse into an existing free widget, and click into the space to drop the graphic view widget in. Delete any unnecessary widgets from the workspace.

Then on the newly dropped in Graphic View, right click and select Properties. Click in the middle of the picture under Style. Browse for the image backdrop you uploaded previously. And lastly, browse for the css style sheet you want to apply – use shape_black_label_bottom.css for consistent look.


Voila, there you have it. Save the workspace, and you should end up with something that looks similar to this:


Here we have a simple graphical view of the health status of an application team’s environment. Additionally, the “traffic lights” could be wired up to jump to respective tier or detailed server views, allowing IT Operations people to drill down to the root cause of the red light. Hovering over will also pop the actual situation(s) that triggered the red light.

TEPS further allows access to run historical reports against many metrics, assisting in root cause analysis of failures and outages, leveraging the monitoring agent data that is constantly collected and fed into the Tivoli Data Warehouse. Both short term detailed and long term aggregated data is available.

All in all a pretty neat simple and quick trick to get a decent looking custom dashboard view you can put in front of anyone.

Hope you enjoyed the post. Feel free to comment and let me know what you think.

MB

Quick Look at Application Availability Monitoring using free IBM Cloud Service

I recently wrote about web application availability monitoring using Microsoft Azure and Application Insights.  You can read all about that here. Spoiler alert - Microsoft's offering is pretty impressive 😀.

Not wanting to favour one vendor over another, I figured I'd have a quick look at the IBM equivalent.  IBM's cloud has recently been rebadged. What was previously known as Softlayer and/or Bluemix is now officially named IBM Cloud.

IBM Cloud has a freemium model where some services - the ones deemed "lite" - are free.  Luckily, their Application Availability monitoring service falls into this bucket so that allowed me to have a go and road test the solution. Let's take a look...

IBM Cloud - Application Availability Monitoring




It was relatively simple to get things going, although there seem to have been a couple of quirks and hiccups.  Nevertheless, the following five high level steps will get you going:

  1. Sign up for an IBM Cloud account - the free one will do
  2. From the Catalogue, create a new basic/free CloudFoundry app - seems that availability monitoring can only be connected to a CloudFoundry app on the IBM Cloud
  3. From the Catalogue under the DevOps heading, create a new Availability Monitoring service - connect this to your CloudFoundry app
  4. Create and configure a new synthetic test - these can be for web pages or APIs, single action or multistep tests; pick the worldwide locations from where to run the test, frequency, and response validation rules
  5. Voila, wait for the tests to run and you will start to get response times and success/failure alerts

The visualisations and views are not bad out of the box, although navigation takes a little getting used to.  Following are some screenshots to give you a bit of an idea what you can expect:





The Verdict

In Summary, this is a decent service, and the synthetic multi step tests to mimic an end user transaction are handy.  The test has to be written in Selenium and uploaded to the IBM Cloud as far as I understand.

The screens seem to not always render and refresh reliably, but that could just be an issue with my browser.  My basic free CloudFoundry .NET app seems to be crashing regularly, but I suspect that I have not given it enough memory to run.

If you are an existing IBM customer who is already in the IBM ecosystem, this new capability is worth exploring.  The ability to drill down on the synthetic transaction results and get a waterfall type view of step timings is neat.

One drawback is that this service does not run independently from IBM Cloud hosted apps.  In other words, you cannot use it to monitor just any website, unlike the Microsoft flavour. Unless I have missed something?

Ultimately, try it and see if it's right for you.  It may be worth your time exploring this one. Enjoy.

MB


Links

IBM Cloud
CloudFoundry
Selenium



Visual Studio Team Services - 5 Good Reasons that make it a Great DevOps Toolkit for Everyone

Microsoft Visual Studio Team Services - A great DevOps Toolkit for Agile Teams

Really, I hear you ask? Why is that? Are there not more established players with better tools in the market? Well, let's give it a bit of context...

Traditionally we would run projects at work the old fashioned way, employing a traditional waterfall delivery model. Like everyone else however, we were wondering what all the hype of Agile, Lean, Scrum and goodness-knows-what was all about. You know, all this new age rage that promises to be so much more effective in delivering projects.

Not wanting to miss out, we grabbed the opportunity as soon as a software development centric project rolled along. We decided to challenge ourselves and deliver this one using Agile. But where do you start with all that? Luckily, some of us had some formal yet basic Agile training and with a bit of research and chatting to like minded folk we felt we had a good basis to get going.

We quickly decided that an Agile wall with sticky notes, cards and blutack was not for us, even though I am of the firm opinion that you can effectively manage projects in that fashion. We wanted a tool to help us, as we set out to manage our work items like Epics, Features, Stories and Tasks, needed a Git based repository for our code, and a visual way of reporting our progress.

Looking around for tools, we quickly zeroed in on the Atlassian kit as they are certainly setting the trend in a fragmented DevOps space and appear to have mature offerings that get good reviews. However, we remembered that Microsoft are playing in this space these days with their Visual Studio Team Services (VSTS) product. In fact, Gartner recognises Microsoft as a Leader in their 2017 Magic Quadrant for Enterprise Agile Planning Tools.

So we decided to have a closer look, and here is where it got interesting. VSTS has a freemium pricing model, where small DevOps teams of up to five people can join a VSTS subscription/workspace, and use this for work item management, Git repositories, load tests and other things for free. Continuous Integration and Delivery pipelines can be set up and appear to work well particularly when used in context of Microsoft's Azure cloud services.

But I digress. The purpose of this post was to outline the key reasons why I think it is worthwhile looking at VSTS if you are a small team wanting to get in on the Agile act and you are looking for a tool to help.  So here we go, in no particular order...

Five Good Reasons that make VSTS a great DevOps toolkit

1. Ease of setup and onboarding - get going fast

Just head over the visualstudio.com/team-services and sign up for free to create your workspace. Then simply create a New Project, give it a Name and Description, select your Version Control format as Git, and your Work Item Process methodology as Agile.


Voila, this will give you a new project shell, with a dashboard for visualisation, a git repository to manage your code, and a work item management area with initial iterations configure.  There is a bit more setting up to do, but it is all very intuitive and within an hour or two you will have everything exactly as you need it to start managing your project

2. It's free for up to 5 people

Yes, free.  Free private Git repos, work tracking, load testing (to a degree), CI and CD pipelines.  And if you have a MSDN subscription by chance, you don't count against the limit of 5 free people but can access it in addition.  Free stakeholder access also included

3. Seamless Git integration with Visual Studio

If you develop in Visual Studio, VSTS will seamlessly integrate.  Push and pull / synch your code to the Git repo online.  Never leave your IDE.

4. Collaborative work item management

Easily manage your backlog, plan your sprints and work collaboratively using mentions to easily keep team members up to date on progress

5. Visually track progress

Sprint burn down, cumulative flow and team velocity charts come out of the box and together with your backlog and task board views allow you to keep track of what is happening at any point during your project


VSTS really served us well and was simple and intuitive to use.  We delivered the full scope of the project right on time and budget.  Reporting and tracking was a breeze thanks to the built in charts that came right out of the box.  And did I mention it did not cost us a cent to get the tool? \

I have to admit I am a bit of a fan - not often you get a useful solution like this for free.  Give it a shot if you are out there wondering about Agile DevOps tooling to use in your next project, and let me know how you went.

Cheers

MB


Some further reading:

Visual Studio Team Services
Atlassian






Consuming Google APIs In UWP XAML / C# Apps

Google APIs and UWP - How does it all work?

Out of curiosity and for my own education, I recently started to look into Google APIs and how a Universal Windows Platform (UWP) App could consume such web APIs.  Specifically, I wanted to hook the YouTube API to easily get access to basic YouTube channel statistic on my Windows phone.

But how to get started?  As usual one turns to Google for research, and I found there was plenty of material available to get started.

I quickly decided that I wanted to have a crack at actually creating a functional app rather than just do some dry research.  After all, applying the knowledge helps with understanding and retention, right? 

Furthermore, I was curious how hard it would be to actually then publish such a working app in the Windows store.  So I set about finding out, but that will be another post in itself.

Accessing Google APIs - Authentication is Key

There is a lot of material on the web on how to access the Google provided web APIs.  Fundamentally, calls to the Google APIs have to be authenticated. And as far as I can see, there are two options:
  1. Use an API Key
  2. Use OAuth2 Authentication
The first method is simple enough to get going, the second one not so easy when you are dealing with a UWP XAML / C# app.  The main reason for that is that the Google code samples and libraries for OAuth2 actually don't work for UWP C# yet.  While you can freely download the libraries and the code will successfully build, it actually fails at run time.

Google mentioned they would address this and fix their code libraries down the track, but there is no time frame from what I can gather.

Hence I concentrated on the first method of using an Authentication Key.  To get started set up an account and log into the Google Developers API Console.  Once in, click on Enable API which will land you on the Library page where you can pick which Google API to actually enable/allow.


In my case I selected the YouTube API for my app.

Then click on Credentials on the navigator on the left, followed by the Create Credentials button.  This will create an API Key and pop up a window containing your new key.  Be sure the restrict and secure that key so others can't steal your volume allocation. And of course don't publish that key in public code repositories by accident.


Needless to say the one in this screenshot is just for illustration purposes and no longer exists so don't bother copying it 😉.

Let's Get Coding - Visual Studio and Google Nuget Packages

I'm not a developer, so I'm not going to pretend I know exactly what I am doing, but for the purpose of this educational exercise it was simple enough to get going.

Grab Microsoft Visual Studio - the free Community Edition will do just fine - and start your XAML / C# UWP project.  I cheated and used the newly available UWP WindowsTemplateStudio project to create a basic, Windows Store compliant UWP app.

Next I downloaded the required Google API Nuget packages, in this case Google.Apis.YouTube.V3 and I think Google.Apis.Services.  I then cobbled together a XAML UI and a button to click to fetch and display basic YouTube Channel Statistics.



Next I put some code into the button click event handler in the page's code-behind.  It's along the lines of the following:


        private void button_Click(object sender, RoutedEventArgs e)
        {
            var youtubeService = new YouTubeService(new BaseClientService.Initializer()
            {
                ApiKey = "Your-API-Key-From-Google",
                ApplicationName = "BlazingTMYouTubeViewCounter"
            });

            var channelsListRequest = youtubeService.Channels.List("snippet,statistics");
            channelsListRequest.Id = "UCkW0h_mbdmo0YChc0fzMkQw";

            var channelsListResponse = channelsListRequest.Execute();

            foreach (var channel in channelsListResponse.Items)
            {
                var channelViewCount = channel.Statistics.ViewCount.Value;
                textBox1.Text = Convert.ToString(channelViewCount);
            }

            textBox.Text = this.GetType().ToString();
        }


Now that's nowhere near actually the final working code, but you get the drift. You create a new YouTubeService object (part of the Google API Nuget packages code), and set your ApiKey and optional ApplicationName property.

Then you create YouTubeService.Channels.List request object, set a default channel ID and execute the request.  And lastly you have to process the response and display the required values in the UI.

If you are a serious developer, you are probably laughing by now at my description, but hey that's okay.  This is just for illustration purposes.

In any case, I managed to build a basic UWP XAML / C# app which was working fine on my PC and Lumia 930 Windows mobile.

As mentioned earlier in this post, I actually also went on to publish the app in the Windows Store just to get familiar with the process.  If you are curious, search the Windows Store for an app called YouTubeChannelStats, download and install for fun.  Very basic but it works.

How all that was done will be the subject of another post some time.  Hope you enjoyed this one and feel free to comment and share.

Cheers

MB
Get it from Microsoft

Load Test Your Web App in 5 Minutes

Recently I have been exploring the capabilities and merits of Microsoft Azure and Application Insights, and have stumbled onto another rather interesting and useful piece of functionality.

Application Insights can easily be combined with Visual Studio Team Services to quickly set up a load test for your web application.

Why Bother with Load Tests?

But why bother with load tests, you might ask?  Is it not good enough that a web application functions as designed with no errors when you do your user acceptance testing?  Surely that's all that matters, right?

Not necessarily.  There have been many recent examples of rather embarrassing failures of high profile web applications due to the sheer number of people trying to access it at the same time.  Who could forget the first Click Frenzy event, or more recently the Australian Census.

Digital businesses rely on web app performance and reliability

It becomes very real if you are a modern digital business, relying on the availability and performance of your web application for revenue, customer satisfaction and brand loyalty.  Your next big online promotion is coming up and you are hoping to drive sales and revenue hard.  But if your promo turns out to be a cracker, is your web application ready for the onslaught of your customers?

The answer is that you absolutely should test and push your application to its limits, so you can understand the capacity of compute you need to sustain the targeted number of concurrent visitors.  Of course you could just use the power of the cloud and automatically scale your application horizontally. But that would make for a whole other post another time.

Visual Studio Team Services to the rescue

Enter Visual Studio Team Services.  If your web app happens to run in Azure, most likely you have already set up an Application Insights workspace to gain visibility on your application's performance and availability. Right from the portal you can also set up a Load Test.  If you haven't already linked a VSTS account, you can do so by creating one on the fly.



Next simply configure the parameters of your load test, give it a name,  what URL to test, duration, how many concurrent users, and from what location to test.  Then sit back and let Azure App Insights and VSTS do the heavy lifting for you.


It will only take a little while to acquire the required resources to run the test but soon enough your test will kick in and the user load is generated.

Are there alternatives?

Of course there are many other testing and load generator tools available in the market.  Some of the more traditional options in this space that I am aware of and know reasonably well are HP LoadRunner and IBM Rational. These don't just do web applications but can also deal with legacy and LOB application testing. Add to this many newer generation web application centric testing tools and you can take your pick for what suits your circumstances best.

In Summary

Application Insights and VSTS are interesting, capable and low cost options and are worth a look if you are a developer in the Microsoft space and/or your applications already run on Azure.  I found the quick and easy setup for simple URL based load tests valuable.  Knowing ahead of time what loads your web application can handle will mean you are always well prepared for the next online sales drive or promotional event.


Watch This Quick Demo



Links

Microsoft Application Insights
HP LoadRunner
IBM Rational Functional Tester

Most Popular Posts