Passer d'Azure Ă  GCP, d'ASP.NET MVC Ă  ASP.NET Core 3.1

Auteur: Andrey Zhukov, chef d'équipe .NET, DataArt





Dans cet article, j'ai dĂ©crit ma propre expĂ©rience rĂ©ussie de migration d'un projet rĂ©el d'une plateforme cloud vers une autre. Bien sĂ»r, ce n'est pas la seule solution possible. Mais je pense que vous trouverez ici des conseils qui faciliteront la vie de tous ceux qui sont sur le point de faire une telle transition. Cependant, vous devrez tenir compte des spĂ©cificitĂ©s de votre projet et faire preuve de bon sens. 





, : Azure -> GCP

(Azure) (Google Cloud Platform). Node.js full-stack typescript-. ASP.NET MVC , . GCP.





, , GCP

ASP.NET MVC-, MS SQL . Azure App Services.





— Web Portal — , Razor, TypeScript, JavaScript, Knockout Bootstrap. . , Azure: Azure Service Bus, Azure Blobs, Azure Tables storage, Azure Queue storage. - , . . GCP . , Azure Cache for Redis. Azure WebJob, Azure Service Bus. , , .





Au départ, l'architecture du portail Web de notre projet ressemblait à ceci
Web Portal

Azure WebJobs - . — , , Hangfire, IHostedService Microsoft.





— Web API — ASP.NET WEB API. MS SQL . , , . .





, : , , ASP.NET MVC . . , , , . .





, ASP.NET MVC ASP.NET Core 3.1, WebJob c .NET Framework .NET Core, Linux. Windows GCP , . , Azure, - Azure WebJob, , GCP, . . Azure App Services. Docker. - .





, : , .





, . . Smoke tests.





, , , . . .   , , , .





: , . , - . , , . , , , , , . . , , .





Azure GCP-, cloud-agnostic-. .





, - , . . , . . – , , . 





  1. Web Portal c ASP.NET MVC ASP.NET Core





    1.1.  Web Portal Azure , .





    1.2.  Web Portal .NET Core.





    1.3.  .





    1.4.  Merge Web Portal , .





    1.5.  Web Portal.





    1.6.  Web Portal, Azure.





  2. Web API c ASP.NET MVC ASP.NET Core





    2.1.  E2E Web API.





    2.2.  Web API Azure , .





    2.3.  Web API.





    2.4.  Web API .NET Core.





    2.5.  Web API .





    2.6.  Merge Web API , .





    2.7.  Web API.





    2.8.  Web API, Azure.





  3. Azure





    3.1.  Web Portal Azure.





  4. GCP





    4.1.  Web Portal GCP.





    4.2.  Web Portal .





    4.3.  .





    4.4.  Web API GCP.





    4.5.  Web API .





    4.6.  prod-.





    4.7.  Web Portal Web API prod GCP.





, , , .





.NET Framework -> .NET Core

.Net Framework .Net Core Microsoft ASP.NET ASP.NET Core.





-Web- :





  • NuGet- Visual Studio 2019;





  • ;





  • App.config XML settings.json .





NuGet- Azure SDK , . , .NET Core , . Azure Service Bus WebJobs SDK. Azure Service Bus , WebJob , SDK.





C ASP.NET MVC ASP.NET Core . Web-. ASP.NET Core , . ASP.NET Core , ASP.NET MVC . , , ASP.NET MVC ASP.NET Core.





  1. ASP.NET Core ASP.NET MVC .





  2. ( NuGet-, . ).





  3. Web.config appsettings.json .





  4. Dependency injection .NET Core , Asp.NET MVC .





  5.   StaticFiles middleware : , , JavaScript-, CSS- . .





app.UseStaticFiles(); // wwwroot
app.UseStaticFiles(new StaticFileOptions
   	{
     	FileProvider = new PhysicalFileProvider(
         Path.Combine(Directory.GetCurrentDirectory(), "Scripts")),
     	RequestPath = "/Scripts"
});
      
      



wwwroot



.





6. bundleconfig.json JavaScript CSS- . JavaScript CSS:





<link rel="stylesheet" href="~/bundles/Content.css" asp-append-version="true" />
<script src="~/bundles/modernizr.js" asp-append-version="true"></script>
      
      



asp-append-version="true"



, (bundles) , . . wwwroot



( ).









7. UnhadledExceptions: ASP.NET Core , , .





8.     : ASP.NET Core Serilog. , , -, structured logging c .





9.     Session — , , .





10.  Routing: , templates, - .





11.  JSON-:  ASP.NET Core System.Text.Json Newtonsoft.Json. Microsoft , , , , , Newtonsoft.Json . , Newtonsoft.Json. , , Web API , , , . Newtonsoft.Json





12.  Typescript 2.3. , Node.js, Microsoft.TypeScript.MSBuild, tsconfig.json, (Definitions) Knockout, - //@ts-ignore







13.  HTTPS . , HttpsOnly, .





14.  , body , URL , HTTP Headers HttpContext , . . API ASP.NET MVC. , binding (Actions) (Controllers).





15.  Swagger c Swashbuckle.AspNetCore.Swagger.





16.  Authentication .





, . , .





Azure?

ASP.NET Core Azure-. , , - GCP. .





Azure Service Bus Redis Pub/Sub. , , , RabbitMQ. , , Redis . — . , , . , Redis Pub/Sub , .





Azure Blobs GCP Blobs. , - : GCP Blobs . CSV. Google Google Cloud operations suite, Stackdriver.





Azure Table Storage Web Portal. , . Microsoft, . . ILogger. , Serilog. GCP Stackdriver.





- GCP, Azure. , , , : IBlobService, IRequestLogger, ILogReader. Serilog. , Web Portal, , Azure Table Storage, Serilog.Sinks.AzureTableStorage.KeyGenerator.IKeyGenerator. GCP Google Cloud operations Log Router Sinks, BigQuery, .





Azure WebJobs?

Azure WebJobs Azure App Services on Windows. , Azure WebJobs SDK. SDK . :





static async Task Main(string[] args)
{
….
 
  var builder = new HostBuilder();

  ...            	

  var host = builder.Build();

  using (host)
  {
     await host.RunAsync();
  }
...
}
      
      



Dependency Injection





public class RedisPubSubMessageProcessor : Microsoft.Extensions.Hosting.IHostedService
{
...
	public async Task StartAsync(CancellationToken cancellationToken)
...
	public async Task StopAsync(CancellationToken cancellationToken)
...
}
      
      



.NET Core . Azure WebJob SDK, Azure WebJob. Linux Docker- Kubernetes, . 





. , . , . , Microsoft. , , . Web API . Azure- , .





, , .





Docker

Docker . Dockerfile Visual Studio. , , Web Portal, Web API, WebJob ( ). Dockerfile Microsoft — Dockerfile Web Portal Node.js. build TypeScript.





RUN apt-get update && \
	apt-get -y install curl gnupg && \
	curl -sL https://deb.nodesource.com/setup_12.x  | bash - && \
	apt-get -y install nodejs
      
      



Azure App Services -> GKE

.NET Core- GCP, :





  • App Engine Flex.





  • Kubernetes Engine.





  • Compute Engine.





Google Kubernetes Engine (GKE). (Linux). GKE, , , . , . - .





GCP, MS SQL Server, Cloud SQL Google. 





L'architecture de notre système après la migration vers GCP
GCP

Web Portal , Smoke-. . , Prod, , , Product Owner. QA-, , , . , . Puppeteer-, - . CICD. - - - .





Web API, , . Postman, CICD Newman. Swagger, . . IIS (Internet Information Services), . . , , Postman- . , , Staging, Prod, Dev.





, . , . Web API , , , .





Azure MS SQL -> GCP Managed MS SQL

MS SQL Managed Azure GCP Cloud SQL , . :





  • (Azure :  Database data storage /





    Used space 181GB).





  •     .





  •   Azure GCP Cloud SQL.





, Google Chrome. , .





, . Azure SQL bacpac, backup . 6 bacpac 154 backup. GCP Cloud backup, , MS SQL bacpac backup . Microsoft SQL Server Management Studio, MS SQL Server . , . Azure SQL prod , . - , . SSD- 1 .





Azure App Services GCP Kubernetes CICD, Feature Branch deployments, Blue/Green deployment. Kubernetes , Github Actions. Iac (Infrastructure-as-Code) Pulumi.





. — .








All Articles