|
8 | 8 | using Microsoft.AspNetCore.Rewrite; |
9 | 9 | using Azure.Storage.Blobs; |
10 | 10 | using Azure.Identity; |
| 11 | +using Microsoft.Extensions.Azure; |
11 | 12 |
|
12 | 13 | var builder = WebApplication.CreateBuilder(args); |
13 | 14 |
|
|
26 | 27 | }); |
27 | 28 |
|
28 | 29 | builder.AddAzureTableClient("tables"); |
| 30 | +builder.AddAzureBlobClient("blobs"); |
29 | 31 |
|
30 | 32 | // Add Redis distributed caching - manual configuration since extension doesn't exist |
31 | 33 |
|
|
138 | 140 | options.Level = CompressionLevel.Optimal; |
139 | 141 | }); |
140 | 142 |
|
141 | | -// Add Azure Blob Storage |
142 | | -builder.Services.AddSingleton(x => |
143 | | -{ |
144 | | - var connectionString = builder.Configuration.GetConnectionString("blobs"); |
145 | | - if (Uri.IsWellFormedUriString(connectionString, UriKind.Absolute)) |
146 | | - { |
147 | | - // If the connection string is a URI, use it directly |
148 | | - var options = new DefaultAzureCredentialOptions |
149 | | - { |
150 | | - ManagedIdentityClientId = builder.Configuration["AZURE_CLIENT_ID"] |
151 | | - }; |
152 | | - |
153 | | - var credential = new DefaultAzureCredential(options); |
154 | | - return new BlobServiceClient(new Uri(connectionString), credential); |
155 | | - |
156 | | - } |
157 | | - else |
158 | | - { |
159 | | - // Otherwise, treat it as a standard connection string |
160 | | - if (string.IsNullOrWhiteSpace(connectionString)) |
161 | | - { |
162 | | - throw new ArgumentException("Invalid Azure Blob Storage connection string.", nameof(connectionString)); |
163 | | - } |
164 | | - return new BlobServiceClient(connectionString); |
165 | | - } |
166 | | -}); |
167 | | - |
168 | 143 | // Add Content Service with image handling |
169 | 144 | builder.Services.AddSingleton<IContentService, ContentService>(); |
170 | 145 |
|
|
0 commit comments