Skip to content

Instantly share code, notes, and snippets.

@xximjasonxx
Created June 13, 2021 00:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xximjasonxx/092e66664162a89c1542c95e2a516185 to your computer and use it in GitHub Desktop.
Save xximjasonxx/092e66664162a89c1542c95e2a516185 to your computer and use it in GitHub Desktop.
Startup File for Azure Blob Storage Upload/Read
namespace FileUpload
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "FileUpload", Version = "v1" });
});
services.AddTransient<IBlobService>(p => new AzureStorageBlobService(Configuration["StorageAccountConnectionString"]));
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "FileUpload v1"));
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapDefaultControllerRoute();
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment