Se afișează postările cu eticheta Azure. Afișați toate postările
Se afișează postările cu eticheta Azure. Afișați toate postările

10/22/2024

Deploying a Web App on Azure App Service: Step-by-Step Guide

 Azure is the Cloud computing platform and Suite of cloud services provided by Microsoft. Azure provides various services including building and deploying web apps, logic apps, configuring databases, etc.

In this article, let us understand how to deploy a web app on Azure app service.


Deploying a Web App on Azure App Service

Step 1: Create and set up your Microsoft Azure account

First, make sure that you have signed in to your Azure portal. If you still figuring out how to sign in to the Azure portal, follow this link: Microsoft-Azure portal. After signing in, you will preview this dashboard.



Step 2: Build your Web Application

Create your web application in the tech stack you want. Microsoft Azure supports various technologies like C#, Java, Python, Ruby, Vue, React, Angular, etc. You can also push your code into GitHub or manage your code with any other Version Control System.

In my case, I created a sample application and pushed it to GitHub.


Step 3: Create a Resource Group, for your Web App

To manage and maintain our web application in terms of access control, resource allocation, etc. We need to have a Resource group. You can use any existing Resource group, if not let us create a new Resource group for our application. Navigate to the `Resource groups` option on the dashboard.


Customize the options as per your requirement and click `Review+create`. you will receive a confirmation message.



Step 4: Create your Web App Service using Azure Services

Now, go back to the home page or dashboard, and you will find the `App Services` option.

I have chosen a `web app` and there are various options to customize. Let me brief the important ones.In the `Basics` tab, we can see some basic options like choosing the Resource group, Name of the Web app, Region, Run-time stack (Run-time stack supports tech stack like Java, node.js, Python, .NET, Go, PHP)


In the `Deployment` tab, we can add and configure our GitHub account settings by enabling the "continuous deployment" option and we can link our GitHub account, repository, and branch.

These are the important and basic configurable options. There are other tabs like "networking", "monitoring", and "tags". The last tab shows ‘Review+create‘ where we can review the properties and create our web app.

Step 5: Deploy your web app

Now, click on the name of your web app in the App Services.

You will find various options listed down along with the "Default domain" option which contains a link. This is the deployed link of your web app. When you click on that link for the first time, you will find a default web page displayed rather than your actual code. We need to modify this.




To modify this default code, go back to your web app, on the left sidebar, under the development tools section, you will find "Advanced tools". Click on that.



You will be navigating to a new tab that shows various options including debbugging console, which has two options: CMD and PowerShell. Lets go with CMD, here the default code directory of the default web page displayed.






Go to the "sites" folder and "wwwroot". you will find "hostingstart.html" there. This contains the code of the default web page displayed.





Go to your application directory on your computer and drag and drop the required files here.


Now, go back to the "Default domain" link or refresh the previously opened link. Now, you will find your web app successfully deployed.


Points to be remembered:

- you can start or stop running your web app anytime, by clicking here, as the Azure web app charges your Azure credits.
- Make sure you give required Access controls to your application through your resource group.
- Now, you can access your web app anywhere with the default domain link.

This is a sample demonstration of Deploying a web app through Azure App Services. There are many configurable options and many approaches to deploy your web app choose according to your requirement and the application’s complexity.




10/20/2024

Using Terraform to deploy infrastructure on Microsoft Azure

Using Terraform to deploy infrastructure on Microsoft Azure




In this article, we will provide a practical end-to-end example of using Terraform to deploy infrastructure on Microsoft Azure. We will also share some best practices, common problems you might encounter when first starting, and how to troubleshoot them. Let’s go!


What we will cover:

  • What is Terraform?
  • What is Microsoft Azure?
  • Why use Terraform on Azure?
  • How to run Terraform with Azure
  • Best practices for using Terraform with Azure
  • Troubleshooting common issues when running Terraform on Azure
  • Example: Kubernetes deployment with Terraform on Azure
  • What is Terraform?


Terraform is an infrastructure-as-code (IaC) tool that allows you to define and provision data center infrastructure using a declarative configuration language. It supports multiple cloud providers, including Microsoft Azure. Using Terraform on Azure, you can create, manage, and update resources like virtual machines, storage accounts, and networking interfaces, ensuring consistent and reproducible infrastructure deployment across different environments. 

Terraform integrates well with automation tools and CI/CD pipelines. As part of your development workflow, you can leverage Terraform scripts to automate infrastructure provisioning and configuration changes.

A typical Terraform workflow involves three main steps: writing the infrastructure as code in configuration files, initializing and planning to preview the changes, and applying those changes to provision the infrastructure.


Basic Terraform commands — quick reference

Here are some common commands you will use in Terraform:

terraform init — Initialize the Terraform working directory. It fetches required plugins and prepares the environment for other commands.

terraform plan — Generate an execution plan outlining the changes Terraform will make based on your configuration files. It shows what will be created, updated, or destroyed.

terraform apply — Apply the planned changes to your infrastructure based on the Terraform configuration. Review the plan carefully before applying.

terraform destroy — Destroy the infrastructure managed by Terraform. Use with caution, as it can permanently remove resources.

terraform show — Show details about a specific resource or the current state of your infrastructure.

terraform state rm <resource name> — Remove a resource from Terraform state management.

terraform state refresh — Refresh the Terraform state to match the actual state of your infrastructure in the cloud provider.

terraform fmt — Reformat your Terraform configuration files to follow the standard coding style.

terraform validate — Validate your Terraform configuration for syntax errors.
terraform get <provider> — Download and install plugins for specific providers (optional argument to specify a provider).




What is Microsoft Azure?

Microsoft Azure is a cloud computing platform developed by Microsoft. It offers a wide range of services, including computing, analytics, storage, and networking, that allow you to build, deploy, and manage applications across a global network of data centers. Users pick and choose from these services to develop and scale new applications or run existing ones.

Common use cases for the Azure public cloud include building and deploying web and mobile applications, developing and deploying cloud-native applications, storing and managing data, and creating and managing virtual machines.

Microsoft Azure features
  • Microsoft Azure offers over 200 products and services.
  • Azure supports all languages and frameworks, allowing you to develop how you want and deploy where you need to.
  • Whether on-premises or across multiple clouds, Azure meets you where you are. It provides services designed for hybrid cloud environments.
  • Azure prioritizes security, compliance, and privacy.

Why use Terraform on Azure?

Terraform allows you to define your infrastructure in code, making it versionable, repeatable, and auditable. You can manage your Azure resources using declarative configuration files. Compared with Azure Resource Manager (ARM) templates, Terraform can be more concise and easier to maintain for complex infrastructure deployments.

Note that Terraform is cloud-agnostic, so you can use the same language to provision resources across Azure, AWS, Google Cloud, and other providers. It also supports hybrid scenarios, seamlessly integrating on-premises and cloud environments. This flexibility is a key reason why many organizations choose to use Terraform as their preferred IaC tool. 

Terraform has a dedicated Azure provider (azurerm) that supports a wide range of Azure resources, allowing you to manage Azure services comprehensively, and it also integrates well with Azure DevOps, enabling you to create CI/CD pipelines for automated deployment and management of your Azure infrastructure.

Terraform ensures consistent resource provisioning. You define the desired state, and Terraform handles the actual deployment, reducing configuration drift. At the same time, Terraform automatically manages resource dependencies. For example, if you create a virtual machine that requires a virtual network, Terraform ensures the network is provisioned first.

Terraform maintains a state file that tracks the actual Azure infrastructure state. This helps with tracking changes, collaboration, and understanding the current environment.

Lastly, Terraform has a vibrant community and a rich ecosystem of providers and modules. You can find pre-built modules for common Azure services, saving time and effort.


How to run Terraform with Azure
To run Terraform with Azure, follow the steps below:

  1. Install the Azure CLI tool.
  2. Install Terraform.
  3. Connect to Azure.
  4. Configure the Terraform Azure provider.
  5. Create and add an Azure resource group.
  6. Verify the results.
  7. Clean up.

1. Install the Azure CLI tool

First, we need to install the Azure CLI tool.

Windows:

Head to the Microsoft download page.

Choose the appropriate installer for your system (32-bit or 64-bit) and download the installer file (.msi).

macOS or Linux:

Open a terminal window and run the following command:
curl -sL https://aka.ms/install-azure-cli | bash

Or using homebrew: 

brew install azure-cli

After installation, confirm it has been successful:

az --version

If the installation was successful, you should see the installed Azure CLI version displayed.

2. Install Terraform

Visit the official Terraform download page.

Select the appropriate version for your operating system (Windows, macOS, or Linux) and architecture (32-bit or 64-bit). Download the installer file (typically a .zip archive for Windows/macOS or a .tar.gz archive for Linux).

Most distributions also offer Terraform packages through package managers. This can be a convenient way to install and update Terraform.


Ubuntu/Debian: sudo apt install terraform

RedHat/CentOS: sudo yum install terraform

macOS (Homebrew): brew tap hashicorp/tap && brew install hashicorp/tap/terraform

chocolatey (Windows): choco install terraform

Verify Terraform is installed:

terraform --version

If the installation was successful, you should see the installed Terraform version displayed.

If you need more help with your Terraform installation, check out How to Download & Install Terraform on Windows, MacOS, Linux.

3. Connect to Azure

After installing the Azure CLI, you need to log in to your Azure account using the az login command. Follow the prompts to authenticate and complete the login process.

az login

If you have multiple Azure subscriptions, you can set your subscription to use for subsequent commands:

az account set --subscription <subscription_id_or_name>


4. Configure the Terraform azurerm provider

The Azure provider is configured in a Terraform configuration file using the azurerm provider configuration block. Create a Terraform configuration file named main.tf (or a name of your choosing) in your project directory.


provider "azurerm" {
  features {}
  # Replace with your Azure subscription ID
  subscription_id = "<your_subscription_id>"
  # Optional: Choose the desired Azure environment from [AzureCloud, AzureChinaCloud, AzureUSGovernment, AzureGermanCloud]
  # environment = "AzureCloud"
  # Optional: Set the Azure tenant ID if using Azure Active Directory (AAD) service principal authentication
  # tenant_id = "<your_tenant_id>"
  # Optional: Set the client ID of your AAD service principal
  # client_id = "<your_client_id>"
  # Optional: Set the client secret of your AAD service principal
  # client_secret = "<your_client_secret>"
}


You can optionally configure authentication using an Azure Active Directory (AAD) service principal by providing tenant_id, client_id, and client_secret. This is a more secure approach compared with using your Azure subscription credentials directly. To avoid hardcoding these in the configuration file, you can set them as environment variables:

export ARM_CLIENT_ID="xxxxx"
export ARM_CLIENT_SECRET="xxxxx"
export ARM_SUBSCRIPTION_ID="xxxxx"
export ARM_TENANT_ID="xxxxx"

5. Create and add an Azure resource group

Add the configuration for the Azure resource group to your configuration file using the azurerm_resource_group block.

resource "azurerm_resource_group" "example_group" {
  name     = "my-resource-group"
  location = "uksouth"
  tags = {
    environment = "dev"
  }
}

In your terminal window, navigate to your Terraform project directory.

Run the command terraform init to initialize Terraform.

Run the command terraform plan to see the changes Terraform will make. This will show you the creation of the resource group. If the plan looks good, run terraform apply to create the resource group in your Azure subscription.

6. Verify the results

Log into the Azure portal and navigate to the Resource Groups section to see your newly created resource group with the specified name and location.

7. Clean up

If you no longer need the resource group, you can remove it using Terraform by running terraform destroy.




4/25/2024

Quarkus and Azure

 Here, I have collected some links related with Quarkus on Azure:


- Tutorial: Linux Java app with Quarkus and PostgreSQL - Azure App Service | Microsoft Learn

- Configure MicroProfile with Azure Key Vault - Java on Azure | Microsoft Learn

- Deploy a Quarkus Web App to Azure App Service with Maven - Java on Azure | Microsoft Learn

- Deploy serverless Java apps with Quarkus on Azure Functions | Microsoft Learn

- Deploy Quarkus on Azure Container Apps - Java on Azure | Microsoft Learn

- How to Manually Deploy a Quarkus Application to Azure with Terraform Thanks to NubesGen - Antonio's Blog (antoniogoncalves.org)

- quarkus - how to specify Hosting options and plan for azure function - Stack Overflow

- GitHub - j-madden/quarkus-mssql-azure: Documentation on setting up a native built quarkus application as an Azure App Service & with an Azure SQL database connection.

- Deploy Quarkus on Azure Container Apps - Java on Azure | Microsoft Learn

- Tutorial: Access data with managed identity in Java using Service Connector | Microsoft Learn

- Deploy Quarkus on Azure Container Apps - Java on Azure | Microsoft Learn

Functions:

 -  Deploying to Microsoft Azure Cloud - Quarkus

-  Azure Functions with Quarkus REST, Undertow, or Reactive Routes - Quarkus

- Serverless on Azure Function with Quarkus - Piotr's TechBlog (piotrminkowski.com)

- .


Azure Monitor

- https://learn.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-enable?tabs=java


Others: 

-  Homepage | Antonio Goncalves's Store (teachable.com)

- Quarkus Azure App Configuration Extension :: Quarkiverse Documentation


Video:

- Deploying Quarkus applications to Azure (youtube.com)

- Quarkus Superheroes on Azure | Antonio Goncalves & Eric Deandreas (EN) (youtube.com)

- Deploying Quarkus apps to Azure App Service with GitHub Actions (youtube.com)

- Create & deploy app services (youtube.com)

- Create & deploy app services (youtube.com) Azure

- SetUp an Azure Kubernetes Cluster for your Quarkus App #coding #quarkus #java (youtube.com)



Database Persistence and Flyway in Quarkus

Database Persistence and Flyway in Quarkus  Building a Production-Ready Product Management System with PostgreSQL Introduction In ...