Giter Club home page Giter Club logo

2018bootcamp's Introduction

2018 Microsoft Azure Global Bootcamp

Develop & Deploy Azure Functions using Visual Studio

Please follow the instructions https://docs.microsoft.com/en-us/azure/azure-functions/functions-develop-vs

  • Setup Azure Development workload on Visual Studio 2017
  • Update Azure Functions and Web Jobs Tools
  • Create an Azure Functions App
  • Deploy Azure Functions

Setup CosmosDB using Azure Portal

Please follow the instructions https://docs.microsoft.com/en-us/azure/cosmos-db/create-sql-api-dotnet

  • Create a database account
  • Add a collection
  • Add sample data
  • Query your data

Ignore the rest of the sections on this page

Integrate CosmosDB with Azure Functions

  • Add Nuget package Microsoft.Azure.WebJobs.Extensions.DocumentDB to Azure Functions App
  • Add DocumentDB binding to the Run method
public static HttpResponseMessage Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "myapi/{id}")]HttpRequestMessage req, string id, TraceWriter log,
              [DocumentDB("CosmosDB", "CosmosDBCollection", SqlQuery = "select * from c where c.id = {id}", ConnectionStringSetting = "CosmosDBConnection")]IEnumerable<dynamic> inputDocuments,
              [DocumentDB("CosmosDB", "CosmosDBCollection", ConnectionStringSetting = "CosmosDBConnection")]out dynamic outputDocument)

{
    var inputDoc = inputDocuments.FirstOrDefault();
    outputDocument = inputDoc;
    var response = new HttpResponseMessage()
    {
        StatusCode = HttpStatusCode.OK,
        Content = new StringContent(JsonConvert.SerializeObject(inputDoc), Encoding.UTF8, "application/json")
    };
    return response;
}
  • Create CosmosDBConnection as an entry under values section in local.settings.json, and copy paste the CosmosDB Key here

2018bootcamp's People

Contributors

bwwilliam avatar

Stargazers

Mike Howell avatar Tom Dinh avatar

Watchers

James Cloos avatar  avatar

Forkers

mikehowell

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.