File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 17
17
18
18
19
19
builder . AddProject < Projects . CommunityToolkit_Aspire_Hosting_Dapr_ServiceA > ( "servicea" )
20
+ . PublishAsAzureContainerApp ( ( i , c ) => { } )
20
21
. WithDaprSidecar ( sidecar => sidecar . WithReference ( stateStore ) . WithReference ( pubSub ) )
21
22
. WaitFor ( redis ) ;
22
23
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ public static void AddScopes(this IResourceBuilder<IDaprComponentResource> build
50
50
foreach ( var resource in builder . ApplicationBuilder . Resources )
51
51
{
52
52
if ( ! resource . TryGetLastAnnotation < DaprSidecarAnnotation > ( out var daprAnnotation ) ||
53
- ! resource . TryGetAnnotationsOfType < DaprComponentReferenceAnnotation > ( out var daprComponentReferenceAnnotations ) )
53
+ ! daprAnnotation . Sidecar . TryGetAnnotationsOfType < DaprComponentReferenceAnnotation > ( out var daprComponentReferenceAnnotations ) )
54
54
{
55
55
continue ;
56
56
}
Original file line number Diff line number Diff line change @@ -62,8 +62,40 @@ public static IResourceBuilder<T> WithDaprSidecar<T>(this IResourceBuilder<T> bu
62
62
IsHidden = true ,
63
63
} ) ;
64
64
65
+
66
+ var serviceId = builder . Resource . Name ;
67
+
65
68
configureSidecar ( sidecarBuilder ) ;
66
69
70
+ if ( sidecarBuilder . Resource . TryGetAnnotationsOfType < DaprSidecarOptionsAnnotation > ( out var optionsAnnotations ) &&
71
+ optionsAnnotations . LastOrDefault ( ) is { } optionsAnnotation )
72
+ {
73
+ // If no AppId was specified, use the resource name.
74
+ if ( string . IsNullOrEmpty ( optionsAnnotation . Options . AppId ) )
75
+ {
76
+ sidecarBuilder . WithOptions ( new DaprSidecarOptions
77
+ {
78
+ AppId = serviceId ,
79
+ Config = optionsAnnotation . Options . Config ,
80
+ EnableApiLogging = optionsAnnotation . Options . EnableApiLogging ,
81
+ LogLevel = optionsAnnotation . Options . LogLevel ,
82
+ EnableProfiling = optionsAnnotation . Options . EnableProfiling ,
83
+ MetricsPort = optionsAnnotation . Options . MetricsPort ,
84
+ DaprHttpPort = optionsAnnotation . Options . DaprHttpPort ,
85
+ DaprGrpcPort = optionsAnnotation . Options . DaprGrpcPort ,
86
+ } ) ;
87
+ }
88
+ }
89
+ else
90
+ {
91
+ // No options were specified, so set a default AppId.
92
+ sidecarBuilder . WithOptions ( new DaprSidecarOptions
93
+ {
94
+ AppId = serviceId ,
95
+ } ) ;
96
+ }
97
+
98
+
67
99
return builder . WithAnnotation ( new DaprSidecarAnnotation ( sidecarBuilder . Resource ) ) ;
68
100
}
69
101
You can’t perform that action at this time.
0 commit comments