Tag: Azure

Azure

How to return JSON from an Azure Function

In this post I’m going to answer a question someone asked me recently when I presented an Introduction to Azure Functions – can we return JSON from the HttpTrigger function? The answer is yes and it’s not limited to the Http trigger function and I’ll walk you through one of many ways to do this.

First let’s start off by taking a look at the output that shows up by default from the HttpTrigger Function I had created in the Azure portal. As you can see the default output is XML as shown here:

image

The same goes for the response when the require “name” parameter is missing in the query string or the body of the request:

image

You might think that there is a simple property in the Azure Function properties to configure the output, but there isn’t, at least at this point in time with version 1 runtime.

Creating a C# Http Trigger Function

Let’s quickly create an Azure Function in the portal and I can show you one of many ways to return JSON from your Azure Function.

1. Create a new Serverless Function App:

image

image

2. Once your Azure Function app is running, create a new C# Http trigger function and then provide it a name and authentication model:

image

image

3. Now that your function is created you will see the following code in the run.csx file. If you run it you will get XML as your response, so let’s go ahead and update this function to return JSON.

image

Changing the return type to JSON

For this example I’ll import Newtonsoft.Json package and then serialize a simple object to return back when the function is called.

1. Add Newtonsoft.Json package and other using references:

image

2. Update function code to use Newtonsoft.Json. Looking at the following code you will see that I’ve created a simple POCO object which is what I’ll be returning from the function. I then changed the response to return a serialized string in UTF8 encoding and application/response:

image

3. Now when we run the function through either the browser or Postman we’ll see the response in JSON format. Here is what we would see in Postman:

image

and then in a browser we would see this:

image

Azure Functions is a powerful component in Azure serverless offering and as you can see your not limited to XML as the only response format.

Let me know if you have any questions and I’d be happy to investigate and follow up.

Enjoy!

Uncategorized

Downloading Microsoft Docs as PDF

Did you know you can download a specific set of docs as a PDF without it taking gigabytes of space, enabling you to take it anywhere with you on your desktop or mobile device.

Simply go to the particular docs you’re interested in, for example the Azure Application Architecture Guide and then below table of contents on the left side you will see a Download PDF button.

image

Clicking the Download PDF button will open up the latest version of the docs for this topic in a browser and from here you can click to save.

image

As you can see it downloaded a 73 page PDF document with all the content found online.

As content is changed online, clicking the Download PDF will result in getting the latest version of this document.

To follow up and learn about other updates to the Microsoft Docs site, follow their blog at https://docs.microsoft.com/en-us/teamblog/.

image

Enjoy!

References

https://docs.microsoft.com/en-us/teamblog/docs-november-update

https://docs.microsoft.com/en-us/teamblog/

https://docs.microsoft.com/en-ca/azure/

Azure

Microsoft Azure Roadmap and Updates

Azure has three areas online where you can go to keep up to date with Azure updates and what the roadmap is for certain products within Azure.

Microsoft Cloud Platform Roadmap

The Microsoft Cloud Platform Roadmap provides a snapshot of what Microsoft is working on in their cloud platform business. From here you can use the roadmap to find out what they’re recently made generally available, released to public preview, are still developing and testing, or what’s no longer being developed. You can search by Product Category and/or Status.

For Product Category you have the following categories:

  • Application development
  • Cloud infrastructure
  • Data management and analytics
  • Enterprise Mobility + Security
  • Internet of Things

For Status type you can search by the following types:

  • All
  • In Development
  • In Preview
  • Now Available

image

For each result there is a date of when it was last updated and then a status of either In Development, In Preview, and Now Available.

image

Finally you can can click the Learn more link for further details about this update.

Azure Roadmap

The Azure Roadmap page shows you where they’re heading and any upcoming changes to Azure products. This is the place to find out what’s new

image

Azure Updates

The Azure Updates page allows you to see all the updates in one place. You can filter by product, update type and even platform.

image

Enjoy!

References

https://azure.microsoft.com/en-us/updates/

https://azure.microsoft.com/en-us/roadmap/

https://www.microsoft.com/en-us/cloud-platform/roadmap/

AzureCloud

Essential tool for blurring Azure secrets for presentations and screen recordings

azure-mask

For those that do Azure presentations / screen recordings you know that you often find yourself scrubbing out your sensitive and personal information such as subscription keys, email addresses, keys and connection strings. What if you could have this magically done for you?

Well let me introduce to you a handy Chrome extension called Azure Mask that will mask GUIDs (such as Subscription IDs), email addresses, keys, and connection strings with a blur. The intention of the extension is to make it easier to do screen recordings without revealing sensitive, personal, account information that may show up on screen.

NOTE: This extension will only run and apply against Azure portal URLs.

Features

  • Blurs GUIDs (such as Subscription IDs)
  • Blurs your account email
  • Hides the "Report a Bug" button (if found)
  • Toggle the mask on/off and store this state
  • Apply the mask (if enabled) after Document Object Model (DOM) mutations

Installing the Extension

As mentioned on the Azure Mask GitHub repository readme, you can install this extension in Chrome from either a package or from source. Let’s take a look at how we can install from source.

  1. Download or clone the repository: git clone git@github.com:clarkio/azure-mask.git
  2. Open up Chrome and bring up the extensions settings by typing in the address bar: chrome://extensions/
  3. Check the “Develop mode” option and click on Load unpacked extension button:image
  4. Navigate to where you cloned this repository and then choose path: /azure-mask/src
  5. Follow the prompts and then the extension will be available in Chrome:sshot-116

Using Azure Mask

After installing the Azure Mask extension in Chrome, navigate to your Azure portal and after signing in you will see all your Azure secrets magically blurred:

image

If you want to turn off this extension, click on the Azure Mask extension button in Chrome to bring up the options:

image

Enjoy!

References

Azure-Mask on GitHub

Cloud

Microsoft’s new Azure & AWS Cloud Service Map

image

Microsoft recently introduced a new Cloud Service Map to help customers and developers quickly compare the capabilities between Amazon Web Services and Microsoft’s Azure cloud platform across all categories. You can leverage this guide for planning multi-cloud solutions or simply to migrate from AWS to Azure.

The cloud service map (PDF available for download) is broken out into 13 sections to make navigation between each service simple:

  1. Marketplace – Cloud marketplace services bring together native and partner service offerings to a single place, making it easier for customers and partners to understand what they can do.
  2. Compute – Compute commonly refers to the collection of cloud computing resources that your application can run on.
  3. Storage – Storage services offer durable, highly-available, and massively-scalable cloud storage for your application, whether it runs in the cloud or not.
  4. Networking & Content Delivery – Allows you to easily provision private networks, connect your cloud application to your on-premises datacenters, and more.
  5. Database – Database services refers to options for storing data, whether it’s a managed relational SQL database that’s globally distributed or multi-model NoSQL databases designed for any scale.
  6. Analytics and big data – Make the most informed decision possible by analyzing all of the data you need in real time.
  7. Intelligence – Intelligence services enable natural and contextual interaction within your applications, using machine learning and artificial intelligence capabilities that include text, speech, vision, and search.
  8. Internet of Things (IoT) – Internet of Things (IoT) services connect your devices, assets, and sensors to collect and analyze untapped data.
  9. Management & monitoring – Management and monitoring services provide visibility into the health, performance, and utilization of your applications, workloads, and infrastructure.
  10. Mobile services – Mobile services enable you to reach and engage your customers everywhere, on every device. DevOps services make it easier to bring a higher quality app to market faster, and a number of engagement services make it easier to deliver performant experiences that feel tailored to each user.
  11. Security, identity, and access – A range of capabilities that protect your services and data in the cloud, while also enabling you to extend your existing user accounts and identities, or provisioning entirely new ones.
  12. Developer tools – Developer tools empower you to quickly build, debug, deploy, diagnose, and manage multi-platform, scalable apps and services.
  13. Enterprise integration – Enterprise integration makes it easier to build and manage B2B workflows that integrate with third-party software-as-a-service apps, on-premises apps, and custom apps.

This guidance is laid out in a convenient table that lets you quickly find and learn more about each of the services you’re most interested in. In this instance, you can quickly see the service name, description and the name of the services in AWS and Azure. Links are also provided for each of the Azure services.

image

Enjoy!     

Additional Resources

Cloud Service Map for AWS and Azure Available Now

Downloadable PDF of the Cloud Service Map for AWS and Azure

Azure

Introduction to Azure File Sync

azure-file-sync

Azure File Sync is meant to provide customers a secure and centralized file share management in the cloud. Once installed you will be able to store less frequently accessed files on the cloud and then keep more frequently accessed files on your local file shares, all while delivering a consistent file share performance with no configuration or code changes required. Azure File Sync could also lower IT support requirements for remote or branch locations.

Azure File Sync was released as a preview on September 25, 2017. Currently the public preview availability is limited to the US regions and works with Windows Server.

For more details on Azure File Sync checkout the announcement blog post and the following is a quick overview video…

image 

Enjoy!

References

Announcing the public preview for Azure File Sync

Azure File Sync Overview

Azure Storage

Docs – Introduction to Azure Files

Azure

FAQ: Azure App Service Domain and Custom Domains

I came across an excellent blog post from the Azure App Service Team BlogFAQ: App Service Domain (preview) and Custom Domains. Lots of great of questions and answers relating to Azure DNS and your custom domains.

If you have any questions or have run into issues with your custom domain and Azure this is a great resource, so check it out!

Reference

Azure App Service Team Blog

DevelopmentDevOps

Visual Studio Team Services Build to the Rescue

So this week Visual Studio Team Services build and release saved me and my team.

At our company we have configured an on premise continuous integration server along with build agents using TeamCity which is a product from JetBrains. TeamCity Professional is actually a free application that allows you to run 3 build agents. The only cost is the associated hardware and Windows licensing. I fell in love with TeamCity years ago when I set it up at our company and it’s been a very stable and a versatile CI server since. However this week I ran into some issues with our TeamCity server and the fact that it was on premise only added to the problem. Let me explain.

Our build server physical infrastructure is actually located offsite from our office (along with other dev/qa servers), so when I say on premise I really means its dedicated hardware that we own and not up in the cloud. The situation we ran into is that our TeamCity server didn’t restart properly and was unavailable by remote access by the ITOPS team, this meant someone had to go to the offsite location and reboot the server. Now you might be wondering, why don’t you have a backup…a good question and something I’ll be looking into.

What made matters worse is that we we’re nearing the end of a regression cycle and we wanted to deploy later this week. So having our build server drop off the grid was just bad timing and it meant DEV and QA were in a holding pattern while we waited for our build server to be brought back up and hopefully it was ok and not corrupted or worse.

While we waited for our build server to be restarted I started thinking about worse case scenarios like what if our build server is dead and we need to rebuild or restore from a backup (and what do you know it was out of date). None of these options can be done quickly and they require unplanned resources from the ITOPS team and myself.

Having already explored Visual Studio Team Services (VSTS) build and release services for my personal development and that of our Live .NET logging tool ReflectInsight, I knew I could easily and quickly get one of our applications setup in that continuous integration pipeline. You will actually be shocked at how quickly I got things going.

Our current build process typically builds the solution, runs unit tests, creates a nuget package and then finally publishes the nuget package to an internal nuget repository that is part of TeamCity. We then have an automated deployment service called Octopus Deploy that picks up this package and can then deploy to any of our QA and/or production systems. Since our TeamCity server is offline, I would need to publish the nuget package to another destination for the time being. I decided to create an Azure Storage account and then copy the nuget package there. I could then pull the nuget package down and manually upload to our Octopus Deploy server.

To get started I headed over to my Visual Studio Team Services account I had setup with my MSDN subscription and I then created a new project to contain my builds. I then clicked on the Build & Release tab and then clicked on the New button to create a new build definition:

image

I then clicked on the ASP.NET (PREVIEW) featured template:

image

I then configured the Get sources task to point to our GitHub repository and then I added in the last two steps for generating a NuGet package and to copy the generated NuGet package to an Azure Storage account:

image

I wont go into detail for each of these build tasks as their pretty straight forward, but after I had everything setup and tested, I looked at the clock and it was under 15 min from start to finish. That is something I could never have done in our existing on premise build infrastructure and it now looks like I have my backup solution.

One of the nice things about using the hosted agent in VSTS is that it’s located in Azure and its a service that is managed by the Azure team. This means I spend more time focusing on developing my applications and less time worrying about managing the associated build infrastructure and what happens if a server goes down, performing backups, restores and that all hands on deck feeling when your infrastructure goes down at the worse possible time.

Enjoy!

References

TeamCity

Visual Studio Team Services

Azure Storage Explorer

Octopus Deploy

AzureDevelopment

How to: Build and deploy an Angular app to Azure using Visual Studio Team Services

This post will guide you on how to build an Angular 4 app using Visual Studio Team Services and then deploy it to an Azure App Service instance.

So let’s review what we’ll need before we begin:

  1. You will be required to have an active Visual Studio Team Services account. If you don’t have one you can signup for free here.
  2. You will also need to have an active Azure subscription. If you don’t have one you can signup for a free trial here.

Now that we have met the requirements, let’s get started.

Create a new build definition

We will start by signing into your Visual Studio Team Services account and then navigating to the Build & Release tab from the top navigation links to create a build. From here we will click on the New button to define a new build definition.

image

Next you will choose a template to use for your build. There are a lot of build templates so take a look at what’s available and choose what is most appropriate for your needs. If you don’t see what you want, you can always choose the empty template which is what I’m going to do now and then add the necessary build tasks that make sense for you.

image

After selecting the empty template you will want to name your build definition, connect your source code repository (Github, Visual Studio Team Services, other) and then start adding build tasks:

image

Click on the Get sources link on the left side to wire up your source code for the build. In this demo I’m connecting to my personal Github repository:

image

Now that we have our source code wired up, you’re ready to start defining your build tasks.

Defining your build process tasks

Now that we have our build definition configured to our source repository, it’s time to start adding build process tasks. To do this we click on the Add Task button from the left which will then present a listing of available build tasks (some of which are in preview):

image

In this post I want to build an Angular app, so I will need to use an npm build task. Using the search box I will type in npm and the listing will then filter out to only show me any npm build tasks. At this time there is one, so I will click on it and then the Add button to add it to my build process:

image

This will be the configuration for our npm install task:

image

Next we will need to add another npm build task for running the Angular CLI build command ng build. This will be the configuration for our npm run task:

image

At this point our build is installing all necessary npm packages and then running an npm command to build the Angular app. Once the app is built, I like to archive the build artifacts in a ZIP file. This will be our configuration for our archive files build task:

image

Finally we will deploy our app to an Azure App Service instance. To do this you will want to have your Azure App Service already pre-configured. You can checkout this post for details on creating an Azure App Service.

This will be our configuration for our Azure App Service Deployment build task. There are 3 settings you need to set:

  1. Select you Azure subscription
  2. Select your App Service name
  3. Select the package or folder you wish to deploy

image

Here is a review of the build tasks we created above:

image

Queue a new build

Once we have our build process defined we can kick off a new build by clicking on the Queue button on the top toolbar:

image

This will being up the queue build modal where you can define the agent queue to use, the branch to build or a specific commit along with defining build variables, etc. I will select the Hosted agent queue and my master branch. I will then click on the Queue button to initiate the build:

image

For more information on the differences between the hosted agents, checkout this link for further details.

You should now notice that your build is now queued:

image

Viewing your build process

You can click on your build at anytime and see detailed output for what is happening during the build process along with view and/or download detailed log files:

image

Voila, our build is now finished:

image

Visual Studio Team Services build can also be configured to send out an email when builds succeed and/or fail:

image 

Now that I have a successful build, lets browse and take a look at our deployed Angular app: http://blog-angular-deployment.azurewebsites.net/ .

Wrap up

I hope this post helps your build and deploy your Angular apps to Azure. As you can see it’s very straight forward to setup and requires no build infrastructure on your end to make it happen.

Enjoy!

References

Azure free trial

Visual Studio Team Services

Build and release tasks

Hosted agents

Angular

Angular CLI

Azure

Tips to managing your Azure subscription

The following are a few tips for managing your Azure subscription. Start by navigating to the Subscription blade and then click on a Subscription you wish to manage:

image

From here you have a clear overview of your Subscription ID and the current spending with a breakdown by resource.

Renaming your subscription

To rename your Subscription, in my case I want to change it from “BizSpark-$70” to “MSDN-Professional-$70” as that is a new MSDN subscription I purchased and changing the name properly reflects that subscription and the Azure credits associated with it.

To rename the Subscription, click on the Subscription name:

image

You can now enter in a new Subscription name and when you’re done click on the Save button. The subscription name change can take up to 10 minutes to be reflected on the Azure portal.

image

After the subscription has successfully been renamed, you’ll receive an alert:

image

Configuring email invoices

The Azure portal recently allowed you to opt in and configure email invoices. This means instead of receiving an email each month that your invoice is ready which required you to login to the Azure portal, now you can have the invoice emailed to you instead, which is awesome!

If you haven’t already setup email invoices, from the Azure Subscription blade, click on Invoices:

image

From the Invoices blade, you can now click on the Invoices button and then from here you can opt-in and configure it:

image

If you already opted in, you can review your current configuration and also configure the list of recipients (maybe you want the invoice sent to your accounting department also). When done, click the Done button at the bottom:

image

Enjoy!

Resources

Azure Portal