マネージド環境で Dapr サブスクリプションを作成または更新します。
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprSubscriptions/{name}?api-version=2023-11-02-preview
URI パラメーター
名前 |
/ |
必須 |
型 |
説明 |
environmentName
|
path |
True
|
string
|
マネージド環境の名前。
Regex pattern: ^[-\w\._\(\)]+$
|
name
|
path |
True
|
string
|
Dapr サブスクリプションの名前。
|
resourceGroupName
|
path |
True
|
string
|
リソース グループの名前。 名前の大文字と小文字は区別されます。
|
subscriptionId
|
path |
True
|
string
|
ターゲット サブスクリプションの ID。
|
api-version
|
query |
True
|
string
|
この操作に使用する API バージョン。
|
要求本文
名前 |
型 |
説明 |
properties.bulkSubscribe
|
DaprSubscriptionBulkSubscribeOptions
|
一括サブスクリプションのオプション
|
properties.deadLetterTopic
|
string
|
Deadletter トピック名
|
properties.metadata
|
object
|
サブスクリプション メタデータ
|
properties.pubsubName
|
string
|
Dapr PubSub コンポーネント名
|
properties.routes
|
DaprSubscriptionRoutes
|
サブスクリプション ルート
|
properties.scopes
|
string[]
|
サブスクリプションを特定のアプリに制限するアプリケーション スコープ。
|
properties.topic
|
string
|
トピック名
|
応答
セキュリティ
azure_auth
Azure Active Directory OAuth2 フロー
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
名前 |
説明 |
user_impersonation
|
ユーザー アカウントの借用
|
例
Create or update dapr subscription with bulk subscribe configuration and scopes
Sample Request
PUT https://management.azure.com/subscriptions/8efdecc5-919e-44eb-b179-915dca89ebf9/resourceGroups/examplerg/providers/Microsoft.App/managedEnvironments/myenvironment/daprSubscriptions/mysubscription?api-version=2023-11-02-preview
{
"properties": {
"pubsubName": "mypubsubcomponent",
"topic": "inventory",
"routes": {
"default": "/products"
},
"scopes": [
"warehouseapp",
"customersupportapp"
],
"bulkSubscribe": {
"enabled": true,
"maxMessagesCount": 123,
"maxAwaitDurationMs": 500
}
}
}
import com.azure.resourcemanager.appcontainers.models.DaprSubscriptionBulkSubscribeOptions;
import com.azure.resourcemanager.appcontainers.models.DaprSubscriptionRoutes;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for DaprSubscriptions CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2023-11-02-preview/examples/
* DaprSubscriptions_CreateOrUpdate_BulkSubscribeAndScopes.json
*/
/**
* Sample code: Create or update dapr subscription with bulk subscribe configuration and scopes.
*
* @param manager Entry point to ContainerAppsApiManager.
*/
public static void createOrUpdateDaprSubscriptionWithBulkSubscribeConfigurationAndScopes(
com.azure.resourcemanager.appcontainers.ContainerAppsApiManager manager) {
manager.daprSubscriptions().define("mysubscription")
.withExistingManagedEnvironment("examplerg", "myenvironment").withPubsubName("mypubsubcomponent")
.withTopic("inventory").withRoutes(new DaprSubscriptionRoutes().withDefaultProperty("/products"))
.withScopes(Arrays.asList("warehouseapp", "customersupportapp"))
.withBulkSubscribe(new DaprSubscriptionBulkSubscribeOptions().withEnabled(true).withMaxMessagesCount(123)
.withMaxAwaitDurationMs(500))
.create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from typing import Any, IO, Union
from azure.identity import DefaultAzureCredential
from azure.mgmt.appcontainers import ContainerAppsAPIClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-appcontainers
# USAGE
python dapr_subscriptions_create_or_update_bulk_subscribe_and_scopes.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerAppsAPIClient(
credential=DefaultAzureCredential(),
subscription_id="8efdecc5-919e-44eb-b179-915dca89ebf9",
)
response = client.dapr_subscriptions.create_or_update(
resource_group_name="examplerg",
environment_name="myenvironment",
name="mysubscription",
dapr_subscription_envelope={
"properties": {
"bulkSubscribe": {"enabled": True, "maxAwaitDurationMs": 500, "maxMessagesCount": 123},
"pubsubName": "mypubsubcomponent",
"routes": {"default": "/products"},
"scopes": ["warehouseapp", "customersupportapp"],
"topic": "inventory",
}
},
)
print(response)
# x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2023-11-02-preview/examples/DaprSubscriptions_CreateOrUpdate_BulkSubscribeAndScopes.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armappcontainers_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appcontainers/armappcontainers/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d74afb775446d7f0bc1810fdc5a128c56289e854/specification/app/resource-manager/Microsoft.App/preview/2023-11-02-preview/examples/DaprSubscriptions_CreateOrUpdate_BulkSubscribeAndScopes.json
func ExampleDaprSubscriptionsClient_CreateOrUpdate_createOrUpdateDaprSubscriptionWithBulkSubscribeConfigurationAndScopes() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armappcontainers.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewDaprSubscriptionsClient().CreateOrUpdate(ctx, "examplerg", "myenvironment", "mysubscription", armappcontainers.DaprSubscription{
Properties: &armappcontainers.DaprSubscriptionProperties{
BulkSubscribe: &armappcontainers.DaprSubscriptionBulkSubscribeOptions{
Enabled: to.Ptr(true),
MaxAwaitDurationMs: to.Ptr[int32](500),
MaxMessagesCount: to.Ptr[int32](123),
},
PubsubName: to.Ptr("mypubsubcomponent"),
Routes: &armappcontainers.DaprSubscriptionRoutes{
Default: to.Ptr("/products"),
},
Scopes: []*string{
to.Ptr("warehouseapp"),
to.Ptr("customersupportapp")},
Topic: to.Ptr("inventory"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.DaprSubscription = armappcontainers.DaprSubscription{
// Name: to.Ptr("mysubscription"),
// Type: to.Ptr("Microsoft.App/managedEnvironments/daprSubscriptions"),
// ID: to.Ptr("/subscriptions/8efdecc5-919e-44eb-b179-915dca89ebf9/resourceGroups/examplerg/providers/Microsoft.App/managedEnvironments/myenvironment/daprSubscriptions/mysubscription"),
// Properties: &armappcontainers.DaprSubscriptionProperties{
// BulkSubscribe: &armappcontainers.DaprSubscriptionBulkSubscribeOptions{
// Enabled: to.Ptr(true),
// MaxAwaitDurationMs: to.Ptr[int32](500),
// MaxMessagesCount: to.Ptr[int32](123),
// },
// PubsubName: to.Ptr("mypubsubcomponent"),
// Routes: &armappcontainers.DaprSubscriptionRoutes{
// Default: to.Ptr("/products"),
// Rules: []*armappcontainers.DaprSubscriptionRouteRule{
// },
// },
// Scopes: []*string{
// to.Ptr("warehouseapp"),
// to.Ptr("customersupportapp")},
// Topic: to.Ptr("inventory"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerAppsAPIClient } = require("@azure/arm-appcontainers");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates a Dapr subscription in a Managed Environment.
*
* @summary Creates or updates a Dapr subscription in a Managed Environment.
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2023-11-02-preview/examples/DaprSubscriptions_CreateOrUpdate_BulkSubscribeAndScopes.json
*/
async function createOrUpdateDaprSubscriptionWithBulkSubscribeConfigurationAndScopes() {
const subscriptionId =
process.env["APPCONTAINERS_SUBSCRIPTION_ID"] || "8efdecc5-919e-44eb-b179-915dca89ebf9";
const resourceGroupName = process.env["APPCONTAINERS_RESOURCE_GROUP"] || "examplerg";
const environmentName = "myenvironment";
const name = "mysubscription";
const daprSubscriptionEnvelope = {
bulkSubscribe: {
enabled: true,
maxAwaitDurationMs: 500,
maxMessagesCount: 123,
},
pubsubName: "mypubsubcomponent",
routes: { default: "/products" },
scopes: ["warehouseapp", "customersupportapp"],
topic: "inventory",
};
const credential = new DefaultAzureCredential();
const client = new ContainerAppsAPIClient(credential, subscriptionId);
const result = await client.daprSubscriptions.createOrUpdate(
resourceGroupName,
environmentName,
name,
daprSubscriptionEnvelope,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/subscriptions/8efdecc5-919e-44eb-b179-915dca89ebf9/resourceGroups/examplerg/providers/Microsoft.App/managedEnvironments/myenvironment/daprSubscriptions/mysubscription",
"name": "mysubscription",
"type": "Microsoft.App/managedEnvironments/daprSubscriptions",
"properties": {
"pubsubName": "mypubsubcomponent",
"topic": "inventory",
"routes": {
"rules": [],
"default": "/products"
},
"scopes": [
"warehouseapp",
"customersupportapp"
],
"bulkSubscribe": {
"enabled": true,
"maxMessagesCount": 123,
"maxAwaitDurationMs": 500
}
}
}
{
"id": "/subscriptions/8efdecc5-919e-44eb-b179-915dca89ebf9/resourceGroups/examplerg/providers/Microsoft.App/managedEnvironments/myenvironment/daprSubscriptions/mysubscription",
"name": "mysubscription",
"type": "Microsoft.App/managedEnvironments/daprSubscriptions",
"properties": {
"pubsubName": "mypubsubcomponent",
"topic": "inventory",
"routes": {
"rules": [],
"default": "/products"
},
"scopes": [
"warehouseapp",
"customersupportapp"
],
"bulkSubscribe": {
"enabled": true,
"maxMessagesCount": 123,
"maxAwaitDurationMs": 500
}
}
}
Create or update dapr subscription with default route only
Sample Request
PUT https://management.azure.com/subscriptions/8efdecc5-919e-44eb-b179-915dca89ebf9/resourceGroups/examplerg/providers/Microsoft.App/managedEnvironments/myenvironment/daprSubscriptions/mysubscription?api-version=2023-11-02-preview
{
"properties": {
"pubsubName": "mypubsubcomponent",
"topic": "inventory",
"routes": {
"default": "/products"
}
}
}
import com.azure.resourcemanager.appcontainers.models.DaprSubscriptionRoutes;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for DaprSubscriptions CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2023-11-02-preview/examples/
* DaprSubscriptions_CreateOrUpdate_DefaultRoute.json
*/
/**
* Sample code: Create or update dapr subscription with default route only.
*
* @param manager Entry point to ContainerAppsApiManager.
*/
public static void createOrUpdateDaprSubscriptionWithDefaultRouteOnly(
com.azure.resourcemanager.appcontainers.ContainerAppsApiManager manager) {
manager.daprSubscriptions().define("mysubscription")
.withExistingManagedEnvironment("examplerg", "myenvironment").withPubsubName("mypubsubcomponent")
.withTopic("inventory").withRoutes(new DaprSubscriptionRoutes().withDefaultProperty("/products")).create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from typing import Any, IO, Union
from azure.identity import DefaultAzureCredential
from azure.mgmt.appcontainers import ContainerAppsAPIClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-appcontainers
# USAGE
python dapr_subscriptions_create_or_update_default_route.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerAppsAPIClient(
credential=DefaultAzureCredential(),
subscription_id="8efdecc5-919e-44eb-b179-915dca89ebf9",
)
response = client.dapr_subscriptions.create_or_update(
resource_group_name="examplerg",
environment_name="myenvironment",
name="mysubscription",
dapr_subscription_envelope={
"properties": {"pubsubName": "mypubsubcomponent", "routes": {"default": "/products"}, "topic": "inventory"}
},
)
print(response)
# x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2023-11-02-preview/examples/DaprSubscriptions_CreateOrUpdate_DefaultRoute.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armappcontainers_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appcontainers/armappcontainers/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d74afb775446d7f0bc1810fdc5a128c56289e854/specification/app/resource-manager/Microsoft.App/preview/2023-11-02-preview/examples/DaprSubscriptions_CreateOrUpdate_DefaultRoute.json
func ExampleDaprSubscriptionsClient_CreateOrUpdate_createOrUpdateDaprSubscriptionWithDefaultRouteOnly() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armappcontainers.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewDaprSubscriptionsClient().CreateOrUpdate(ctx, "examplerg", "myenvironment", "mysubscription", armappcontainers.DaprSubscription{
Properties: &armappcontainers.DaprSubscriptionProperties{
PubsubName: to.Ptr("mypubsubcomponent"),
Routes: &armappcontainers.DaprSubscriptionRoutes{
Default: to.Ptr("/products"),
},
Topic: to.Ptr("inventory"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.DaprSubscription = armappcontainers.DaprSubscription{
// Name: to.Ptr("mysubscription"),
// Type: to.Ptr("Microsoft.App/managedEnvironments/daprSubscriptions"),
// ID: to.Ptr("/subscriptions/8efdecc5-919e-44eb-b179-915dca89ebf9/resourceGroups/examplerg/providers/Microsoft.App/managedEnvironments/myenvironment/daprSubscriptions/mysubscription"),
// Properties: &armappcontainers.DaprSubscriptionProperties{
// PubsubName: to.Ptr("mypubsubcomponent"),
// Routes: &armappcontainers.DaprSubscriptionRoutes{
// Default: to.Ptr("/products"),
// Rules: []*armappcontainers.DaprSubscriptionRouteRule{
// },
// },
// Topic: to.Ptr("inventory"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerAppsAPIClient } = require("@azure/arm-appcontainers");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates a Dapr subscription in a Managed Environment.
*
* @summary Creates or updates a Dapr subscription in a Managed Environment.
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2023-11-02-preview/examples/DaprSubscriptions_CreateOrUpdate_DefaultRoute.json
*/
async function createOrUpdateDaprSubscriptionWithDefaultRouteOnly() {
const subscriptionId =
process.env["APPCONTAINERS_SUBSCRIPTION_ID"] || "8efdecc5-919e-44eb-b179-915dca89ebf9";
const resourceGroupName = process.env["APPCONTAINERS_RESOURCE_GROUP"] || "examplerg";
const environmentName = "myenvironment";
const name = "mysubscription";
const daprSubscriptionEnvelope = {
pubsubName: "mypubsubcomponent",
routes: { default: "/products" },
topic: "inventory",
};
const credential = new DefaultAzureCredential();
const client = new ContainerAppsAPIClient(credential, subscriptionId);
const result = await client.daprSubscriptions.createOrUpdate(
resourceGroupName,
environmentName,
name,
daprSubscriptionEnvelope,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/subscriptions/8efdecc5-919e-44eb-b179-915dca89ebf9/resourceGroups/examplerg/providers/Microsoft.App/managedEnvironments/myenvironment/daprSubscriptions/mysubscription",
"name": "mysubscription",
"type": "Microsoft.App/managedEnvironments/daprSubscriptions",
"properties": {
"pubsubName": "mypubsubcomponent",
"topic": "inventory",
"routes": {
"rules": [],
"default": "/products"
}
}
}
{
"id": "/subscriptions/8efdecc5-919e-44eb-b179-915dca89ebf9/resourceGroups/examplerg/providers/Microsoft.App/managedEnvironments/myenvironment/daprSubscriptions/mysubscription",
"name": "mysubscription",
"type": "Microsoft.App/managedEnvironments/daprSubscriptions",
"properties": {
"pubsubName": "mypubsubcomponent",
"topic": "inventory",
"routes": {
"rules": [],
"default": "/products"
}
}
}
Sample Request
PUT https://management.azure.com/subscriptions/8efdecc5-919e-44eb-b179-915dca89ebf9/resourceGroups/examplerg/providers/Microsoft.App/managedEnvironments/myenvironment/daprSubscriptions/mysubscription?api-version=2023-11-02-preview
{
"properties": {
"pubsubName": "mypubsubcomponent",
"topic": "inventory",
"metadata": {
"foo": "bar",
"hello": "world"
},
"routes": {
"rules": [
{
"match": "event.type == 'widget'",
"path": "/widgets"
},
{
"match": "event.type == 'gadget'",
"path": "/gadgets"
}
],
"default": "/products"
}
}
}
import com.azure.resourcemanager.appcontainers.models.DaprSubscriptionRouteRule;
import com.azure.resourcemanager.appcontainers.models.DaprSubscriptionRoutes;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for DaprSubscriptions CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2023-11-02-preview/examples/
* DaprSubscriptions_CreateOrUpdate_RouteRulesAndMetadata.json
*/
/**
* Sample code: Create or update dapr subscription with route rules and metadata.
*
* @param manager Entry point to ContainerAppsApiManager.
*/
public static void createOrUpdateDaprSubscriptionWithRouteRulesAndMetadata(
com.azure.resourcemanager.appcontainers.ContainerAppsApiManager manager) {
manager.daprSubscriptions().define("mysubscription")
.withExistingManagedEnvironment("examplerg", "myenvironment").withPubsubName("mypubsubcomponent")
.withTopic("inventory")
.withRoutes(new DaprSubscriptionRoutes()
.withRules(Arrays.asList(
new DaprSubscriptionRouteRule().withMatch("event.type == 'widget'").withPath("/widgets"),
new DaprSubscriptionRouteRule().withMatch("event.type == 'gadget'").withPath("/gadgets")))
.withDefaultProperty("/products"))
.withMetadata(mapOf("foo", "bar", "hello", "world")).create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from typing import Any, IO, Union
from azure.identity import DefaultAzureCredential
from azure.mgmt.appcontainers import ContainerAppsAPIClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-appcontainers
# USAGE
python dapr_subscriptions_create_or_update_route_rules_and_metadata.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerAppsAPIClient(
credential=DefaultAzureCredential(),
subscription_id="8efdecc5-919e-44eb-b179-915dca89ebf9",
)
response = client.dapr_subscriptions.create_or_update(
resource_group_name="examplerg",
environment_name="myenvironment",
name="mysubscription",
dapr_subscription_envelope={
"properties": {
"metadata": {"foo": "bar", "hello": "world"},
"pubsubName": "mypubsubcomponent",
"routes": {
"default": "/products",
"rules": [
{"match": "event.type == 'widget'", "path": "/widgets"},
{"match": "event.type == 'gadget'", "path": "/gadgets"},
],
},
"topic": "inventory",
}
},
)
print(response)
# x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2023-11-02-preview/examples/DaprSubscriptions_CreateOrUpdate_RouteRulesAndMetadata.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armappcontainers_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appcontainers/armappcontainers/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d74afb775446d7f0bc1810fdc5a128c56289e854/specification/app/resource-manager/Microsoft.App/preview/2023-11-02-preview/examples/DaprSubscriptions_CreateOrUpdate_RouteRulesAndMetadata.json
func ExampleDaprSubscriptionsClient_CreateOrUpdate_createOrUpdateDaprSubscriptionWithRouteRulesAndMetadata() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armappcontainers.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewDaprSubscriptionsClient().CreateOrUpdate(ctx, "examplerg", "myenvironment", "mysubscription", armappcontainers.DaprSubscription{
Properties: &armappcontainers.DaprSubscriptionProperties{
Metadata: map[string]*string{
"foo": to.Ptr("bar"),
"hello": to.Ptr("world"),
},
PubsubName: to.Ptr("mypubsubcomponent"),
Routes: &armappcontainers.DaprSubscriptionRoutes{
Default: to.Ptr("/products"),
Rules: []*armappcontainers.DaprSubscriptionRouteRule{
{
Path: to.Ptr("/widgets"),
Match: to.Ptr("event.type == 'widget'"),
},
{
Path: to.Ptr("/gadgets"),
Match: to.Ptr("event.type == 'gadget'"),
}},
},
Topic: to.Ptr("inventory"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.DaprSubscription = armappcontainers.DaprSubscription{
// Name: to.Ptr("mysubscription"),
// Type: to.Ptr("Microsoft.App/managedEnvironments/daprSubscriptions"),
// ID: to.Ptr("/subscriptions/8efdecc5-919e-44eb-b179-915dca89ebf9/resourceGroups/examplerg/providers/Microsoft.App/managedEnvironments/myenvironment/daprSubscriptions/mysubscription"),
// Properties: &armappcontainers.DaprSubscriptionProperties{
// Metadata: map[string]*string{
// "foo": to.Ptr("bar"),
// "hello": to.Ptr("world"),
// },
// PubsubName: to.Ptr("mypubsubcomponent"),
// Routes: &armappcontainers.DaprSubscriptionRoutes{
// Default: to.Ptr("/products"),
// Rules: []*armappcontainers.DaprSubscriptionRouteRule{
// {
// Path: to.Ptr("/widgets"),
// Match: to.Ptr("event.type == 'widget'"),
// },
// {
// Path: to.Ptr("/gadgets"),
// Match: to.Ptr("event.type == 'gadget'"),
// }},
// },
// Topic: to.Ptr("inventory"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ContainerAppsAPIClient } = require("@azure/arm-appcontainers");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates a Dapr subscription in a Managed Environment.
*
* @summary Creates or updates a Dapr subscription in a Managed Environment.
* x-ms-original-file: specification/app/resource-manager/Microsoft.App/preview/2023-11-02-preview/examples/DaprSubscriptions_CreateOrUpdate_RouteRulesAndMetadata.json
*/
async function createOrUpdateDaprSubscriptionWithRouteRulesAndMetadata() {
const subscriptionId =
process.env["APPCONTAINERS_SUBSCRIPTION_ID"] || "8efdecc5-919e-44eb-b179-915dca89ebf9";
const resourceGroupName = process.env["APPCONTAINERS_RESOURCE_GROUP"] || "examplerg";
const environmentName = "myenvironment";
const name = "mysubscription";
const daprSubscriptionEnvelope = {
metadata: { foo: "bar", hello: "world" },
pubsubName: "mypubsubcomponent",
routes: {
default: "/products",
rules: [
{ path: "/widgets", match: "event.type == 'widget'" },
{ path: "/gadgets", match: "event.type == 'gadget'" },
],
},
topic: "inventory",
};
const credential = new DefaultAzureCredential();
const client = new ContainerAppsAPIClient(credential, subscriptionId);
const result = await client.daprSubscriptions.createOrUpdate(
resourceGroupName,
environmentName,
name,
daprSubscriptionEnvelope,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/subscriptions/8efdecc5-919e-44eb-b179-915dca89ebf9/resourceGroups/examplerg/providers/Microsoft.App/managedEnvironments/myenvironment/daprSubscriptions/mysubscription",
"name": "mysubscription",
"type": "Microsoft.App/managedEnvironments/daprSubscriptions",
"properties": {
"pubsubName": "mypubsubcomponent",
"topic": "inventory",
"routes": {
"rules": [
{
"match": "event.type == 'widget'",
"path": "/widgets"
},
{
"match": "event.type == 'gadget'",
"path": "/gadgets"
}
],
"default": "/products"
},
"metadata": {
"foo": "bar",
"hello": "world"
}
}
}
{
"id": "/subscriptions/8efdecc5-919e-44eb-b179-915dca89ebf9/resourceGroups/examplerg/providers/Microsoft.App/managedEnvironments/myenvironment/daprSubscriptions/mysubscription",
"name": "mysubscription",
"type": "Microsoft.App/managedEnvironments/daprSubscriptions",
"properties": {
"pubsubName": "mypubsubcomponent",
"topic": "inventory",
"routes": {
"rules": [
{
"match": "event.type == 'widget'",
"path": "/widgets"
},
{
"match": "event.type == 'gadget'",
"path": "/gadgets"
}
],
"default": "/products"
},
"metadata": {
"foo": "bar",
"hello": "world"
}
}
}
定義
createdByType
リソースを作成した ID の種類。
名前 |
型 |
説明 |
Application
|
string
|
|
Key
|
string
|
|
ManagedIdentity
|
string
|
|
User
|
string
|
|
DaprSubscription
Dapr PubSub イベント サブスクリプション。
名前 |
型 |
説明 |
id
|
string
|
リソースの完全修飾リソース ID。 例 - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
name
|
string
|
リソースの名前
|
properties.bulkSubscribe
|
DaprSubscriptionBulkSubscribeOptions
|
一括サブスクリプションのオプション
|
properties.deadLetterTopic
|
string
|
Deadletter トピック名
|
properties.metadata
|
object
|
サブスクリプション メタデータ
|
properties.pubsubName
|
string
|
Dapr PubSub コンポーネント名
|
properties.routes
|
DaprSubscriptionRoutes
|
サブスクリプション ルート
|
properties.scopes
|
string[]
|
サブスクリプションを特定のアプリに制限するアプリケーション スコープ。
|
properties.topic
|
string
|
トピック名
|
systemData
|
systemData
|
createdBy および modifiedBy 情報を含む Azure Resource Manager メタデータ。
|
type
|
string
|
リソースの型。 例: "Microsoft.Compute/virtualMachines" または "Microsoft.Storage/storageAccounts"
|
DaprSubscriptionBulkSubscribeOptions
Dapr PubSub 一括サブスクリプション オプション。
名前 |
型 |
既定値 |
説明 |
enabled
|
boolean
|
False
|
一括サブスクリプションを有効にする
|
maxAwaitDurationMs
|
integer
|
|
アプリに一括メッセージが送信されるまでの最大待機時間 (ミリ秒)。
|
maxMessagesCount
|
integer
|
|
一括メッセージで配信するメッセージの最大数。
|
DaprSubscriptionRouteRule
Dapr Pubsub イベント サブスクリプション ルート 規則は、メッセージを特定のパスに送信する条件を指定するために使用されます。
名前 |
型 |
説明 |
match
|
string
|
イベントの照合に使用される省略可能な CEL 式。 一致が指定されていない場合、ルートは既定と見なされます。 ルールは指定された順序でテストされるため、最も具体的なものから最も少ないものまで定義する必要があります。 既定のルートは、一覧の最後に表示されます。
|
path
|
string
|
このルールに一致するイベントのパス
|
DaprSubscriptionRoutes
Dapr PubSub イベント サブスクリプションルートの構成。
名前 |
型 |
説明 |
default
|
string
|
どのルールにも一致しないイベントを配信するための既定のパス。
|
rules
|
DaprSubscriptionRouteRule[]
|
Dapr PubSub イベント サブスクリプション ルート ルールの一覧。
|
DefaultErrorResponse
エラー応答をApp Serviceします。
名前 |
型 |
説明 |
error
|
Error
|
エラー モデル。
|
Details
詳細またはエラー
名前 |
型 |
説明 |
code
|
string
|
プログラムによってエラーを識別するための標準化された文字列。
|
message
|
string
|
エラーの詳細な説明とデバッグ情報。
|
target
|
string
|
エラーの詳細な説明とデバッグ情報。
|
Error
エラー モデル。
名前 |
型 |
説明 |
code
|
string
|
プログラムによってエラーを識別するための標準化された文字列。
|
details
|
Details[]
|
詳細またはエラー
|
innererror
|
string
|
デバッグ エラーの詳細。
|
message
|
string
|
エラーの詳細な説明とデバッグ情報。
|
target
|
string
|
エラーの詳細な説明とデバッグ情報。
|
systemData
リソースの作成と最後の変更に関連するメタデータ。
名前 |
型 |
説明 |
createdAt
|
string
|
リソース作成のタイムスタンプ (UTC)。
|
createdBy
|
string
|
リソースを作成した ID。
|
createdByType
|
createdByType
|
リソースを作成した ID の種類。
|
lastModifiedAt
|
string
|
リソースの最終変更のタイムスタンプ (UTC)
|
lastModifiedBy
|
string
|
リソースを最後に変更した ID。
|
lastModifiedByType
|
createdByType
|
リソースを最後に変更した ID の種類。
|