logic apps と api apps の話

36
GABC Logic Apps API Apps の話 Japan Azure User Group Microsoft MVP for Microsoft Azure 冨田 (とみたすなお) http://twitter.com/harutama

Upload: sunao-tomita

Post on 18-Jul-2015

986 views

Category:

Technology


7 download

TRANSCRIPT

GABCLogic Appsと API Appsの話

Japan Azure User Group

Microsoft MVP for Microsoft Azure

冨田 順 (とみたすなお)

http://twitter.com/harutama

Azure App Service

2https://weblogs.asp.net/scottgu/announcing-the-new-azure-app-service

使うもの

• Microsoft Azure–アカウント持ってるよねっ!!!

– 1ヶ月無料評価版もどうぞhttp://azure.microsoft.com/ja-jp/pricing/free-trial/

• Visual Studio– Community でも問題なく使えます。

• Microsoft Azure SDK 2.5.1–現状での最新版を入れてください。

(最新じゃないと API Apps や Logic Apps に対応していません)

3

一発でインストールできます

4

Microsoft Web Platform Installer 5.0

http://www.microsoft.com/web/downloads/platform.aspx

API Apps(API アプリ)

5

これは何ですか?

• アプリケーションを 50 以上の人気の SaaS

API に公開し、組織で API を共有

– SaaS およびエンタープライズアプリケーションとの統合。

–選択した言語でのクライアントプロキシまたは API の生成。

– API アプリのバージョン管理と展開の自動化。

– Active Directory、シングルサインオン、および OAuth による API の保護。

–組織のギャラリーによる API の社内共有。

6

理解できない…

7

8

作ってみるしかない

ASP.NETプロジェクトから

9

API Appが増えてる!

10

11

詳しい話はここにありますので…

http://miso-soup3.hateblo.jp/entry/2015/03/25/121143

Logic Apps(ロジックアプリ)

12

これは何ですか?

• ロジックアプリを使用すると、強力な統合ソリューションを簡単な操作により開発および配信できます。

–ビジュアル操作によりビジネスプロセスおよびワークフローを作成する。

– Web、モバイル、および API のアプリで統合機能を配信する。

– SaaS およびエンタープライズアプリケーションと統合する。

– EAI/B2B およびビジネスプロセスを自動化する

–オンプレミスのデータに接続する。13

理解できない…

14

Logic Appsのコンセプト

• ワークフロー

–一連のワークフローが組み合わされたビジネスプロセスをグラフィカルに表現。

• コネクター

–コネクターは特殊な API アプリケーション。データを繋げたいときに使うもの。

• トリガー

–ワークフローの中のイベント。メールが届いたとか

15

http://azure.microsoft.com/en-us/documentation/articles/app-service-logic-

what-are-logic-apps/

例えばこんなこと

16

データベースに何か Insertされたら

Twitterで中身を Tweetして

Twilioから電話に SMS送る

いろんなサービスを連携

17

API Appsと Logic Appsの関係

18

人情として思う

19

ここに出てくる箱自体を

自分で作りたい

20

実態は箱= API Apps で動いている Web API

つまり

21

これ自体は Logic Apps

= Web Apps の組み合わせ

Web Apps で動いている API

22

Q.API Apps の上に自分で作った

Web API 乗せるとLogic Apps で使えますか?

23

A.

使えるよ!(ただし条件が1つあるけど)

不思議なことですが…

24

どうしてこのWeb API が

POST をサポートする事が分かっている?

どうして POST

が要求するパラメータが分かっている?

25

Web Apps で動いているWeb API のメタデータを

Logic Apps に教えるためのメタデータが必要

Swagger

26

Swagger is a simple yet powerful representation of your RESTful API.

http://swagger.io/

apiapp.jsonがメタデータ

27

{"$schema": "http://json-schema.org/schemas/2014-11-01/apiapp.json#","id": "WebApplication1","namespace": "microsoft.com","gateway": "2015-01-14","version": "1.0.0","title": "WebApplication1","summary": "","author": "","endpoints": {

"apiDefinition": "/swagger/docs/v1","status": null

}}

ところが…

28

APIアプリは、.NET、Node.js、PHP、Python、Javaなど、Webアプリがサポートできる任意のテクノロジをサポートできます。APIアプリを構築、デプロイした際に、舞台裏では、我々があなたのためにWebアプリを作成し、それがAPIアプリであることを示す特殊ないくつかのメタデータを配置しています。また、APIアプリは、apiapp.jsonという特殊なファイルを、ルートに持つ必要があります。このファイルには、作者、概要、IDといった、APIアプリ関連のメタデータが含まれています。これらのメタデータは、現在のプレビューでは使われていませんが、今後活用される予定です。

https://satonaoki.wordpress.com/2015/04/02/azure-api-apps-detail-faq/

29

apiapp.json に手作りの温もりなしで勝手に作ってくれませんか?

いまのところ

30

AppStart/SwaggerConfig.cs の中身

// In contrast to WebApi, Swagger 2.0 does not include the query string component when mapping a URL// to an action. As a result, Swashbuckle will raise an exception if it encounters multiple actions// with the same path (sans query string) and HTTP method. You can workaround this by providing a// custom strategy to pick a winner or merge the descriptions for the purposes of the Swagger docs ////c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());// ***** Uncomment the following to enable the swagger UI *****

}).EnableSwaggerUi(c =>

{

// Use the "InjectStylesheet" option to enrich the UI with one or more additional CSS stylesheets.// The file must be included in your project as an "Embedded Resource", and then the resource's// "Logical Name" is passed to the method as shown below.////c.InjectStylesheet(containingAssembly, "Swashbuckle.Dummy.SwaggerExtensions.testStyles1.css");

SwaggerConfig.cs の中にある UI を有効にする部分のコメントを外す。(大きいファイルなので “EnableSwaggerUi” で検索した方がいいです)

Web UI が有効になります

31

デバッグで動作させて http://localhost/swagger/にアクセスすると自動的に作られたメタデータをいい感じに見ることができます。これを動かしておくと、Logic App から API が見えます。

apiapp.jsonをダウンロード

32

ここから自動生成されたapiapp.json を

ダウンロードできます

参考

33

API Apps

• Azure App Service API Appsの詳細とFAQ

https://satonaoki.wordpress.com/2015/04/02/azure-api-

apps-detail-faq/

• Azure App Serviceでの.NETではないAPIアプリの実行

https://satonaoki.wordpress.com/2015/04/03/non-dotnet-

api-app-app-service/

34

Logic Apps

• Azure Logic App with simple API App with inputs and

outputs

http://blogs.msdn.com/b/hosamshobak/archive/2015/03/3

1/logic-app-with-simple-api-app-with-inputs-and-

outputs.aspx

• Azure API Apps を Node.js で作って Logic Apps で使う

https://r2.ag/azure-api-apps-with-node-js/

• Logic Apps で JavaScript を実行したい!

https://r2.ag/azure-javascript-processor-api-app/

35

Let’s dream and then let’s build.

- Ray Ozzie

冨田 順 (@harutama)

http://twitter.com/harutama