Get started building and deploying applications on Microsoft Azure.
This guide will walk you through the essential steps to set up your development environment and deploy your first application to Azure. We'll cover creating resources, writing code, and making it live.
Before you begin, ensure you have an active Azure subscription. If you don't, you can sign up for a free trial.
Next, install the Azure CLI, a powerful command-line tool for managing Azure resources.
Install Azure CLIOpen your terminal or command prompt and log in to your Azure account:
az login
This command will open a browser window for you to authenticate.
Resource groups are logical containers for your Azure resources. Let's create one for this project.
Replace myResourceGroup
and eastus
with your desired name and location.
az group create --name myResourceGroup --location eastus
For this quickstart, we'll deploy a simple Node.js web application. First, create a new directory for your project and navigate into it.
mkdir my-azure-app
cd my-azure-app
Now, create a simple index.js
file with the following content:
const http = require('http');
const port = process.env.PORT || 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello from Azure!\n');
});
server.listen(port, () => {
console.log(`Server running at http://localhost:${port}/`);
});
And a package.json
file:
{
"name": "my-azure-app",
"version": "1.0.0",
"description": "A simple Node.js app for Azure",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {}
}
Now, create your Azure App Service and deploy your code:
az webapp create --resource-group myResourceGroup --name my-unique-app-name --runtime "node|18-lts"
az webapp deploy --resource-group myResourceGroup --name my-unique-app-name --src-path .
Replace my-unique-app-name
with a globally unique name for your web app.
Once the deployment is complete, you can access your web app by navigating to its URL in your browser:
https://my-unique-app-name.azurewebsites.net
Congratulations! You've successfully deployed your first application to Azure.