Reading Notes #341

IMG_20180815_181252Cloud


Programming


Integration


Miscellaneous


Books

  • VaporizedVaporized: Solid Strategies for Success in a Dematerialized World (Robert Tercek) - I really loved that book. In this world of digital transformation where everything goes so fast, this book explains why you should care. In fact, it asked so many good questions and related facts. I like to pretend I'm aware of the new technologies. That I'm on the edge, that I'm aware of the trending stuff... But guess what?! I got surprised, and even a bit scare at one point. This book is a must. Enjoy! ASIN: B01F9G31H8

Reading Notes #340

fan-out-fan-in

Cloud


Programming


Integration


Miscellaneous


Reading Notes #339

IMG_20180725_154113

Cloud



Programming



Data



Miscellaneous



~Enjoy!


Reading Notes #338

ChocolateyGUI_main_screen

Suggestion of the week




Cloud


    Programming


      Miscellaneous





        Reading Notes #337

        IMG_20180707_220101

        Cloud



        Programming



        Data



        Miscellaneous




        Reading Notes #336

        MSInspire2018

        Cloud



        Programming


        Miscellaneous



        Reading Notes #335

        IMG_20180622_184715Suggestion of the week


        Cloud


        Programming


        Data


        Miscellaneous



        How create a static website on Azure Storage

        I have been waiting for this feature for so long! I know; it's not a major feature, but it fills an important gap in the Azure offer. We can now create static websites in the Azure Blob Storage (as I'm writing this post the service is still in preview). In this post, I will explain why I think it's a really good news, show how to create and publish on a static website.

        Why It's an Awesome News


        The cloud is the perfect place when you need to build something huge very quickly. It's also an excellent solution when you have a lot of variance in the number of resources it required. Because Azure is a service, it will provide you as many resources as you would like in few minutes. And when you are done with the resources you stop paying for them; and it's really great like that!
        However, if the only thing you need was to host a little something like a blog or a little website for an event or some temporary publicity Azure was not the best place for it. I mean yes of course, you could build a service and host many little websites on it (Scott Hanselman as excellent posts about that like this one), but it felt always a bit overkill for most of the users. Some people kept an "old style" host provider just for that. I mean it's fine, it works... But with Azure storage, it will be really reliable, and at a lower cost! Let's see how we can create one.

        Create a Static Website


        To have the static website feature you need to create an Azure Blob Storage account the same way you created them before, however, it needs to be of kind General Purpose V2 (GPV2). Today if you install the Azure CLI Storage-extension Preview, you can use it to create one, or simply go on the portal.azure.com. Let's use the portal since it's more visual.

        createStorage
        Once the storage is created, open it. On the left menu of the storage blade, click on the Static website (preview) option. That will open the configuration page for our static website. First, click the Enabled button then enter the initial/ index document name (ex:index.html). Finally, click the Save button on the top of the blade.

        ConfigureStatic
        The shell for our website is now created. A new Azure Blob Storage container named $web h been created. The Primary and secondary endpoint should now be displayed (ex: https://frankdemo.z13.web.core.windows.net/). If you test this URL, you will see and message saying that the content doesn't exist... and it's normal.

        emptywebsite

        Create some content


        This is the part where it all depends on your needs. You may already have some HTML pages ready, or you may want to code them all yourself, or the website may previously exist. For this post, I will create a brand-new blog using a static website generator named Wyam (if you would like to see how to do it with Jekyll, another generator, I used it in the video)
        To create a new template with Wyam you use the following command in a command prompt. That will create a new website in the subfolder output.
        wyam --recipe Blog --theme CleanBlog

        Publish to Azure


        It's now time to upload our content to the Azure blob Storage. The easiest is probably directly from the portal. To upload a file, click on the $web container, then the Upload button. From the new form, select the file and upload it.

        portalUpload
        The main problem with this method is the that it only works one file at the time... And a website usually has many of those...
        A more efficient way would be to use Azure Explorer or some script. Azure Explorer doesn't support yet the Azure Storage Static Website, but it will be soon. So that leads us to scripts or command lines.

        AzCopy


        I really like AZCopy as it's very efficient and easy to use. Unfortunately, as I'm writing this post, AzCopy doesn't support the Azure Storage Static Website. I try to upload all content from the output folder (and sub folders)) with a command like this, but it fails.
        azcopy --source ./output --destination https://frankdemo.blob.core.windows.net/$web --dest-key fec1acb473aa47cba3aa77fa6ca0c5fdfec1acb473aa47cba3aa77fa6ca0c5fd== --recursive

        Azure CLI


        An Azure CLI extension preview is also available. Like I mentioned previously, the extension gives you the possibility to create a static website or update the configuration, to upload files you have two options the batch would be more efficient of course, but the file by file option also works. Thanks to Carl-Hugo (@CarlHugoM) for your help with those commands.


        az storage blob upload-batch -s "./output" -d $"web" --account-key fec1acb473aa47cba3aa77fa6ca0c5fdfec1acb473aa47cba3aa77fa6ca0c5fd== --account-name frankdemo
        

        az storage blob upload -f "./output/index.html" -c $"web" -n index.html ---account-key fec1acb473aa47cba3aa77fa6ca0c5fdfec1acb473aa47cba3aa77fa6ca0c5fd== --account-name frankdemo

        Visual Studio Code Azure Storage Extension

        I finally tried the Visual Studio Code Stogare Extension. After installing it, you need to add a User Setting Ctrl + ,. Then add "azureStorage.preview.staticWebsites" : true to your configuration. Now you just need to click on the extension, then select Azure blob storage from your subscription, and right click to be able to upload a folder.

        vscodeupload
        Depending on how many files, and their sizes it will take a moment. VSCode will notify you when it's done. You will then be able to get back online and refresh your website to see the result.

        website

        Conclusion


        I'm very happy to see that feature because it fills a need that was not really cover yet by the Microsoft offer. Right now, it's an early preview so even if the service is very stable, not all the tools support it but that only temporary. Right not you can set your custom domain name, however, HTTPS is not supported.
        So what do we do with it? Should we wait or jump right on? Well as the best practices imply when a feature is in preview don't put your core business on it yet. If you are just looking to build a personal website, a little promo than... enjoy!

        In video, please!


        I also have a video of this post if you prefer.




        References




        Reading Notes #334

        canadaflag

        Suggestion of the week

        • HTTPS Is Easy! (Troy Hunt) - A wonderful series of 4 videos that explains how to get secure with https. A must!

        Cloud


        Programming


        Miscellaneous


        Reading Notes #333

        flag-28555_640Cloud


        Programming


        Data


        Reading Notes #332

        IMG_20180616_101111

        Cloud


        Programming


        Books

        • [Invisible Ink: A Practical Guide to Building Stories That Resonate] (Brian McDonald)  - We all know it, a story is the element that will give that little plus to our post, and video. This short book explains how to really make an effective one talking about the not visual things...
          Really interesting.

          ISBN 0984178627 (ISBN13: 9780984178629)

        Reading Notes #331

        IMG_20180609_102403-EFFECTS

        Cloud


        Programming



        Books



        Miscellaneous



        How to Deploy your Azure Functions Faster and Easily with Zip Push

        Azure functions are great. I used to do a lot of "csx" version (C# scripted version) but more recently I switched to the compile version, and I definitely loved it! However, I was looking for a way to keep my deployment short and sweet, because sometimes I don't have time to setup a "big" CI/CD or simply because sometimes I'm not the one doing the deployment... In those cases, I need a simple script that will deploy everything! In this post, I will share with you how you can deploy everything with one easy script.

        The Context


        In this demo, I will deploy a simple C# (full .Net framework) Azure functions. I will create the Azure Function App and storage using an Azure Resource Manager (ARM template) and deploy with a method named Zip push or ZipDeploy. All the code, script, a template is available on my Github.

        The Azure Functions Code


        The Azure Function doesn't have to be special, and it can be any language supported by Azure Functions. Simply to show you everything, here the code of my function.

        
        namespace AzFunctionZipDeploy
        {
            public static class Function1
            {
                [FunctionName("GetTopRunner")]
                public static async Task Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequestMessage req, TraceWriter log)
                {
                    log.Info("C# HTTP trigger function processed a request.");
        
                    string top = req.GetQueryNameValuePairs()
                        .FirstOrDefault(q => string.Compare(q.Key, "top", true) == 0)
                        .Value;
        
                    if (top == null)
                    {
                        dynamic data = await req.Content.ReadAsAsync< object>();
                        top = data?.top;
                    }
        
                return top == null
                        ? req.CreateResponse(HttpStatusCode.BadRequest, "Please pass a number to get your top x runner on the query string or in the request body")
                        : req.CreateResponse(HttpStatusCode.OK, new { message = $"Hello, here is your Top {top} runners", runners = A.ListOf(int.Parse(top)) });
                }
            }
        
            class Person
            {
                public string FirstName { get; set; }
                public string LastName { get; set; }
                public int Age { get; set; }
            }
        }
        

        It's a really simple function that will return a list of Person generated on the fly. The list will contain as many person as the number passed in parameter. I'm using the very useful GenFu library, from my buddies: ASP.NET Monsters.

        The only thing we need to do is to create our compress file (Zip or Rar) that contains everything our project required.

        createZip

        In this case, it's the project file (AzFunction-ZipDeploy.csproj), the function's code (Function1.cs) the host (host.json) and local settings of our function (local.settings.json).

        The ARM template


        For this demo, we need one Azure Function App. I will use a template that is part of the Azure Quickstart Templates. A quick look to the azuredeploy.parameters.json file and we see that the only parameter we really need to set is the name of our application.

        
        {
            "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
            "contentVersion": "1.0.0.0",
            "parameters": {
                "appName": {
                "value": "zipdeploydemo"
                }
            }
        }
        

        To be able to ZipDeploy, we need to add one Application Setting to let the Kudu interface we need its help to compile our code. To do that let's open the azuredeploy.json and go to the appSettings section. We need to add a new variable named: SCM_DO_BUILD_DURING_DEPLOYMENT and set it to true. After adding the setting it should look like this (see the last one... that's our new one):

        
        "appSettings": [
            {
            "name": "AzureWebJobsDashboard",
            "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
            },
            {
            "name": "AzureWebJobsStorage",
            "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
            },
            {
            "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
            "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
            },
            {
            "name": "WEBSITE_CONTENTSHARE",
            "value": "[toLower(variables('functionAppName'))]"
            },
            {
            "name": "FUNCTIONS_EXTENSION_VERSION",
            "value": "~1"
            },
            {
            "name": "WEBSITE_NODE_DEFAULT_VERSION",
            "value": "6.5.0"
            },
            {
            "name": "SCM_DO_BUILD_DURING_DEPLOYMENT",
            "value": true
            }
        ]
        

        The Deployment Script


        Now that all the pieces are ready it's time to put it together one script. In fact, only the two last commands are required; everything else is just stuff to make it easier to re-use it. Check out my previous post 5 Simple Steps to Get a Clean ARM Template, to learn more about the best practices related to ARM template. So let's see that script, it's pretty simple.
        
            # script to Create an Azure Gramophone-PoC Solution
        
            resourceGroupName=$1
            resourceGroupLocation=$2
        
            templateFilePath="./arm/azuredeploy.json"
            parameterFilePath="./arm/azuredeploy.parameters.json"
        
            dateToken=`date '+%Y%m%d%H%M'`
            deploymentName="FrankDemo"$dateToken
        
            # az login
        
            # You can select a specific subscription if you do not want to use the default
            # az account set -s SUBSCRIPTION_ID
        
            if !( $(az group exists -g  $resourceGroupName) ) then
                echo "---> Creating the Resourcegroup: " $resourceGroupName
                az group create -g $resourceGroupName -l $resourceGroupLocation
            else
                echo "---> Resourcegroup:" $resourceGroupName "already exists."
            fi
        
            az group deployment create --name $deploymentName --resource-group $resourceGroupName --template-file $templateFilePath --parameters $parameterFilePath --verbose
        
            echo "---> Deploying Function Code"
            az functionapp deployment source config-zip -g $resourceGroupName -n zipdeploydemo --src "./zip/AzFunction-ZipDeploy.zip"
        
            echo "---> done <--- code="">

        The only "new" thing is the last command functionapp deployment source config-zip. That where we specify to the Azure Function App to look to --src to get our source. Because I'm running it locally, the path is pointing to a local folder. However, you could execute this command also in the CloudShell, and that would become a URI... to an Azure Blob Storage by example.

        Deploy and Test


        If you didn't notice yet, I did my script in bash and Azure CLI. That because I want my script to be compatible with all platforms. Of course, you could have done it in PowerShell or anything else that would call the REST API.

        To deploy, just execute the script passing the ResourceGroup name, and its location.

            ./Deploy-AZ-Gramophone.sh cloud5mins eastus

        ScriptOutputs

        To get to Function URL, go to the Azure portal (portal.azure.com) and click on the Function App that we just deploy. Click on the function GetTopRunner in this case, and click on the </> Getfunction URL button.

        GetFunctionURL

        Use that URL in postman and pass another parameter top to see we the deployment ws successful.

        postmanTest

        In Video Please


        If you prefer, I also have a video version of this post.



        ~Enjoy!

        Reading Notes #330

        IMG_20180602_073928

        Cloud


        Programming


        Data

        • Apply a Filter to a Slicer (Mike Carlo) - Sooooo useful. If you don't know how to do it (yet), just watch the video, you'll thanks me later.

        Miscellaneous



        Reading Notes #329

        IMG_20180527_154913

        Suggestion of the week



        Cloud



        Programming



        Books

        jab_cover
        Jab, Jab, Jab, Right Hook: How to Tell Your Story in a Noisy Social World (Gary Vaynerchuk) - Great book, for all of us you are trying to tell something, pass a message on the social media... This is a must.




        Miscellaneous


        Reading Notes #328

        Cloud

        • 10 Reasons to Use Durable Functions (Mark Heath) - To celebrate his new course about durable function, Mark shares with us his top10 of the best reason with should use durable functions.

        Programming


        Data

        • Power BI Desktop May Feature Summary (Amanda Cofsky) - The monthly updates is always a great new. This month shows more about that new Q&A feature... You may not know about it, but you really want to use it...
        • Data Encodings and Layout (Clemens Vasters) - Very useful and deep article that provides the best practices for data encoding for different type of situation.

        Books

        Exactly What to Say, The Magic Words for Influence and Impact
        (Phil M. Jones)
        I listen to this audio book and really enjoy it. Simple powerful key works selection tat helps us to get where we want to go. It was only about two hours long and I listen to it in one shoot. And I’m mostly certain I will listen to it again.
        ISBN 9780692881958



        Miscellaneous