- Added comprehensive course structure with 11 modules - Included theoretical content, practical examples, and tasks - Multi-language code examples (Java, Rust, Node.js, Python) - Detailed analysis of architectural approaches and trade-offs - Complete caching strategies documentation - Architecture examples from real-world systems (Twitter, Netflix, Uber) - Structured navigation and learning path - Ready for educational use
11 KiB
11 KiB
Azure (Microsoft Azure)
Навигация
Основные сервисы Azure
1. Compute Services
Virtual Machines
- Виртуальные серверы в облаке
- Различные серии (B, D, E, F, G, H, L, M, N)
- Автомасштабирование с Virtual Machine Scale Sets
- Spot VMs для экономии
# Azure VM Configuration
apiVersion: 2021-03-01
type: Microsoft.Compute/virtualMachines
properties:
hardwareProfile:
vmSize: Standard_B1s
storageProfile:
imageReference:
publisher: Canonical
offer: UbuntuServer
sku: 18.04-LTS
version: latest
osDisk:
createOption: FromImage
managedDisk:
storageAccountType: Standard_LRS
osProfile:
computerName: my-vm
adminUsername: azureuser
adminPassword: !Ref AdminPassword
networkProfile:
networkInterfaces:
- id: !Ref NetworkInterface
Azure Functions
- Serverless вычисления
- Поддержка различных языков
- Интеграция с другими Azure сервисами
// Azure Function Example
module.exports = async function (context, req) {
context.log('Processing order request');
const order = req.body;
// Валидация заказа
if (!order || !order.customerId || !order.items) {
context.res = {
status: 400,
body: { error: 'Invalid order data' }
};
return;
}
// Обработка заказа
const orderId = await processOrder(order);
// Отправка уведомления
context.bindings.outputQueue = {
orderId: orderId,
status: 'processed',
timestamp: new Date().toISOString()
};
context.res = {
status: 200,
body: {
orderId: orderId,
status: 'processed'
}
};
};
async function processOrder(order) {
// Логика обработки заказа
return `ORD-${order.customerId}-${Date.now()}`;
}
App Service
- Платформа для веб-приложений
- Поддержка различных языков и фреймворков
- Автоматическое масштабирование
# App Service Configuration
apiVersion: 2021-02-01
type: Microsoft.Web/sites
properties:
name: my-app
location: East US
kind: app
properties:
serverFarmId: !Ref AppServicePlan
siteConfig:
appSettings:
- name: WEBSITE_NODE_DEFAULT_VERSION
value: "18.0.0"
- name: NODE_ENV
value: "production"
alwaysOn: true
httpLoggingEnabled: true
detailedErrorLoggingEnabled: true
2. Storage Services
Blob Storage
- Объектное хранилище для файлов
- Различные уровни доступа (Hot, Cool, Archive)
- Интеграция с CDN
# Azure Storage Account
apiVersion: 2021-02-01
type: Microsoft.Storage/storageAccounts
properties:
sku:
name: Standard_LRS
kind: StorageV2
accessTier: Hot
supportsHttpsTrafficOnly: true
minimumTlsVersion: TLS1_2
allowBlobPublicAccess: false
networkAcls:
defaultAction: Deny
bypass: AzureServices
Managed Disks
- Управляемые диски для VM
- Различные типы (Premium SSD, Standard SSD, Standard HDD)
- Автоматические бэкапы
3. Database Services
Azure SQL Database
- Управляемая реляционная БД
- Автоматические бэкапы и патчи
- Elastic pools для оптимизации затрат
# Azure SQL Database
apiVersion: 2021-02-01
type: Microsoft.Sql/servers
properties:
administratorLogin: admin
administratorLoginPassword: !Ref AdminPassword
version: 12.0
publicNetworkAccess: Disabled
minimalTlsVersion: 1.2
databases:
- name: my-database
properties:
collation: SQL_Latin1_General_CP1_CI_AS
maxSizeBytes: 10737418240
requestedServiceObjectiveName: S0
Cosmos DB
- NoSQL база данных
- Глобальное распределение
- Множественные API (SQL, MongoDB, Cassandra, etc.)
# Cosmos DB Configuration
apiVersion: 2021-03-15
type: Microsoft.DocumentDB/databaseAccounts
properties:
databaseAccountOfferType: Standard
locations:
- locationName: East US
failoverPriority: 0
isZoneRedundant: false
capabilities:
- name: EnableServerless
consistencyPolicy:
defaultConsistencyLevel: Session
enableAutomaticFailover: false
4. Networking Services
Virtual Network
- Изолированная виртуальная сеть
- Подсети и маршрутизация
- Интеграция с on-premises
# Azure Virtual Network
apiVersion: 2021-02-01
type: Microsoft.Network/virtualNetworks
properties:
addressSpace:
addressPrefixes:
- 10.0.0.0/16
subnets:
- name: default
properties:
addressPrefix: 10.0.1.0/24
networkSecurityGroup:
id: !Ref NetworkSecurityGroup
- name: database
properties:
addressPrefix: 10.0.2.0/24
networkSecurityGroup:
id: !Ref DatabaseSecurityGroup
Load Balancer
- Распределение нагрузки
- Health checks
- SSL termination
# Azure Load Balancer
apiVersion: 2021-02-01
type: Microsoft.Network/loadBalancers
properties:
frontendIPConfigurations:
- name: LoadBalancerFrontEnd
properties:
publicIPAddress:
id: !Ref PublicIP
backendAddressPools:
- name: BackendPool
loadBalancingRules:
- name: LBRule
properties:
frontendIPConfiguration:
id: !Ref LoadBalancerFrontEnd
backendAddressPool:
id: !Ref BackendPool
protocol: Tcp
frontendPort: 80
backendPort: 80
enableFloatingIP: false
idleTimeoutInMinutes: 4
5. Security Services
Azure Active Directory
- Управление идентификацией
- Single Sign-On (SSO)
- Multi-Factor Authentication (MFA)
Key Vault
- Управление секретами и ключами
- Шифрование данных
- Аудит доступа
# Azure Key Vault
apiVersion: 2021-06-01-preview
type: Microsoft.KeyVault/vaults
properties:
sku:
family: A
name: standard
tenantId: !Ref TenantId
accessPolicies:
- tenantId: !Ref TenantId
objectId: !Ref UserObjectId
permissions:
keys: [get, list, create, delete, update, import, backup, restore, recover]
secrets: [get, list, set, delete, backup, restore, recover]
certificates: [get, list, create, delete, update, import, backup, restore, managecontacts, manageissuers, getissuers, listissuers, setissuers, deleteissuers]
enabledForDeployment: false
enabledForDiskEncryption: false
enabledForTemplateDeployment: false
enableSoftDelete: true
softDeleteRetentionInDays: 90
enableRbacAuthorization: false
6. Monitoring and Logging
Azure Monitor
- Мониторинг ресурсов и приложений
- Логи и метрики
- Алерты и автоматические действия
# Azure Monitor Alert
apiVersion: 2021-02-01
type: Microsoft.Insights/metricAlerts
properties:
description: Alert when CPU exceeds 80%
severity: 2
enabled: true
scopes:
- !Ref VirtualMachine
criteria:
metricName: Percentage CPU
operator: GreaterThan
threshold: 80
timeAggregation: Average
actions:
- actionGroupId: !Ref ActionGroup
Application Insights
- APM (Application Performance Monitoring)
- Трассировка запросов
- Анализ производительности
7. Application Services
API Management
- Управление API
- Аутентификация и авторизация
- Rate limiting и throttling
# API Management
apiVersion: 2021-08-01
type: Microsoft.ApiManagement/service
properties:
sku:
name: Developer
capacity: 1
publisherName: My Company
publisherEmail: admin@mycompany.com
notificationSenderEmail: notifications@mycompany.com
hostnameConfigurations:
- type: Proxy
hostname: myapi.azure-api.net
defaultSslBinding: true
Service Bus
- Очереди сообщений
- Topics и Subscriptions
- Dead letter queues
# Service Bus Namespace
apiVersion: 2021-06-01-preview
type: Microsoft.ServiceBus/namespaces
properties:
sku:
name: Standard
tier: Standard
location: East US
tags:
Environment: Production
Лучшие практики Azure
1. Resource Groups
- Организуйте ресурсы по проектам или средам
- Используйте теги для категоризации
- Применяйте принцип least privilege
# Resource Group Organization
Resources:
ProductionRG:
Type: Microsoft.Resources/resourceGroups
Properties:
location: East US
tags:
Environment: Production
CostCenter: IT
Owner: Development Team
DevelopmentRG:
Type: Microsoft.Resources/resourceGroups
Properties:
location: East US
tags:
Environment: Development
CostCenter: IT
Owner: Development Team
2. Security
- Используйте Azure AD для аутентификации
- Включайте шифрование для всех данных
- Настройте Network Security Groups
- Используйте Private Endpoints для чувствительных сервисов
3. Monitoring
- Настройте Azure Monitor алерты
- Используйте Application Insights для приложений
- Мониторьте затраты с помощью Cost Management
- Настройте автоматическое масштабирование
4. Backup and Recovery
- Включите автоматические бэкапы
- Используйте Azure Site Recovery для disaster recovery
- Тестируйте процедуры восстановления
- Документируйте recovery procedures
5. Networking
- Используйте приватные подсети для баз данных
- Настройте NAT Gateway для исходящего трафика
- Используйте Private Endpoints для Azure сервисов
- Настройте NSG с минимальными правами