Crée ou met à jour un abonnement Dapr dans un environnement managé.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprSubscriptions/{name}?api-version=2023-11-02-preview
Paramètres URI
Nom |
Dans |
Obligatoire |
Type |
Description |
environmentName
|
path |
True
|
string
|
Nom de l’environnement managé.
Regex pattern: ^[-\w\._\(\)]+$
|
name
|
path |
True
|
string
|
Nom de l’abonnement Dapr.
|
resourceGroupName
|
path |
True
|
string
|
Nom du groupe de ressources. Le nom ne respecte pas la casse.
|
subscriptionId
|
path |
True
|
string
|
ID de l’abonnement cible.
|
api-version
|
query |
True
|
string
|
Version de l’API à utiliser pour cette opération.
|
Corps de la demande
Nom |
Type |
Description |
properties.bulkSubscribe
|
DaprSubscriptionBulkSubscribeOptions
|
Options d’abonnement en bloc
|
properties.deadLetterTopic
|
string
|
Nom de la rubrique Deadletter
|
properties.metadata
|
object
|
Métadonnées d’abonnement
|
properties.pubsubName
|
string
|
Nom du composant Dapr PubSub
|
properties.routes
|
DaprSubscriptionRoutes
|
Itinéraires d’abonnement
|
properties.scopes
|
string[]
|
Étendues d’application pour restreindre l’abonnement à des applications spécifiques.
|
properties.topic
|
string
|
Nom de la rubrique
|
Réponses
Sécurité
azure_auth
Flux OAuth2 Azure Active Directory
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Nom |
Description |
user_impersonation
|
Emprunter l’identité de votre compte d’utilisateur
|
Exemples
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"
}
}
}
Définitions
createdByType
Type d’identité qui a créé la ressource.
Nom |
Type |
Description |
Application
|
string
|
|
Key
|
string
|
|
ManagedIdentity
|
string
|
|
User
|
string
|
|
DaprSubscription
Abonnement aux événements Dapr PubSub.
Nom |
Type |
Description |
id
|
string
|
ID de ressource complet pour la ressource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
name
|
string
|
nom de la ressource.
|
properties.bulkSubscribe
|
DaprSubscriptionBulkSubscribeOptions
|
Options d’abonnement en bloc
|
properties.deadLetterTopic
|
string
|
Nom de la rubrique Deadletter
|
properties.metadata
|
object
|
Métadonnées d’abonnement
|
properties.pubsubName
|
string
|
Nom du composant Dapr PubSub
|
properties.routes
|
DaprSubscriptionRoutes
|
Itinéraires d’abonnement
|
properties.scopes
|
string[]
|
Étendues d’application pour restreindre l’abonnement à des applications spécifiques.
|
properties.topic
|
string
|
Nom de la rubrique
|
systemData
|
systemData
|
Métadonnées Azure Resource Manager contenant les informations createdBy et modifiedBy.
|
type
|
string
|
Type de la ressource. Par exemple, « Microsoft.Compute/virtualMachines » ou « Microsoft.Storage/storageAccounts »
|
DaprSubscriptionBulkSubscribeOptions
Options d’abonnement en bloc Depr PubSub.
Nom |
Type |
Valeur par défaut |
Description |
enabled
|
boolean
|
False
|
Activer l’abonnement en bloc
|
maxAwaitDurationMs
|
integer
|
|
Durée maximale en millisecondes d’attente avant qu’un message en bloc soit envoyé à l’application.
|
maxMessagesCount
|
integer
|
|
Nombre maximal de messages à remettre dans un message en bloc.
|
DaprSubscriptionRouteRule
Dapr Pubsub Event Subscription Route Rule est utilisée pour spécifier la condition d’envoi d’un message à un chemin spécifique.
Nom |
Type |
Description |
match
|
string
|
Expression CEL facultative utilisée pour correspondre à l’événement. Si la correspondance n’est pas spécifiée, la route est considérée comme la valeur par défaut. Les règles étant testées dans l’ordre spécifié, elles doivent être définies du plus au moins spécifique. L’itinéraire par défaut doit apparaître en dernier dans la liste.
|
path
|
string
|
Chemin d’accès pour les événements qui correspondent à cette règle
|
DaprSubscriptionRoutes
Configuration des itinéraires d’abonnement aux événements Dapr PubSub.
Nom |
Type |
Description |
default
|
string
|
Chemin d’accès par défaut pour remettre les événements qui ne correspondent à aucune des règles.
|
rules
|
DaprSubscriptionRouteRule[]
|
Liste des règles d’itinéraire de l’abonnement aux événements Dapr PubSub.
|
DefaultErrorResponse
App Service réponse d’erreur.
Nom |
Type |
Description |
error
|
Error
|
Modèle d’erreur.
|
Details
Détails ou erreur
Nom |
Type |
Description |
code
|
string
|
Chaîne standardisée pour identifier l’erreur par programmation.
|
message
|
string
|
Description détaillée de l’erreur et informations de débogage.
|
target
|
string
|
Description détaillée de l’erreur et informations de débogage.
|
Error
Modèle d’erreur.
Nom |
Type |
Description |
code
|
string
|
Chaîne standardisée pour identifier l’erreur par programmation.
|
details
|
Details[]
|
Détails ou erreur
|
innererror
|
string
|
Plus d’informations sur l’erreur de débogage.
|
message
|
string
|
Description détaillée de l’erreur et informations de débogage.
|
target
|
string
|
Description détaillée de l’erreur et informations de débogage.
|
systemData
Métadonnées relatives à la création et à la dernière modification de la ressource.
Nom |
Type |
Description |
createdAt
|
string
|
Horodatage de la création de ressources (UTC).
|
createdBy
|
string
|
Identité qui a créé la ressource.
|
createdByType
|
createdByType
|
Type d’identité qui a créé la ressource.
|
lastModifiedAt
|
string
|
Horodatage de la dernière modification de la ressource (UTC)
|
lastModifiedBy
|
string
|
Identité qui a modifié la dernière ressource.
|
lastModifiedByType
|
createdByType
|
Type d’identité qui a modifié la dernière ressource.
|