<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>2017-06 on Funky Si's Blog (Dev)</title><link>https://blog-dev.funkysi1701.com/2017/06/</link><description>Recent content in 2017-06 on Funky Si's Blog (Dev)</description><generator>Hugo -- gohugo.io</generator><language>en-gb</language><managingEditor>funkysi1701@gmail.com (Simon Foster)</managingEditor><webMaster>funkysi1701@gmail.com (Simon Foster)</webMaster><lastBuildDate>Mon, 26 Jun 2017 20:00:45 +0000</lastBuildDate><atom:link href="https://blog-dev.funkysi1701.com/2017/06/index.xml" rel="self" type="application/rss+xml"/><item><title>Using Azure WebJobs to automate</title><link>https://blog-dev.funkysi1701.com/posts/2017/using-azure-webjobs-to-automate-stuff/</link><author>funkysi1701@gmail.com (funkysi1701)</author><pubDate>Mon, 26 Jun 2017 20:00:45 +0000</pubDate><guid>https://blog-dev.funkysi1701.com/posts/2017/using-azure-webjobs-to-automate-stuff/</guid><category term="Automate">Automate</category><category term="Azure">Azure</category><category term="Cron">Cron</category><description>&lt;p&gt;I keep hearing about Azure WebJobs but I have never used them. Time to change this.&lt;/p&gt;
&lt;p&gt;WebJobs are a feature of Azure App Service that can run a script at a specific time. In my case I would like to hit a specific url of my website at the same time every day.&lt;/p&gt;
&lt;p&gt;
&lt;img class="img-fluid" alt="WebJobs" src="https://blog-dev.funkysi1701.com/images/2017/addkeepalivewebjob.png" loading="lazy"
width="313" height="615"
/&gt;
To the right you can see an example of the WebJobs form on the Azure portal that you need to fill in.&lt;/p&gt;
&lt;p&gt;You need to supply a name for your webjob.&lt;/p&gt;
&lt;p&gt;You need to upload the script that will run in my case I used a powershell script. My script consisted of which basically just loads the url specified.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$progressPreference = &lt;span style="color:#e6db74"&gt;&amp;#34;silentlyContinue&amp;#34;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$result = Invoke-WebRequest -Uri (&lt;span style="color:#e6db74"&gt;&amp;#34;https://www.google.com&amp;#34;&lt;/span&gt;) -Method Get -UseBasicParsing;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Type refers to if your job will be triggered or run continuously, I want it to be triggered.&lt;/p&gt;
&lt;p&gt;Triggers refers to if you want it to be scheduled or manual, something that you can run on an ad hoc basis. I of course want scheduled.&lt;/p&gt;
&lt;p&gt;If you are familiar with the linux CRON then the next box will make sense to you for everyone else I will try and make sense of it. The box consists of 6 numbers which can either have a value or a *. The numbers correspond to the following {second} {minute} {hour} {day} {month} {day of the week}.&lt;/p&gt;
&lt;p&gt;A hourly job would be expressed as 0 0 * * * *, ie every day of week, every month, every day, every hour and only when minute and second equals zero. For more help with this check out the &lt;a href="https://docs.microsoft.com/en-us/azure/app-service-web/web-sites-create-web-jobs#CreateScheduledCRON" target="_blank" rel="noopener noreferrer"&gt;MSDN docs&lt;/a&gt;
about it. I want to use 0 30 21 * * * to run daily at 9.30pm.&lt;/p&gt;
&lt;p&gt;That’s it everything setup, now time to wait and see if it works.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Oh no!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;It failed to run at the specified time.&lt;/p&gt;
&lt;p&gt;The reason for this is the scheduler requires the feature Always On to be turned on which is not available in the free App Service. Before you reach for your wallets, I found a solution on this &lt;a href="https://tomssl.com/2016/12/20/how-to-get-azure-webjobs-to-run-indefinitely-for-free/" target="_blank" rel="noopener noreferrer"&gt;blog post&lt;/a&gt;
that allows them to run on the free tier.&lt;/p&gt;
&lt;p&gt;The thinking behind this solution is you need to keep the website alive throughout the day so Tom has created a script that does this. His script can be found on his blog or on his &lt;a href="https://github.com/TomChantler/Self-KeepAlive" target="_blank" rel="noopener noreferrer"&gt;github page&lt;/a&gt;
.&lt;/p&gt;
&lt;p&gt;Set this script up to run every 5 minutes (0 */5 * * * *) like the example above.&lt;/p&gt;
&lt;p&gt;The nextthing you need to do is create a Custom connection string in the Application Settings blade called SecretThing. Tom’s script references this to access the website and keep it alive. The password you need to put in SecretThing can be found in you publish profile (downloaded from the Overview blade in the Azure portal). For more details and a better explanation check out &lt;a href="https://tomssl.com/2016/12/20/how-to-get-azure-webjobs-to-run-indefinitely-for-free/" target="_blank" rel="noopener noreferrer"&gt;Tom’s blog&lt;/a&gt;
.&lt;/p&gt;
&lt;p&gt;One last thing to mention about WebJobs is that you can see details about when they have run at https://[YourWebAppName].scm.azurewebsites.net/azurejobs/#/jobs and this can be a great place to help debug your scripts.&lt;/p&gt;</description></item><item><title>Fiddler and APIs</title><link>https://blog-dev.funkysi1701.com/posts/2017/fiddler-and-apis/</link><author>funkysi1701@gmail.com (funkysi1701)</author><pubDate>Mon, 19 Jun 2017 20:00:45 +0000</pubDate><guid>https://blog-dev.funkysi1701.com/posts/2017/fiddler-and-apis/</guid><category term=""/><category term=""/><description>&lt;p&gt;A while ago I blogged about &lt;a href="https://www.funkysi1701.com/posts/2017/automation-promotion/" target="_blank" rel="noopener noreferrer"&gt;promoting&lt;/a&gt;
my blog with Buffer. At the time I made use of the nuget package &lt;a href="https://www.nuget.org/packages/BufferAPI/" target="_blank" rel="noopener noreferrer"&gt;BufferAPI&lt;/a&gt;
but lets look at some improvements I can make.&lt;/p&gt;
&lt;p&gt;The BufferAPI package worked great from my console app, but when I tried to use it from a Controller in an MVC app I never got it to work. Lets look at the API docs and see if I can rewrite it.&lt;/p&gt;
&lt;p&gt;There are two main types of API calls GET which gets data from the server and POST which posts data to the server. These come from the types of HTTP requests.&lt;/p&gt;
&lt;p&gt;
&lt;img class="img-fluid" alt="Alt Text" src="https://blog-dev.funkysi1701.com/images/2017/6wozrfdoqvtjaoxs7j1v.jpg" loading="lazy"
width="638" height="359"
/&gt;
&lt;/p&gt;
&lt;p&gt;I quickly figured out how to use the GET API call to authenticate using &lt;a href="https://api.bufferapp.com/1/profiles.json?access_token=XXXX" target="_blank" rel="noopener noreferrer"&gt;https://api.bufferapp.com/1/profiles.json?access_token=XXXX&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;However POST was defeating me. That was until I remembered &lt;a href="https://www.telerik.com/fiddler" target="_blank" rel="noopener noreferrer"&gt;Fiddler&lt;/a&gt;
.&lt;/p&gt;
&lt;p&gt;I had heard Troy Hunt (and others) talk of using Fiddler to examine what data is being passed among websites. Troy uses it to do a man in the middle test to see what information can be stolen.&lt;/p&gt;
&lt;p&gt;It is really easy to setup, install Fiddler, click yes to a few security warnings and you can see what information is being passed from your code to remote APIs.&lt;/p&gt;
&lt;p&gt;Once I had Fiddler installed I could compare what information is being passed between a successful API call using the BufferAPI nuget package and an unsuccessful API call using my code.&lt;/p&gt;
&lt;p&gt;Fiddler also showed that passing my authentication token in a POST request is much better. Despite both GET and POST being encrypted when using HTTPS, anything at either end that logs URLs will have a log of your username and password.&lt;/p&gt;
&lt;p&gt;If you have not tried Fiddler, give it a try especially if you are doing things with API calls.&lt;/p&gt;</description></item><item><title>Add Power BI data to a webpage</title><link>https://blog-dev.funkysi1701.com/posts/2017/how-do-i-add-power-bi-data-to-a-webpage/</link><author>funkysi1701@gmail.com (funkysi1701)</author><pubDate>Mon, 12 Jun 2017 20:00:45 +0000</pubDate><guid>https://blog-dev.funkysi1701.com/posts/2017/how-do-i-add-power-bi-data-to-a-webpage/</guid><category term="PowerBI">PowerBI</category><category term=""/><description>&lt;p&gt;Last week I talked about &lt;a href="https://www.funkysi1701.com/posts/2017/businessintelligence/" target="_blank" rel="noopener noreferrer"&gt;Power BI&lt;/a&gt;
, what it is and some of the different services you can use with it. This week lets add some of that data to a simple web page.&lt;/p&gt;
&lt;p&gt;For this example I am going to add the google analytics data from this website to this page.&lt;/p&gt;
&lt;p&gt;First login to your Power BI &lt;a href="https://app.powerbi.com/" target="_blank" rel="noopener noreferrer"&gt;https://app.powerbi.com/&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;Click the get data link at the bottom left.&lt;/p&gt;
&lt;p&gt;Click My Organisation to bring up the app search box.&lt;/p&gt;
&lt;p&gt;
&lt;img class="img-fluid" alt="Alt Text" src="https://blog-dev.funkysi1701.com/images/2017/46c1lyxy053xcq66fowf.jpg" loading="lazy"
width="768" height="406"
/&gt;
&lt;/p&gt;
&lt;p&gt;Click the Apps tab and search for “google” in the search box, you should then see Google Analytics, click into this and then click the get it now button.&lt;/p&gt;
&lt;p&gt;Log into your google account. If you have multiple google accounts I found it worked best to sign out of all of them or run this in an incognito window.&lt;/p&gt;
&lt;p&gt;Once you are signed in you should see a list of the different google analytics data you have, select the one you want to use and click import.&lt;/p&gt;
&lt;p&gt;Power BI will then go away and start loading the data.&lt;/p&gt;
&lt;p&gt;Once loaded go to Reports and select the Google Analytics that has been loaded. If you have more than one, it is a good idea to rename each one eg Corporate Site Google Analytics, Blog Google Analytics so you won’t get mixed up.&lt;/p&gt;
&lt;p&gt;In the file menu select Publish to web and agree that you are OK for this to be made public.&lt;/p&gt;
&lt;p&gt;You will then be given a piece of HTML code that starts with &amp;lt;iframe copy this onto your web page. Reload your webpage and you should see something similar to mine below.&lt;/p&gt;
&lt;p&gt;It should be noted that while you can but the webpage containing the iframe behind a login page, the data could still be accessed if you knew the url contained within the iframe, this is why the link can be emailed and continue to work.&lt;/p&gt;</description></item><item><title>What is Business Intelligence here?</title><link>https://blog-dev.funkysi1701.com/posts/2017/businessintelligence/</link><author>funkysi1701@gmail.com (funkysi1701)</author><pubDate>Mon, 05 Jun 2017 20:00:45 +0000</pubDate><guid>https://blog-dev.funkysi1701.com/posts/2017/businessintelligence/</guid><category term="ApplicationInsights">ApplicationInsights</category><category term="BusinessIntelligence">BusinessIntelligence</category><category term="SQL">SQL</category><description>&lt;p&gt;The term &lt;strong&gt;Business Intelligence (BI)&lt;/strong&gt; refers to technologies, applications and practices for the collection, integration, analysis, and presentation of business information. The purpose of Business Intelligence is to support better business decision making. Essentially, Business Intelligence systems are data-driven Decision Support Systems (DSS). Business Intelligence is sometimes used interchangeably with briefing books, report and query tools and executive information systems.&lt;/p&gt;
&lt;h2 id="what-is-power-bi"&gt;What is Power BI?&lt;a class="anchor ms-1" href="#what-is-power-bi" aria-label="Permalink: What is Power BI?"&gt;&lt;i class="fas fa-link" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Power BI&lt;/strong&gt; is a business analytics service provided by Microsoft. It provides interactive visualisations with self-service business intelligence capabilities, where end users can create reports and dashboards by themselves, without having to depend on any information technology staff or database administrator.&lt;/p&gt;
&lt;p&gt;Microsoft describe it as follows: &lt;strong&gt;Power BI&lt;/strong&gt; is a suite of business analytics tools that deliver insights throughout your organisation. Connect to hundreds of data sources, simplify data prep, and drive ad hoc analysis. Produce beautiful reports, then publish them for your organisation to consume on the web and across mobile devices. Everyone can create personalised dashboards with a unique, 360-degree view of their business. And scale across the enterprise, with governance and security built-in.&lt;/p&gt;
&lt;h2 id="what-can-you-do-with-it"&gt;What can you do with it?&lt;a class="anchor ms-1" href="#what-can-you-do-with-it" aria-label="Permalink: What can you do with it?"&gt;&lt;i class="fas fa-link" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;One of the first thing you can do with Power Bi is connect some of the apps that you use.&lt;/p&gt;
&lt;p&gt;To sign up to use Power BI go to the &lt;a href="https://www.microsoft.com/en-us/power-platform/products/power-bi/" target="_blank" rel="noopener noreferrer"&gt;Power BI website&lt;/a&gt;
.&lt;/p&gt;
&lt;p&gt;Once you are signed in click the get data link in the bottom left corner and browse through the apps you can use.&lt;/p&gt;
&lt;p&gt;If your website uses google analytics you can connect it up to Power BI and see some cool analytics. The below map was generated from some google analytics data, you can see that this website has had users across the globe, with UK and USA getting a lot of hits.
&lt;img class="img-fluid" alt="Business Intelligence from Google Analytics" src="https://blog-dev.funkysi1701.com/images/2017/Capture.jpg" loading="lazy"
width="1189" height="627"
/&gt;
&lt;/p&gt;
&lt;p&gt;Another thing you can do is connect Azure Application Insights. This provides some similar data to google analytics about who is visiting your site.&lt;/p&gt;
&lt;p&gt;If your code is hosted in Visual Studio Team Services you can get some cool analytics from your commit history.
&lt;img class="img-fluid" alt="Business Intelligence from VSTS" src="https://blog-dev.funkysi1701.com/images/2017/Capture-1.jpg" loading="lazy"
width="1299" height="348"
/&gt;
&lt;/p&gt;
&lt;p&gt;There is a huge long list of apps you can connect to power BI so you can start getting all sorts of analysis very easily. I am hopefully going to talk another time about getting custom data into Power BI.&lt;/p&gt;</description></item></channel></rss>