Upgrade to Pro — share decks privately, control downloads, hide ads and more …

サーバーレスで作ろう! Azure Cosmos DB と Azure Functions... / CosmosDB and Functions

サーバーレスで作ろう! Azure Cosmos DB と Azure Functions... / CosmosDB and Functions

de:code 2019 で発表したスライドです。

スケーラブルで高速なバックエンドの仕組みを実現するには、サーバーレスなデータ ストアとジョブ実行環境の組み合わせが近道です。

このセッションでは、Azure Cosmos DB と Azure Functions の組み合わせで実現できるクラウド ネイティブなバックエンドの作り方について、OSS 技術を使ったモダンな開発環境を使ったデモを中心に解説します。

miyake

May 29, 2019
Tweet

More Decks by miyake

Other Decks in Programming

Transcript

  1. Azure Functions (Node.js) import { AzureFunction, Context } from '@azure/functions';

    const cosmosDBTrigger: AzureFunction = async function( context: Context, documents: Tweet[] ): Promise<void> { if (!!documents && documents.length > 0) { context.log('Document: ', documents[0].tweetText); } context.bindings.signalRMessages = [ { target: 'newMessage', arguments: [documents] } ]; };
  2. Azure Functions (.NET) public class Startup : FunctionsStartup { public

    override void Configure(IFunctionsHostBuilder builder) { builder.Services.AddDbContext<AppDbContext>((provider, options) => { var configuration = provider.GetRequiredService<IConfiguration>(); options.UseSqlServer(configuration.GetConnectionString("SqlConnection")); }); } } public Function1(AppDbContext context) { _context = context; }
  3. Vue.js signalr.js created: async function(): Promise<void> { console.log("VUE_APP_HOST: ", process.env.VUE_APP_HOST);

    // SignalR const connection = new HubConnectionBuilder() .withUrl(this.baseUrl) .configureLogging(LogLevel.Information) .build(); console.log("connecting..."); // SignalR Service connection .start() .then(() => console.log("connected!")) .catch(console.error); // SignalR connection.on("newMessage", (tweets: Tweet[]) => this.displayTweet(tweets)); // connection.onclose(() => console.log("disconnected")); }