Tag: Azure Functions

Azure

How to cleanup your Azure Functions URL and remove /api from the route

We looked at Azure Functions. We also looked at security around Azure Function used to implement APIs. Something people will quickly notice when implementing an Webhook / API function is that its URL or route is always prepended by /api. For instance, if we create a webhook function in C# and we setup the route […]

via How to get rid of /api in Azure Function’s route? — Vincent-Philippe Lauzon’s

Azure

Azure Serverless: Azure Functions and Logic Apps that are ready to deploy!

image

If you’re new to Azure Functions and/or Logic Apps there is a great open source library for you to browse that contains set of common use cases that are ready to deploy!

If you want to create an Azure Resource Manager (ARM) template that deploys Functions or Logic Apps, you can build your own as shown here. Just provide your GitHub repository URL and it will quickly create an azure.deploy.json file for you to include with your repos.

image

Summary

These samples are available in a either C# or NodeJS and can be deployed to your Azure subscription with a click of a button. The samples cover a number of useful tasks that can easily be incorporated into your application or simply used for learning purposes. If you’re interested in contributing to this project or browsing through the code please take a look at the GitHub repository.

Enjoy!

    References

    http://functionlibrary.azurewebsites.net/

    https://github.com/jefking/FunctionLibrary

    Azure

    Try Azure Functions for Free

    In my previous post “Introduction to Azure serverless with Azure Functions, Logic Apps and Azure Event Grid” I briefly introduced each of those services from Azure. In this post I’ll show you how you can try Azure Functions for free without signing up for an Azure subscription. Let’s get started.

    Microsoft has setup a free sandbox environment for trying out Azure Functions for free. Navigate to the free trial link and select the function you want to create:

    image

    After clicking on the Create this function button you will be asked to choose an auth provider. Any will do and it’s just needed to get some basic information for the trial. No credit card information is required:

    image

    After a few seconds you should see your new HttpTrigger C# function (based on the selection from the previous screen). Click on the Run button to see your function run. From this portal you can edit your function code and save the changes, run the function and view the logs from the, test your function with different input, and see the output and status.

    image

    Your function also has a URL you can use to run your function outside of this portal. Go to the top right corner and click on Get function URL:

    image

    You will then see the get function URL modal with the key and URL. Click on the copy link and then open up another browser tab or use it within Postman:

    image

    Paste your function link and then add the required query string parameter Name with a value. You should then see the output of your function like so:

    image

    This environment is limited in what you can do. So although you can change your function code and the integrations it works with, you are prevented from managing your function app. You also only have only 59 minutes to try it out.

    image

    As you can see you can quickly try out Azure Functions in a sandbox environment. If and when you’re ready you can move to an Azure subscription where you can fully manage your Azure Function and get access to a world of other resources to use with your function app. It’s worth mentioning that with your Azure subscription you get access to a number of Azure resources for free within certain limits…including Azure Functions. So take a look and give Azure Functions a try.

    Enjoy!

    Resources

    Try Azure Functions for Free

    Azure Functions

    Azure

    Introduction to Azure serverless with Azure Functions, Logic Apps and Azure Event Grid

    image

    In this blog post I’ll introduce you to what is serverless and then what services in Azure provide serverless capabilities. First let’s define what is serverless.

    What is the definition of Serverless

    • It’s an abstraction of servers. This doesn’t mean there are no servers, there are still servers behind the scenes but this means you don’t need to worry about optimizing which OS to run, about OS patching, etc. You also don’t need to worry about optimizing utilization and scaling up and down for demand. Think of it as less server more code.
    • It’s an event driven process. You simple tell Azure how or when to run your code. This could be based on a schedule or when a new customer is added to Salesforce, or when items are added to a queue, to a table storage, etc.
    • It’s micro-billing. This means you’re only charged for your usage.

    The benefits of serverless

    • Reduced DevOps – You can dynamically and elastically scale to meet demand.
    • Focus on Business Logic – Allows you as the developer to focus on your business logic and everything else is taken cared of for you. No need to provision resources and wait on ITOPS. In some cases you can design and develop your serverless code offline.
    • Faster Time to Market – By focusing on your business logic and features, you’re able to drastically increase time to market.

    Let’s now look at three Azure services that provide serverless capabilities.

    1. Azure Functions

    image

    Azure Functions is an event driven, compute-on-demand experience. You can easily and quickly build the apps you need using simple serverless functions that scale and meet demand and you only pay for your usage.

    You can use the programming language of your choice like C#, F#, JavaScript, PHP, Python, Java or using scripting tools like Bash or PowerShell. You can develop on Windows, Linux or Mac. You can deploy on Windows or Linux. You can choose from using either the full .NET Framework or the .NET Core runtimes.

    Azure Functions allows you to bind into services. This means you can integrate Azure Functions into Cosmos DB, Logic Apps, queues, table storage, on premise and so much more.

    With Azure Functions you simply provide your code and then let Azure take care of the rest…meaning that when an event happens, Azure will automatically take care of everything to run that code at scale.

         

    2. Logic App Service

    Azure Logic Apps are built around the idea of events, triggers and workflows. When you think about building microservices, there are a lot of moving parts to manage. Azure Logic Apps lets you stitch them all together much more easily and provides you with a central place to build and manage all of your event-driven services.

    Logic Apps are a fully managed iPaaS (integration Platform as a Service) that provide serverless workflows that allow developers to easily integrate data with their apps instead of writing complex glue code between disparate systems. This allows you to orchestrate and connect the serverless functions and APIs of your applications.

    Benefits of Logic Apps

    1. You can quickly tap into the power of the cloud and fire events from other services.

    image

    2. You can orchestrate almost anything:

    • Run mission-critical, complex integration scenarios with ease
    • Connect on-premises, hybrid and cloud applications
    • Position for future with API centric connectivity
    • Easily connect custom on-premises applications to the cloud

    image

    Connectors

    At the time of this post there are over 200 connectors available out of the box. Connectors reduce integration challenges and enable you to quickly and easily connect apps, data and devices anywhere.

    Creating a Logic App

    The following is a sample Logic App. As you can see you simply string together Connectors, Triggers, Conditions and Actions to form the basis of your Logic App. When your Logic App is running you can monitor and inspect each run iteration and see what data came in and the path it took through the Logic App.

    image

    In summary Logic Apps is the workflow engine built for the cloud with cloud scale, massive compute and high availability built in.

    3. Azure Event Grid

    Finally there is Azure Event Grid which is a messaging service built to easily build application with event-based architectures. You simply select the Azure resource you would like to subscribe to, and give the event handler or webhook endpoint to send the event to. Event Grid also has built-in support for events coming from other Azure services, like resource groups, subscriptions, storage blobs, and event hubs.

    functional-model

    Topics and Subscriptions

    Event Grid is similar to Azure Service Bus in that a Topic is an endpoint that receives messages, and a Subscription is used to receive messages through the Topic that will be handled by a message listener. These concepts are basically the same, but there are some differences in how they work. Event Grid it uses a concept of events instead of messages since it’s an event-based messaging system, and because Event Grid is based on events, it lends itself nicely to microservice architectures using serverless compute options like Azure Functions and Logic Apps in addition to other implementations.

    There are also more differences between Azure Event Grid and other message queue services. The capabilities of Azure Event Grid are centered around speed, scale, breadth, and low cost. Rather than being a general / generic messaging service, Azure Event Grid is built specifically for Serverless architectures.

    Event Publishers

    Currently Azure Event Grid has built in support for the following event publishers:

    • Event Hubs
    • IoT Hubs
    • Storage
    • Blog Storage
    • Custom Topics
    • Azure Subscriptions (management operations)
    • Resource Groups (management operations)

    Event Handlers

    Currently the following Azure services have built-in handler support for Event Grid:

    • Azure Functions
    • Logic Apps
    • Event Hubs
    • Webhooks
    • Azure Automation
    • Microsoft Flow

    If using Azure Functions as your handler, use the Event Grid trigger over the generic HTTP trigger as it automatically validates Event Grid Function triggers.

    Azure Event Grid is built specifically for Serverless architectures.

    Event Grid Architectures

    Azure Event Grid is designed to be used in microservices and event based architectures. It can be used in a serverless application to connect data sources and event handlers. In an ops automation scenario you can notify Azure Automation when virtual machines are created, or when a SQL database is spun up. Finally you can use Event grid to connect your application with other services. The possibilities are really limited by your imagination.

    EventGridArchitecture1

    Summary

    As you can see all three services provide a different component to the serverless story and each of them integrate nicely with each other. They each allow you to think less about the server and more about your code and you only pay for your usage. The best way to learn about these Azure serverless offerings is to create a free Azure account and try it out yourself.

    Enjoy!

    References

    Azure Functions

    Docs: An introduction to Azure Functions

    Logic App Service

    Docs: An introduction to Logic App

    Azure Event Grid

    Docs: An introduction to Azure Event Grid

    Webinar: Go serverless. Build apps faster and stop worrying about infrastructure.

    Report: Economics of Serverless Cloud Computing

    Attribution: This post uses one or more graphics from the official Azure Event Grid documentation, such as diagrams.

    AzureDevelopmentPresentationsTechnology

    An Introduction to Serverless Compute with Azure Functions–My presentation at CTTDNUG

    AzureFunctions-e1491294484596

    Last week I did a presentation on Azure Functions at Canada’s Technology Triangle .NET User Group (CTTDNUG) in Kitchener, Ontario. One of the audience members was kind enough to film the presentation and post it on YouTube.

    Here is a link to my presentation on An Introduction to Serverless Compute with Azure Functions.

    Enjoy!

    References

    https://www.youtube.com/watch?v=bPMzW10pECQ&feature=youtu.be

    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!

    Azure

    Azure Functions Updates

    New Release of Azure Functions

    A new release of Azure Functions is now available, version 1.0.10917. The main things in this release are:

    • Application Insights integration (Preview)
    • Native TypeScript support (preview)
    • Improvements to binding extensibility for binding authors
    • JavaScript transpiler API/extension model
    • Miscellaneous bug fixes and improvements

    New Experience for Azure Functions

    The Azure Functions portal was also completely re-vamped with a new UI experience. Some of the improvements are:

    • A dedicated browse blade for Function Apps.
    • A tree view that allows viewing and managing multiple Function Apps
    • Filters on subscription and app name, as well as an option to scope the view to just one app
    • One-click access to all App Service platform features
    • A convenient way to manage features that have already been configured
    • Overall UI enhancements to be more consistent with the rest of the Azure portal

    image

    You can read more about the portal changes in the announcement blog.

    Enjoy!

    References

    https://blogs.msdn.microsoft.com/appserviceteam/2017/05/01/april-2017-app-service-update/

    Azure

    Azure Functions now with Application Insights integration

    Earlier this month Azure Functions was updated to have direct integration with Application Insights and is currently only available on the “beta” version of Azure Functions. At this time it’s recommended to only try this out in non-production Azure Function apps until it’s a more stable release.

    Getting Started

    Before we can enable Azure Function Application Insights integration, we will need to setup an Application Insights instance. If you already have one skip to the next step.

    1. Create an Application Insights instance and Application Type should be General. Once your Application Insights is setup, copy the instrumentation key which we’ll need in the next step.
      image
      image
    2. Next you will need to update your Azure Function Application Settings to configure your function to run under the “beta” version and then to set your Application Insights Instrumentation Key.image
    3. Now go to Application Settings and then update App Setting “FUNCTIONS_EXTENSION_VERSION” from “~1” to “beta” and then add a new key named “APPINSIGHTS_INSTRUMENTATIONKEY” and set the value to the Application Insights Instrumentation key you copied in step 1. Now click Save to update your Azure Function.
      image 

    Once this is done, your Application Insights instance will start collecting telemetry from your Azure Function without any code changes.

    Using Application Insights

    Going to your Application Insights, you can start to see some metrics showing up on the overview blade:image

    Live Metrics Stream

    You can get a lot more insights to real-time telemetry from the Live Metrics Stream to see what’s happening right now:
    image

    Analytics

    Another great resource of Application Insights is the Analytics portal, which provides you the ability to write your own custom queries.
    image

    Alerts

    The previous two options are great to see what is happening or what happened historically, but Alerts will tell you what’s happening. I suggest you checkout Alerts from the Application Insights blade, where you can define alerts based on a wide array of metrics.

    image

    Summary

    You can now add Application Insights to your Azure Functions with minimal effort, which is a powerful tool for monitoring your applications. Keep in mind that this is currently only available in the “beta” version of Azure Functions, but is something that should be coming to the production release in the near future now that it’s been merged into the develop branch on github.

    Enjoy!

    References

    Azure Functions integration with Application Insights

    Azure Functions now has direct integration with Application Insights

    Application Insights

    Live Metrics Stream docs

    Azure

    Take the Azure Functions Code Challenge!

    image

    Test your coding skills and learn how to build solutions using Azure Functions at the same time. Earn badges for every challenge you complete and brag to your friends! You can code these challenges in the FREE Azure Functions experience or using your existing Azure subscription. Don’t worry, Azure Functions has more than enough free executions for you to last the whole challenge experience!

    Also check out the new Visual Studio Tools for Azure Functions. Use it to build and debug your function locally and then publish or zip deploy to your test function. If you already have an Azure subscription, you can also remotely debug your functions.

    Azure Functions is an event-based serverless compute experience that scales based on your demand and you only pay for the resources used.

    Click here to get started with the Azure Functions Code Challenge!

    Enjoy!

    Resources

    Get started using the Try Functions experience here.

    Already have an Azure Subscription, then get started with your existing account here.

    Download the Visual Studio Tools for Azure Functions here.

    Azure

    Microsoft Azure Stack Technical Preview 3 Released

    image

    Today Microsoft announced that Azure Stack Technical Preview 3 has been released with several new updates.

    Azure and the Azure Stack integrated systems enable businesses to focus on investing energy and talent on turning their application portfolio into a strategic differentiator for their business. This approach enables customer choice and flexibility of deploying and operating their application where it best meets their business needs. IT can deliver far greater value by empowering development teams with self-service provisioning and cloud services while partnering with them to establish DevOps workflows that meet business policies and requirements.

    What’s new

    • Deploy with ADFS for disconnected scenarios
    • Start using Azure Virtual Machine Scale Sets for scale out workloads
    • Syndicate content from the Azure Marketplace to make available in Azure Stack
    • Use Azure D-Series VM sizes
    • Deploy and create templates with Temp Disks that are consistent with Azure
    • Take comfort in the enhanced security of an isolated administrator portal
    • Take advantage of improvements to IaaS and PaaS functionality
    • Use enhanced infrastructure management functionality, such as improved alerting

    Roadmap update

    Shortly after TP3, Azure Functions will now be available to run on Azure Stack TP3. This will be followed by Blockchain, Cloud Foundry and Mesos templates.

    TP3 should the last planned technical preview before becoming available in mid-CY17.

    Further reading and next steps

    Learn more about Azure Stack and download Azure Stack Technical Preview 3.

    Learn more about this announcement here.

    References

    https://azure.microsoft.com/en-us/blog/hybrid-application-innovation-with-azure-and-azure-stack/