
Oracle Cloud Infrastructure NotificationsサービスからOracle Functionsをトリガーできるようになりました。
Oracle Functionsはfunctions as a service(FaaS)プラットフォームで、これを使うことで開発者はインフラについて心配することなくビジネス上の要求に見合ったコードを書くことができます。Oracle Functionsが下回りのインフラをマネージし、エラスティックにスケールして受け取ったリクエストをさばきます。Oracle Functionsを使う際にかかる料金は、そのファンクションが実行している間だけのリソースに対してです。
Notificationsはクラウドネイティブなメッセージングサービスで、Eメール、PagerDutyおよびHTTPSエンドポイントに対してのプッシュベースのメッセージングをサポートしてきました。NotificationsはEventsやMonitoringのような他のOracle Cloud Infrastructure 上のサービスとの最上級のインテグレーションを提供します。こうしたインテグレーションを使い、ある通知トピックからイベント通知やアラーム通知をEメールやPagerDutyといった複数のエンドポイントに発出できます。Oracle Functionsはfunctions as a service(FaaS)プラットフォームで、これを使うことで開発者はインフラについて心配することなくビジネス上の要求に見合ったコードを書くことができます。Oracle Functionsが下回りのインフラをマネージし、エラスティックにスケールして受け取ったリクエストをさばきます。Oracle Functionsを使う際にかかる料金は、そのファンクションが実行している間だけのリソースに対してです。
一般的なユースケース
今日のクラウドが普及した世界では、あなたは自身のサービスが常に利用可能であることを期待するでしょう。クラウドインフラ上で起きた問題を迅速に解決することは、この目標を実現するうえで鍵であり、また、成熟したDevOpsのカルチャーの一部です。あなたがオンコールエンジニアで、あなたのサービスに対して必要なごくシンプルなタスク、例えばコンピュートインスタンスのシェイプにメモリを追加してやるといったようなタスクのために早朝3時に起こされるような場面を想像してみてください。我々はこのようなシナリオを自動化することで、カスタマーエクスペリエンスを向上し、また、お客様がもっと多くの時間を生産的な仕事に使うことができるようになると信じています。Notificationsによってコンピュートインスタンスをリサイズするように書いておいたコードのファンクションをトリガーすることで、このシナリオを自動化することができるんです。
以下はこのインテグレーションによって実現できる、その他のサンプルユースケースです:
- Monitoringサービスのストレージ使用率メトリックからあがったアラームをきっかけに、Oracle Autonomous Databaseのストレージをスケールアップする
- Automatic Volume Healingを使い、あるブロックボリューム上の利用率がしきい値を越えたことをきっかけに追加ボリュームを作成し、アタッチすることでボリュームを拡張する。また、その新しいディスク容量の詳細について通知を発出する。
- サービスやファンクションにカスタムメッセージを発出しつつ、別のファンクションをトリガーする
始めてみよう
Oracle Cloud Infrastructure Notificationsを使っているなら、この新機能はコンソール、SDK、CLIおよびAPIを通じてサブスクリプションを作成するときに利用可能です。以下はいくつかのやり方のサンプルです。
コンソール:トピックへのサブスクリプションの作成
トピックにサブスクリプションを作成する際に、プロトコルタイプとしてFunctionを選んでください。


トリガーしたいファンクションとそのコンパートメントを選択します。

サブスクリプションが作成されると、コンソールに表示されます。

コンソール:アラームの作成
コンソールのMonitoringのページから、Alarm Definitionsをクリックし、Create Alarmをクリック。

アラームの必要情報を入力します。

Notificationsの欄では既存のトピックを選択するか、ここから新しくトピックを作成することもできます。


CLI
ファンクションのサブスクリプションの作成:
oci ons subscription create \
--compartment-id "<compartment-ocid>" \
--topic-id "<topic-ocid>" \
--protocol "ORACLE_FUNCTIONS" \
--subscription-endpoint "<function_ocid>"
Java SDK
ファンクションのサブスクリプションの作成:
subscription = client.createSubscription(CreateSubscriptionRequest.builder()
.createSubscriptionDetails(CreateSubscriptionDetails.builder()
.compartmentId(compartmentId)
.topicId(topicId)
.protocol("ORACLE_FUNCTIONS")
.endpoint(functionId)
.build())
.build()).getSubscription();
Terraform
Provider Configurationで以下のようにプロトコルを設定します。
variable "subscription_protocol" {
...
default = "ORACLE_FUNCTIONS"
...
...
}
Oracle_Functionsのタイプでサブスクリプションが作成できます。
resource "oci_ons_subscription" "test_subscription" {
#Required
compartment_id = "${var.compartment_OCID}"
endpoint = "${var.function_OCID}"
protocol = "${var.subscription_protocol}"
topic_id = "${oci_ons_notification_topic.test_notification_topic.id}"
#Optional
defined_tags = "${map("${oci_identity_tag_namespace.tag_namespace1.name}.${oci_identity_tag.tag1.name}", "${var.subscription_defined_tags_value}")}"
freeform_tags = "${var.subscription_freeform_tags}"
}
data "oci_ons_subscriptions" "test_subscriptions" {
#Required
compartment_id = "${var.compartment_ocid}"
#Optional
topic_id = "${oci_ons_subscription.test_subscription.topic_id}"
}
REST API
ファンクションのサブスクリプションの作成:
POST /20181201/subscriptions
Host: notification.<oracle-cloud-infrastructure-region>.oraclecloud.com
<authorization and other headers>
{
"topicId": "<topic_OCID>",
"compartmentId": "<compartment_OCID>",
"protocol": "ORACLE_FUNCTIONS",
"endpoint": "<function_OCID>"
}
課金について
Notificationsサービスからファンクションをトリガーするのに追加の料金は必要ありません。Oracle Functionsの課金についてはこちらの製品ページを確認ください。
より詳しい情報
この新機能のより詳しい情報や、Notificationsサービスについて詳しいことを知りたければ以下のリンクをたどってみてください。
- Notifications-Functions integration documentation
- Notifications-Functions developer walkthrough blog post
- Example: Automated VM resize scenario
- Example: E-Commerce application order processing system using Notifications and Functions
- Notifications documentation
- Notifications REST API reference
- Notifications CLI reference
- Notifications product page
- Notifications pricing
0 件のコメント:
コメントを投稿