Create Azure WebApps
In this section we will go over the different ways of how to use Fractal SDK to configure Azure Web Apps, both for .NET apps and for Java apps. Furthermore, we also have a section on how to deploy Azure WebApps using Azure Pipelines.
Java Web App Example
var resourceGroup = AzureResourceGroup.builder()
.withName("resource-group")
.withRegion(EUROPE_WEST)
.build();
var appServicePlan = AzureAppServicePlan.builder()
.withName("asp-sample")
.withRegion(EUROPE_WEST)
.withAzureResourceGroup(resourceGroup)
.withOperatingSystem(AzureOsType.LINUX)
.withPricingPlan(AzurePricingPlan.BASIC_B1)
.withNumberOfWorkers(1)
.build();
return AzureWebApp.builder()
.withId(id)
.withDisplayName("Java WebApp")
.withResourceGroup(resourceGroup)
.withRegion(EUROPE_WEST)
.withRepoId("YanchWare/fractal-samples")
.withBranchName("env/prod")
.withPrivateSSHKeyPassphraseSecretId("fractal-deployer-secret-id")
.withPrivateSSHKeySecretId("fractal-deployer-passphrase-secret-id")
.withSSHRepositoryURI("git@github.com:YanchWare/fractal-samples.git")
.withOperatingSystem(LINUX)
.withRuntimeStack(AzureWebAppLinuxRuntimeStack.JAVA_11)
.withAppServicePlan(appServicePlan)
.withCustomDomains(List.of("api.app.cloud"))
.withCertificate(AzureKeyVaultCertificate.builder()
.withKeyVaultId("/subscriptions/keyvault")
.withName("sna-app")
.build())
.withConfiguration(AzureWebAppConfiguration.builder()
.withAppSettings(Map.of("JAVA_VERSION", "11"))
.withHealthCheckPath("/health/")
.withNumberOfWorkers(2)
.build())
.withLink(ComponentLink.builder().withComponentId("another-component-id").withRoleName("Contributor").build())
.withRoles(List.of(CustomWorkloadRole.builder().withName("role").withRoleType(RoleType.BUILT_IN_ROLE).build()))
.build();
.NET Web App Example
var resourceGroup = AzureResourceGroup.builder()
.withName("resource-group")
.withRegion(EUROPE_WEST)
.build();
var appServicePlan = AzureAppServicePlan.builder()
.withName("asp-sample")
.withRegion(EUROPE_WEST)
.withAzureResourceGroup(resourceGroup)
.withOperatingSystem(AzureOsType.LINUX)
.withPricingPlan(AzurePricingPlan.BASIC_B1)
.withNumberOfWorkers(1)
.build();
return AzureWebApp.builder()
.withId(id)
.withDisplayName(".NET WebApp")
.withResourceGroup(resourceGroup)
.withRegion(EUROPE_WEST)
.withRepoId("YanchWare/fractal-samples")
.withBranchName("env/prod")
.withPrivateSSHKeyPassphraseSecretId("fractal-deployer-secret-id")
.withPrivateSSHKeySecretId("fractal-deployer-passphrase-secret-id")
.withSSHRepositoryURI("git@github.com:YanchWare/fractal-samples.git")
.withOperatingSystem(LINUX)
.withRuntimeStack(AzureWebAppLinuxRuntimeStack.DOTNET_CORE_7_0)
.withAppServicePlan(appServicePlan)
.withCustomDomains(List.of("api.app.cloud"))
.withCertificate(AzureKeyVaultCertificate.builder()
.withKeyVaultId("/subscriptions/keyvault")
.withName("sna-app")
.build())
.withConfiguration(AzureWebAppConfiguration.builder()
.withAppSettings(Map.of("ASPNETCORE_ENVIRONMENT", "Development"))
.withHealthCheckPath("/health/")
.withNumberOfWorkers(2)
.build())
.withLink(ComponentLink.builder().withComponentId("another-component-id").build())
.withRoles(List.of(CustomWorkloadRole.builder().withName("role").withRoleType(RoleType.BUILT_IN_ROLE).build()))
.build();
Deployment example using Azure Pipelines
Microsoft provides good integration between Azure and DevOps and you can easily deploy a web app using pipelines. For more details you can check Microsoft documentation.