Azure 简介
什么是 Azure Cloud?
Microsoft Azure 是微软提供的云计算平台,涵盖计算、存储、数据库、AI/ML、安全等多种云服务。
info
Azure 适用于企业级应用、DevOps、数据分析和 AI 开发。
Azure 主要服务
服务 | 描述 | 适用场景 |
---|---|---|
Virtual Machines | 提供可扩展的虚拟机实例 | 托管应用、Web 服务器 |
Azure Blob Storage | 对象存储,适用于大规模数据存储 | 备份、日志存储、大数据 |
Azure SQL Database | 托管关系数据库,如 SQL Server | 数据库托管 |
Azure Functions | 无服务器计算,按需运行代码 | 事件驱动应用、微服务 |
Cosmos DB | NoSQL 数据库,低延迟高扩展性 | IoT、实时数据存储 |
Azure AD | 身份访问管理,控制 Azure 资源权限 | 访问控制、安全管理 |
Azure 代码示例
- Python
- JavaScript
from azure.storage.blob import BlobServiceClient
connection_string = "your_connection_string"
client = BlobServiceClient.from_connection_string(connection_string)
buckets = client.list_containers()
for bucket in buckets:
print(bucket['name'])
const { BlobServiceClient } = require("@azure/storage-blob");
const client = BlobServiceClient.fromConnectionString("your_connection_string");
async function listContainers() {
let containers = client.listContainers();
for await (const container of containers) {
console.log(container.name);
}
}
listContainers();
Azure Functions 示例
- Python
- Node.js
def main(req):
return 'Hello from Azure Functions!'
module.exports = async function (context, req) {
context.res = {
body: "Hello from Azure Functions!",
};
};
部署 Azure 资源
如何使用 Azure CLI 创建存储账户
az storage account create --name mystorageaccount --resource-group myResourceGroup --location eastus --sku Standard_LRS
如何使用 Terraform 部署 Azure VM
provider "azurerm" {
features {}
}
resource "azurerm_virtual_machine" "example" {
name = "example-vm"
location = "eastus"
resource_group_name = "myResourceGroup"
vm_size = "Standard_B1s"
storage_os_disk {
name = "myosdisk"
caching = "ReadWrite"
create_option = "FromImage"
}
}
结论
Azure 提供了丰富的云计算服务,适用于不同的业务场景。无论是计算、存储、数据库,还是无服务器架构,Azure 都能提供灵活高效的解决方案。