9
9
10
10
namespace OrchardCore . DataProtection . Azure ;
11
11
12
- internal sealed class BlobOptionsConfiguration : IConfigureOptions < BlobOptions >
12
+ public sealed class BlobOptionsSetup : IAsyncConfigureOptions < BlobOptions >
13
13
{
14
14
private readonly FluidParser _fluidParser = new ( ) ;
15
15
@@ -18,28 +18,28 @@ internal sealed class BlobOptionsConfiguration : IConfigureOptions<BlobOptions>
18
18
private readonly ShellSettings _shellSettings ;
19
19
private readonly ILogger _logger ;
20
20
21
- public BlobOptionsConfiguration (
21
+ public BlobOptionsSetup (
22
22
IShellConfiguration configuration ,
23
23
IOptions < ShellOptions > shellOptions ,
24
24
ShellSettings shellSettings ,
25
- ILogger < BlobOptionsConfiguration > logger )
25
+ ILogger < BlobOptionsSetup > logger )
26
26
{
27
27
_configuration = configuration ;
28
28
_shellOptions = shellOptions . Value ;
29
29
_shellSettings = shellSettings ;
30
30
_logger = logger ;
31
31
}
32
32
33
- public void Configure ( BlobOptions options )
33
+ public async ValueTask ConfigureAsync ( BlobOptions options )
34
34
{
35
35
_logger . LogDebug ( "Configuring BlobOptions in BlobOptionsSetup" ) ;
36
36
37
37
_configuration . Bind ( "OrchardCore_DataProtection_Azure" , options ) ;
38
- ConfigureContainerName ( options ) ;
39
- ConfigureBlobName ( options ) ;
38
+ await ConfigureContainerNameAsync ( options ) ;
39
+ await ConfigureBlobNameAsync ( options ) ;
40
40
}
41
41
42
- private void ConfigureContainerName ( BlobOptions options )
42
+ private async ValueTask ConfigureContainerNameAsync ( BlobOptions options )
43
43
{
44
44
_logger . LogDebug ( "Configuring BlobOptions.ContainerName in BlobOptionsSetup" ) ;
45
45
@@ -54,7 +54,7 @@ private void ConfigureContainerName(BlobOptions options)
54
54
var template = _fluidParser . Parse ( options . ContainerName ) ;
55
55
56
56
// Container name must be lowercase.
57
- var containerName = template . Render ( templateContext , NullEncoder . Default ) . ToLowerInvariant ( ) ;
57
+ var containerName = ( await template . RenderAsync ( templateContext , NullEncoder . Default ) ) . ToLowerInvariant ( ) ;
58
58
options . ContainerName = containerName . Replace ( "\r " , string . Empty ) . Replace ( "\n " , string . Empty ) ;
59
59
60
60
if ( _logger . IsEnabled ( LogLevel . Debug ) )
@@ -74,7 +74,7 @@ private void ConfigureContainerName(BlobOptions options)
74
74
{
75
75
_logger . LogDebug ( "Testing data protection container {ContainerName} existence" , options . ContainerName ) ;
76
76
var blobContainer = new BlobContainerClient ( options . ConnectionString , options . ContainerName ) ;
77
- var response = blobContainer . CreateIfNotExistsAsync ( PublicAccessType . None ) . GetAwaiter ( ) . GetResult ( ) ;
77
+ var response = await blobContainer . CreateIfNotExistsAsync ( PublicAccessType . None ) ;
78
78
_logger . LogDebug ( "Data protection container {ContainerName} created." , options . ContainerName ) ;
79
79
}
80
80
catch ( Exception e )
@@ -85,7 +85,7 @@ private void ConfigureContainerName(BlobOptions options)
85
85
}
86
86
}
87
87
88
- private void ConfigureBlobName ( BlobOptions options )
88
+ private async ValueTask ConfigureBlobNameAsync ( BlobOptions options )
89
89
{
90
90
_logger . LogDebug ( "Configuring BlobOptions.BlobName in BlobOptionsSetup" ) ;
91
91
@@ -111,7 +111,7 @@ private void ConfigureBlobName(BlobOptions options)
111
111
112
112
var template = _fluidParser . Parse ( options . BlobName ) ;
113
113
114
- var blobName = template . Render ( templateContext , NullEncoder . Default ) ;
114
+ var blobName = await template . RenderAsync ( templateContext , NullEncoder . Default ) ;
115
115
options . BlobName = blobName . Replace ( "\r " , string . Empty ) . Replace ( "\n " , string . Empty ) ;
116
116
117
117
if ( _logger . IsEnabled ( LogLevel . Debug ) )
0 commit comments