Files
2026-11-10 18:41:53 +03:30

1142 lines
57 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>راهنمای جامع Azure API و توسعه برنامه | شرکت رایان پرداز کاوش Azure</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');
:root {
--primary: #1a365d;
--primary-light: #2c5282;
--accent: #c9a961;
--accent-dark: #a8893f;
--bg: #faf9f6;
--card-bg: #ffffff;
--text: #1a202c;
--text-muted: #4a5568;
--border: #e2e8f0;
--success: #38a169;
--danger: #e53e3e;
--warning: #dd6b20;
--shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 10px 30px rgba(26, 54, 93, 0.08);
}
{
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: 'Vazirmatn', Tahoma, sans-serif;
background: var(--bg);
color: var(--text);
line-height: 1.9;
font-size: 15px;
padding: 30px 15px;
}
.document-container {
max-width: 950px;
margin: 0 auto;
background: var(--card-bg);
box-shadow: var(--shadow);
border-radius: 12px;
overflow: hidden;
}
.document-header {
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
color: white;
padding: 50px 40px 40px;
position: relative;
border-bottom: 4px solid var(--accent);
}
.document-header::before {
content: '';
position: absolute;
top: 0;
right: 0;
width: 200px;
height: 200px;
background: radial-gradient(circle, rgba(201, 169, 97, 0.15) 0%, transparent 70%);
border-radius: 50%;
transform: translate(50%, -50%);
}
.header-top {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 30px;
position: relative;
z-index: 1;
}
.company-badge {
display: flex;
align-items: center;
gap: 12px;
}
.company-logo {
width: 60px;
height: 60px;
background: var(--accent);
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.doc-meta {
text-align: left;
font-size: 12px;
opacity: 0.9;
}
.doc-meta div {
margin-bottom: 3px;
}
.document-title {
text-align: center;
position: relative;
z-index: 1;
padding: 20px 0;
}
.document-title .label {
display: inline-block;
background: rgba(201, 169, 97, 0.2);
color: var(--accent);
padding: 4px 16px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
margin-bottom: 15px;
border: 1px solid rgba(201, 169, 97, 0.4);
}
.document-title h1 {
font-size: 28px;
font-weight: 800;
margin-bottom: 10px;
letter-spacing: -0.5px;
}
.document-title h2 {
font-size: 16px;
font-weight: 400;
opacity: 0.9;
}
.document-body {
padding: 40px;
}
.intro-text {
background: linear-gradient(to left, #f7fafc, #edf2f7);
border-right: 4px solid var(--accent);
padding: 20px 25px;
border-radius: 8px;
margin-bottom: 35px;
font-size: 14px;
color: var(--text-muted);
}
.section {
margin-bottom: 40px;
page-break-inside: avoid;
}
.section-header {
display: flex;
align-items: center;
gap: 15px;
padding-bottom: 12px;
border-bottom: 2px solid var(--border);
margin-bottom: 20px;
}
.section-number {
width: 50px;
height: 50px;
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
font-weight: 800;
font-size: 20px;
flex-shrink: 0;
box-shadow: 0 4px 10px rgba(26, 54, 93, 0.2);
}
.section-title {
flex: 1;
}
.section-title h3 {
font-size: 19px;
font-weight: 700;
color: var(--primary);
margin-bottom: 2px;
}
.section-title .subtitle {
font-size: 12px;
color: var(--text-muted);
}
.section-content {
padding-right: 10px;
}
.section-content p {
margin-bottom: 12px;
text-align: justify;
text-indent: 20px;
}
.section-content p.no-indent {
text-indent: 0;
}
.highlight-box {
background: linear-gradient(to left, #fffaf0, #fef5e7);
border: 1px solid #f6e05e;
border-right: 4px solid var(--accent);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.highlight-box strong {
color: var(--accent-dark);
}
.info-box {
background: linear-gradient(to left, #ebf8ff, #e6f6ff);
border: 1px solid #90cdf4;
border-right: 4px solid var(--primary-light);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.success-box {
background: linear-gradient(to left, #f0fff4, #e6fffa);
border: 1px solid #9ae6b4;
border-right: 4px solid var(--success);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.warning-box {
background: linear-gradient(to left, #fffaf0, #fef5e7);
border: 1px solid #fbd38d;
border-right: 4px solid var(--warning);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.styled-table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
background: white;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.styled-table thead {
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
}
.styled-table th {
padding: 14px 16px;
text-align: right;
font-weight: 600;
font-size: 13px;
}
.styled-table td {
padding: 13px 16px;
border-bottom: 1px solid var(--border);
font-size: 13px;
}
.styled-table tbody tr:last-child td {
border-bottom: none;
}
.styled-table tbody tr:nth-child(even) {
background: #f8fafc;
}
.styled-table .highlight-row {
background: #fffaf0 !important;
font-weight: 600;
}
.comparison-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
margin: 25px 0;
}
.comparison-card {
background: #f8fafc;
border: 2px solid var(--border);
border-radius: 10px;
padding: 20px;
position: relative;
}
.comparison-card.recommended {
border-color: var(--success);
background: linear-gradient(to left, #f0fff4, #e6fffa);
}
.comparison-card .card-badge {
position: absolute;
top: -10px;
right: 20px;
background: var(--success);
color: white;
padding: 3px 12px;
border-radius: 15px;
font-size: 11px;
font-weight: 600;
}
.comparison-card h4 {
font-size: 16px;
font-weight: 700;
color: var(--primary);
margin-bottom: 15px;
padding-bottom: 10px;
border-bottom: 2px solid var(--border);
}
.comparison-card.recommended h4 {
border-bottom-color: var(--success);
}
.comparison-card ul {
list-style: none;
padding: 0;
}
.comparison-card ul li {
padding: 8px 0;
border-bottom: 1px solid var(--border);
font-size: 13px;
display: flex;
justify-content: space-between;
}
.comparison-card ul li:last-child {
border-bottom: none;
}
.comparison-card ul li .value {
font-weight: 600;
color: var(--primary);
}
.quote-box {
background: linear-gradient(135deg, #f7fafc, #edf2f7);
border-right: 4px solid var(--accent);
padding: 20px 25px;
border-radius: 8px;
margin: 20px 0;
position: relative;
}
.quote-box::before {
content: '"';
position: absolute;
top: -10px;
right: 15px;
font-size: 60px;
color: var(--accent);
opacity: 0.3;
font-family: Georgia, serif;
}
.quote-box p {
font-style: italic;
color: var(--text-muted);
margin-bottom: 10px;
text-indent: 0 !important;
}
.quote-box .source {
font-size: 12px;
color: var(--text-muted);
text-align: left;
font-style: normal;
}
.stats-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 15px;
margin: 25px 0;
}
.stat-card {
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
padding: 20px;
border-radius: 10px;
text-align: center;
box-shadow: 0 4px 12px rgba(26, 54, 93, 0.2);
}
.stat-card .stat-value {
font-size: 24px;
font-weight: 800;
margin-bottom: 5px;
color: var(--accent);
line-height: 1.3;
}
.stat-card .stat-label {
font-size: 12px;
opacity: 0.9;
}
.timeline {
position: relative;
padding: 20px 0;
margin: 25px 0;
}
.timeline::before {
content: '';
position: absolute;
right: 50%;
top: 0;
bottom: 0;
width: 3px;
background: var(--border);
transform: translateX(50%);
}
.timeline-item {
display: flex;
margin-bottom: 20px;
position: relative;
}
.timeline-item:nth-child(odd) {
flex-direction: row-reverse;
}
.timeline-content {
width: 45%;
background: #f8fafc;
border: 1px solid var(--border);
border-radius: 8px;
padding: 15px;
position: relative;
}
.timeline-item:nth-child(odd) .timeline-content {
margin-left: 5%;
}
.timeline-item:nth-child(even) .timeline-content {
margin-right: 5%;
}
.timeline-dot {
position: absolute;
right: 50%;
top: 20px;
width: 16px;
height: 16px;
background: var(--accent);
border: 3px solid white;
border-radius: 50%;
transform: translateX(50%);
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.timeline-content h5 {
font-size: 14px;
font-weight: 700;
color: var(--primary);
margin-bottom: 8px;
}
.timeline-content p {
font-size: 12px;
color: var(--text-muted);
text-indent: 0 !important;
margin-bottom: 0 !important;
}
.reference-list {
list-style: none;
padding: 0;
margin: 20px 0;
}
.reference-list li {
background: #f8fafc;
border-right: 3px solid var(--primary-light);
padding: 15px 20px;
margin-bottom: 10px;
border-radius: 6px;
font-size: 13px;
}
.reference-list li strong {
color: var(--primary);
display: block;
margin-bottom: 5px;
}
.reference-list li .ref-source {
font-size: 11px;
color: var(--text-muted);
margin-top: 5px;
}
.conclusion-box {
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
padding: 30px;
border-radius: 12px;
margin: 30px 0;
text-align: center;
box-shadow: 0 8px 20px rgba(26, 54, 93, 0.3);
}
.conclusion-box h3 {
font-size: 22px;
font-weight: 800;
margin-bottom: 15px;
color: var(--accent);
}
.conclusion-box p {
font-size: 14px;
line-height: 1.8;
text-indent: 0 !important;
margin-bottom: 15px;
}
.conclusion-box .highlight {
background: rgba(201, 169, 97, 0.2);
padding: 15px 20px;
border-radius: 8px;
margin-top: 20px;
border: 1px solid rgba(201, 169, 97, 0.4);
}
.document-footer {
background: var(--primary);
color: white;
padding: 25px 40px;
text-align: center;
font-size: 12px;
margin-top: 40px;
}
.document-footer .footer-brand {
font-weight: 700;
color: var(--accent);
margin-bottom: 5px;
font-size: 14px;
}
.footer-divider {
width: 60px;
height: 2px;
background: var(--accent);
margin: 10px auto;
}
.page-info {
text-align: center;
padding: 15px;
font-size: 11px;
color: var(--text-muted);
border-top: 1px solid var(--border);
margin-top: 30px;
}
@media print {
body {
background: white;
padding: 0;
}
.document-container {
box-shadow: none;
border-radius: 0;
}
.section {
page-break-inside: avoid;
}
}
@media (max-width: 768px) {
.document-body {
padding: 25px 20px;
}
.document-header {
padding: 30px 20px;
}
.comparison-grid {
grid-template-columns: 1fr;
}
.stats-grid {
grid-template-columns: 1fr;
}
.header-top {
flex-direction: column;
gap: 15px;
}
.doc-meta {
text-align: center;
}
}
</style>
</head>
<body>
<div class="document-container">
<header class="document-header">
<div class="header-top">
<div class="company-badge">
<div class="company-logo"></div>
</div>
<div class="doc-meta">
<div>شماره مستند: AZ-1405-001</div>
<div>نسخه: ۱.۰</div>
<div>تاریخ تهیه: آبان ۱۴۰۵</div>
<div>طبقه‌بندی: محرمانه</div>
</div>
</div>
<div class="document-title"> <span class="label">TECHNICAL GUIDE & ANALYSIS</span>
<h1>راهنمای جامع Azure API و توسعه برنامه</h1>
<h2>از مفاهیم پایه تا افزودن قابلیت سفارشی به Azure</h2>
</div>
</header>
<div class="document-body">
<div class="intro-text"> <strong>همکار محترم،</strong><br> این مستند با هدف توانمندسازی تیم فنی شرکت
<strong>رایان پرداز کاوش Azure</strong> در استفاده از APIهای Azure و توسعه برنامه‌های قابل اجرا در این
پلتفرم تدوین شده است. با توجه به اینکه سیستم مدیریت منابع و پروژه‌های شرکت بر بستر Azure است، درک عمیق
APIها و الگوهای توسعه، کلید یکپارچه‌سازی مؤثر، خودکارسازی فرآیندها و افزودن قابلیت‌های سفارشی به محیط
Azure است. این راهنما از مفاهیم پایه REST API آغاز و تا الگوهای عملی توسعه و افزونه‌نویسی ادامه می‌یابد.
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۱</div>
<div class="section-title">
<h3>مبانی Azure REST API</h3>
<div class="subtitle">Azure REST API Fundamentals</div>
</div>
</div>
<div class="section-content">
<p>APIهای REST (Representational State Transfer) نقاط پایانی سرویس‌هایی هستند که مجموعه‌ای از عملیات
HTTP (متدها) را برای ارائه، ایجاد، بازیابی، به‌روزرسانی یا حذف دسترسی به منابع سرویس پشتیبانی
می‌کنند. در Azure، تقریباً تمام عملیات مدیریتی و داده‌ای از طریق REST API قابل انجام است. این
APIها پایه و اساس SDKها، پورتال Azure، CLI و ابزارهای اتوماسیون هستند.</p>
<p>یک جفت درخواست/پاسخ REST API از پنج مؤلفه اصلی تشکیل می‌شود: <strong>URI درخواست</strong> (شامل
طرح، میزبان، مسیر منبع و رشته پرس‌وجو)، <strong>متد HTTP</strong> (GET، POST، PUT، DELETE و
غیره)، <strong>هدرهای درخواست</strong> (مانند Authorization و Content-Type)، <strong>بدنه
درخواست</strong> (اختیاری) و <strong>پاسخ</strong> (شامل کد وضعیت، هدرها و بدنه).</p>
<h4 style="margin-top: 25px; color: var(--primary); font-size: 16px;">دو دسته اصلی API در Azure:
</h4>
<div class="comparison-grid">
<div class="comparison-card">
<h4>Azure Resource Manager (ARM) API</h4>
<ul>
<li><span>Base URL</span> <span class="value">https://management.azure.com/</span></li>
<li><span>کاربرد</span> <span class="value">مدیریت منابع (VM، Storage، Network و
غیره)</span></li>
<li><span>احراز هویت</span> <span class="value">Microsoft Entra ID</span></li>
<li><span>نسخه API</span> <span class="value">الزامی در query string</span></li>
</ul>
</div>
<div class="comparison-card">
<h4>Microsoft Graph API</h4>
<ul>
<li><span>Base URL</span> <span class="value">https://graph.microsoft.com/v1.0/</span>
</li>
<li><span>کاربرد</span> <span class="value">هویت، دسترسی، کاربران، گروه‌ها</span></li>
<li><span>احراز هویت</span> <span class="value">Microsoft Entra ID</span></li>
<li><span>نسخه API</span> <span class="value">در URL مسیر</span></li>
</ul>
</div>
</div>
<p>به عنوان مثال، برای لیست کردن گروه‌های منابع یک اشتراک، درخواست GET زیر به ARM API ارسال می‌شود:
</p>
<div class="highlight-box"
style="direction: ltr; text-align: left; font-family: monospace; font-size: 13px;"> GET
https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups?api-version=2021-04-01
</div>
<p>یا برای ایجاد یک گروه منابع جدید، از متد PUT استفاده می‌شود:</p>
<div class="highlight-box"
style="direction: ltr; text-align: left; font-family: monospace; font-size: 13px;"> PUT
https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}?api-version=2021-04-01
</div>
<div class="info-box"> <strong>💡 نکته کلیدی:</strong> در Azure REST API، پارامتر <code
style="direction: ltr; display: inline-block;">api-version</code> الزامی است و نسخه قرارداد
API را مشخص می‌کند. استفاده از نسخه‌های پایدار (stable) برای محیط عملیاتی توصیه می‌شود. </div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۲</div>
<div class="section-title">
<h3>احراز هویت و مجوزدهی</h3>
<div class="subtitle">Authentication & Authorization</div>
</div>
</div>
<div class="section-content">
<p>برای فراخوانی Azure REST API، ابتدا باید یک <strong>توکن دسترسی (Access Token)</strong> از
Microsoft Entra ID (سابقاً Azure Active Directory) دریافت کنید. این توکن در هدر <code
style="direction: ltr; display: inline-block;">Authorization</code> با الگوی <code
style="direction: ltr; display: inline-block;">Bearer {access-token}</code> قرار می‌گیرد.
</p>
<table class="styled-table">
<thead>
<tr>
<th>روش احراز هویت</th>
<th>سناریوی استفاده</th>
<th>نیاز به مدیریت Secret</th>
<th>توصیه</th>
</tr>
</thead>
<tbody>
<tr>
<td>Managed Identity</td>
<td>برنامه‌های در حال اجرا روی Azure (VM، App Service، Functions، Container Apps)</td>
<td style="color: var(--success); font-weight: 600;">خیر</td>
<td>✅ اولویت اول</td>
</tr>
<tr>
<td>Service Principal</td>
<td>برنامه‌های خارج از Azure یا CI/CD</td>
<td style="color: var(--warning); font-weight: 600;">بله (Client Secret یا Certificate)
</td>
<td>گزینه جایگزین</td>
</tr>
<tr>
<td>Workload Identity</td>
<td>Kubernetes (AKS) با فدراسیون هویت</td>
<td style="color: var(--success); font-weight: 600;">خیر</td>
<td>برای AKS</td>
</tr>
<tr>
<td>Azure CLI</td>
<td>توسعه محلی و اسکریپت‌های تعاملی</td>
<td style="color: var(--success); font-weight: 600;">خیر</td>
<td>فقط برای توسعه</td>
</tr>
</tbody>
</table>
<div class="success-box"> <strong>✓ توصیه امنیتی:</strong> برای برنامه‌هایی که در Azure اجرا
می‌شوند، همیشه از <strong>Managed Identity</strong> استفاده کنید. این روش به شما اجازه می‌دهد
بدون قرار دادن هیچ رمز یا کلیدی در کد، به منابع Azure دسترسی امن داشته باشید. Azure به طور
خودکار هویت را مدیریت می‌کند. </div>
<p>برای دریافت توکن با استفاده از Managed Identity روی یک ماشین مجازی Azure، می‌توانید از سرویس IMDS
(Instance Metadata Service) استفاده کنید:</p>
<div class="highlight-box"
style="direction: ltr; text-align: left; font-family: monospace; font-size: 13px;"> curl
'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fmanagement.azure.com%2F'
-H Metadata:true </div>
<p>پس از دریافت توکن، آن را در هدر درخواست به ARM API قرار دهید:</p>
<div class="highlight-box"
style="direction: ltr; text-align: left; font-family: monospace; font-size: 13px;"> curl
https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups?api-version=2021-04-01
-H "Authorization: Bearer {access-token}" </div>
<div class="warning-box"> <strong>⚠️ هشدار:</strong> هرگز کلیدها یا توکن‌ها را در کد منبع یا مخازن
عمومی قرار ندهید. از Azure Key Vault برای مدیریت اسرار استفاده کنید. </div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۳</div>
<div class="section-title">
<h3>Azure SDKها و کتابخانه‌های کلاینت</h3>
<div class="subtitle">Azure SDK & Client Libraries</div>
</div>
</div>
<div class="section-content">
<p>در حالی که می‌توانید مستقیماً با REST API کار کنید، مایکروسافت <strong>Azure SDK</strong>هایی را
برای زبان‌های برنامه‌نویسی مختلف ارائه می‌دهد که یک رابط بومی و تایپ‌شده برای استفاده از
سرویس‌های Azure فراهم می‌کنند. این SDKها مدیریت خطاها، تلاش مجدد (Retry)، صفحه‌بندی و احراز هویت
را خودکار می‌کنند و استفاده از APIها را بسیار ساده‌تر می‌سازند.</p>
<table class="styled-table">
<thead>
<tr>
<th>زبان / چارچوب</th>
<th>حداقل نسخه پشتیبانی‌شده</th>
<th>مخزن رسمی SDK</th>
<th>نمونه کتابخانه Storage</th>
</tr>
</thead>
<tbody>
<tr>
<td>.NET (C#)</td>
<td>.NET 6+</td>
<td>Azure/azure-sdk-for-net</td>
<td>Azure.Storage.Blobs</td>
</tr>
<tr>
<td>Java</td>
<td>Java 8+</td>
<td>Azure/azure-sdk-for-java</td>
<td>azure-storage-blob</td>
</tr>
<tr>
<td>Python</td>
<td>Python 3.7+</td>
<td>Azure/azure-sdk-for-python</td>
<td>azure-storage-blob</td>
</tr>
<tr>
<td>JavaScript / Node.js</td>
<td>Node.js 14 LTS+</td>
<td>Azure/azure-sdk-for-js</td>
<td>@azure/storage-blob</td>
</tr>
<tr>
<td>Go</td>
<td>Go 1.18+</td>
<td>Azure/azure-sdk-for-go</td>
<td>azblob</td>
</tr>
</tbody>
</table>
<div class="info-box"> <strong>💡 نکته:</strong> SDKها بر پایه همان REST API ساخته شده‌اند. اگر SDK
برای سرویس مورد نظر شما وجود نداشت یا به قابلیت خاصی نیاز داشتید که در SDK پوشش داده نشده است،
همیشه می‌توانید مستقیماً با REST API ارتباط برقرار کنید. </div>
<p>علاوه بر SDKهای داده‌ای، <strong>کتابخانه‌های مدیریتی (Management Libraries)</strong> نیز وجود
دارند که برای مدیریت منابع Azure (مانند ایجاد VM، پیکربندی شبکه و غیره) از طریق ARM API استفاده
می‌شوند. این کتابخانه‌ها معمولاً با پیشوند <code
style="direction: ltr; display: inline-block;">azure-mgmt-</code> (در Python) یا <code
style="direction: ltr; display: inline-block;">Azure.ResourceManager</code> (در .NET) شناخته
می‌شوند.</p>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۴</div>
<div class="section-title">
<h3>Azure API Management (APIM)</h3>
<div class="subtitle">API Gateway, Security & Lifecycle</div>
</div>
</div>
<div class="section-content">
<p>هنگامی که APIهای خود را توسعه می‌دهید یا از APIهای Azure استفاده می‌کنید، یک <strong>دروازه API
(API Gateway)</strong> مانند Azure API Management لایه‌ای حیاتی برای امنیت، کنترل ترافیک و
مدیریت چرخه عمر API فراهم می‌کند. APIM بین مصرف‌کنندگان API و سرویس‌های بک‌اند قرار می‌گیرد و به
جای پیاده‌سازی جداگانه احراز هویت، محدودیت نرخ و لاگ‌گیری در هر سرویس، این رفتارها را یک‌بار در
دروازه پیکربندی و به‌صورت یکنواخت اعمال می‌کند.</p>
<h4 style="margin-top: 20px; color: var(--primary); font-size: 16px;">قابلیت‌های کلیدی APIM:</h4>
<ul style="padding-right: 20px; margin-top: 10px;">
<li style="margin-bottom: 8px;"><strong>امنیت:</strong> احراز هویت OAuth 2.0، اعتبارسنجی کلید
اشتراک، فیلتر IP، ادغام با Key Vault</li>
<li style="margin-bottom: 8px;"><strong>محدودیت نرخ و سهمیه:</strong> کنترل تعداد درخواست‌ها بر
اساس اشتراک، کلید یا IP</li>
<li style="margin-bottom: 8px;"><strong>نسخه‌بندی و بازبینی:</strong> مدیریت نسخه‌های مختلف API
برای سازگاری با تغییرات شکستنی (Breaking Changes) و استفاده از Revisions برای تغییرات
غیرشکستنی</li>
<li style="margin-bottom: 8px;"><strong>تبدیل درخواست/پاسخ:</strong> تغییر هدرها، بدنه و URL
بدون تغییر کد بک‌اند</li>
<li style="margin-bottom: 8px;"><strong>کش:</strong> بهبود عملکرد و کاهش بار بک‌اند</li>
<li style="margin-bottom: 8px;"><strong>پورتال توسعه‌دهنده:</strong> مستندات تعاملی و آزمون API
</li>
</ul>
<div class="success-box"> <strong>✓ بهترین روش:</strong> برای تغییرات شکستنی (Breaking Changes) از
<strong>Versions</strong> استفاده کنید و برای تغییرات غیرشکستنی از <strong>Revisions</strong>.
محدودیت نرخ را با سیاست <code
style="direction: ltr; display: inline-block;">rate-limit-by-key</code> بر اساس IP یا شناسه
کاربر تنظیم کنید و همیشه آن را بعد از سیاست کش قرار دهید. </div>
<div class="quote-box">
<p>APIM به عنوان یک نقطه اجرای سیاست (Policy Enforcement Point) عمل می‌کند. به جای ساختن احراز
هویت، محدودیت نرخ و لاگ‌گیری در هر میکروسرویس به صورت جداگانه، این رفتارها را یک‌بار در
دروازه پیکربندی می‌کنید و به‌صورت یکنواخت روی ده‌ها یا صدها API اعمال می‌کنید.</p>
<div class="source">— ZapAI, Azure API Management Best Practices (2026)</div>
</div>
<p>برای شروع با APIM در پورتال Azure، یک منبع <strong>API Management</strong> ایجاد کنید، سپس APIهای
خود را (از طریق OpenAPI، WSDL یا تعریف دستی) وارد کرده و سیاست‌های مورد نیاز را اعمال کنید.</p>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۵</div>
<div class="section-title">
<h3>توسعه برنامه در Azure: Azure Functions</h3>
<div class="subtitle">Serverless Event-Driven Compute</div>
</div>
</div>
<div class="section-content">
<p>Azure Functions یک سرویس محاسباتی بدون سرور (Serverless) است که به شما امکان می‌دهد کد رویدادمحور
را بدون فراهم‌کردن یا مدیریت زیرساخت اجرا کنید. اجرای توابع توسط رویدادهایی مانند درخواست‌های
HTTP، پیام‌های صف، تایمرها یا تغییرات در Storage فعال می‌شود و به‌صورت خودکار بر اساس تقاضا
مقیاس می‌گیرد.</p>
<h4 style="margin-top: 20px; color: var(--primary); font-size: 16px;">مفاهیم کلیدی Azure Functions:
</h4>
<div class="stats-grid">
<div class="stat-card">
<div class="stat-value">Trigger</div>
<div class="stat-label">رویدادی که اجرای تابع را آغاز می‌کند (HTTP، Timer، Queue، Blob و
غیره)</div>
</div>
<div class="stat-card">
<div class="stat-value">Binding</div>
<div class="stat-label">اتصال ورودی/خروجی به سرویس‌های Azure بدون کد اضافی</div>
</div>
<div class="stat-card">
<div class="stat-value">Scale</div>
<div class="stat-label">مقیاس خودکار بر اساس تعداد رویدادها</div>
</div>
</div>
<p>برای توسعه Azure Functions، می‌توانید از <strong>Visual Studio Code</strong> همراه با
<strong>Azure Functions Core Tools</strong> استفاده کنید. این ابزارها امکان اجرا و دیباگ محلی
توابع را فراهم می‌کنند و سپس می‌توانید کد را در پورتال Azure یا از طریق CI/CD مستقر کنید.</p>
<h4 style="margin-top: 25px; color: var(--primary); font-size: 16px;">مدل برنامه‌نویسی Python (نسخه
۲):</h4>
<p>در مدل جدید Python (نسخه 2.x)، از رویکرد مبتنی بر دکوراتور برای تعریف تریگرها و بایندینگ‌ها
مستقیماً در فایل <code style="direction: ltr; display: inline-block;">function_app.py</code>
استفاده می‌شود. این مدل برای برنامه‌های جدید توصیه می‌شود.</p>
<div class="highlight-box"
style="direction: ltr; text-align: left; font-family: monospace; font-size: 13px;"> import
azure.functions as func<br><br> app = func.FunctionApp()<br><br> @app.route(route="hello")<br>
def hello(req: func.HttpRequest) -> func.HttpResponse:<br> &nbsp;&nbsp;&nbsp;&nbsp;name =
req.params.get('name', 'World')<br> &nbsp;&nbsp;&nbsp;&nbsp;return func.HttpResponse(f"Hello,
{name}!") </div>
<p>برای زبان‌های دیگر نیز SDKها و الگوهای مشابهی وجود دارد. به عنوان مثال، در Node.js از پکیج <code
style="direction: ltr; display: inline-block;">@azure/functions</code> استفاده می‌شود.</p>
<div class="info-box"> <strong>💡 موارد استفاده رایج Azure Functions:</strong> پردازش فایل‌های
آپلودشده در Blob Storage، پاسخ به پیام‌های صف، اجرای وظایف زمان‌بندی‌شده (Cron Jobs)، ساخت
APIهای سبک، و یکپارچه‌سازی رویدادمحور بین سرویس‌ها. </div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۶</div>
<div class="section-title">
<h3>افزودن قابلیت سفارشی به Azure</h3>
<div class="subtitle">Extension Patterns & Custom Functionality</div>
</div>
</div>
<div class="section-content">
<p>بسته به اینکه منظور شما از «افزودن قابلیت به Azure» چیست، چند الگوی اصلی وجود دارد. در ادامه سه
رویکرد عملی و پرکاربرد معرفی می‌شود.</p>
<h4 style="margin-top: 20px; color: var(--primary); font-size: 16px;">الگوی اول: توسعه یک برنامه
میزبانی‌شده در Azure (App Service / Functions)</h4>
<p>اگر می‌خواهید یک برنامه سفارشی بسازید که در محیط Azure اجرا شود و منطق مورد نظر شما را پیاده‌سازی
کند، ساده‌ترین و مستقیم‌ترین راه این است که کد خود را در <strong>Azure App Service</strong>
(برای APIهای وب و برنامه‌های کامل) یا <strong>Azure Functions</strong> (برای منطق رویدادمحور
بدون سرور) مستقر کنید. سپس این برنامه می‌تواند از طریق HTTP یا بایندینگ‌ها با سایر سرویس‌های
Azure ارتباط برقرار کند.</p>
<div class="success-box"> <strong>✓ مثال عملی:</strong> یک Azure Function با تریگر HTTP بسازید که یک
API سفارشی برای مدیریت منابع شرکت ارائه دهد. این تابع می‌تواند با استفاده از Managed Identity به
ARM API متصل شود و عملیات مورد نیاز (مانند ایجاد یا حذف منابع) را انجام دهد. سپس این تابع را از
طریق APIM منتشر کنید تا امنیت و کنترل ترافیک اعمال شود. </div>
<h4 style="margin-top: 25px; color: var(--primary); font-size: 16px;">الگوی دوم: ساخت کانکتور سفارشی
برای Azure Logic Apps</h4>
<p>اگر می‌خواهید قابلیت جدیدی به گردش‌کارهای Azure Logic Apps اضافه کنید (مثلاً اتصال به یک سیستم
داخلی شرکت که کانکتور آماده ندارد)، می‌توانید <strong>کانکتور سفارشی (Custom Connector)</strong>
بسازید. برای Logic Apps مصرفی (Consumption)، کانکتور سفارشی از یک تعریف
<strong>Swagger/OpenAPI</strong> یا <strong>SOAP</strong> ساخته می‌شود. برای Logic Apps
استاندارد (Standard)، می‌توانید از مدل توسعه‌پذیری Azure Functions برای ساخت <strong>کانکتور
داخلی سفارشی (Custom Built-in Connector)</strong> استفاده کنید که عملکرد و یکپارچگی بهتری
دارد.</p>
<div class="info-box"> <strong>💡 نکته:</strong> کانکتورهای داخلی سفارشی برای Logic Apps استاندارد
از همان مدل توسعه‌پذیری استفاده می‌کنند که کانکتورهای داخلی مبتنی بر ارائه‌دهنده سرویس
مایکروسافت استفاده می‌کنند. این کانکتورها در همان فرآیند runtime اجرا می‌شوند و تأخیر کمتری
دارند. </div>
<h4 style="margin-top: 25px; color: var(--primary); font-size: 16px;">الگوی سوم: گسترش Azure
Developer CLI (azd) با Extension</h4>
<p>اگر هدف شما افزودن قابلیت به <strong>ابزارهای توسعه Azure</strong> (مانند azd) است، می‌توانید یک
<strong>Extension</strong> برای Azure Developer CLI بسازید. این Extension‌ها می‌توانند
قابلیت‌های جدیدی مانند دستورات سفارشی، ارائه‌دهندگان هدف استقرار سفارشی (Service Target
Providers) و کنترل‌کننده‌های رویداد پروژه را ثبت کنند. این رویکرد برای تیم‌هایی مناسب است که
می‌خواهند گردش‌کارهای استقرار و مدیریت منابع خود را خودکارسازی کنند.</p>
<table class="styled-table">
<thead>
<tr>
<th>الگو</th>
<th>سناریوی مناسب</th>
<th>میزبان</th>
<th>زبان/ابزار</th>
</tr>
</thead>
<tbody>
<tr>
<td>برنامه میزبانی‌شده (App Service / Functions)</td>
<td>API سفارشی، منطق تجاری، پردازش رویداد</td>
<td>Azure App Service یا Azure Functions</td>
<td>.NET، Java، Python، Node.js و غیره</td>
</tr>
<tr>
<td>کانکتور سفارشی Logic Apps</td>
<td>اتصال به سیستم‌های بدون کانکتور آماده در گردش‌کارها</td>
<td>Logic Apps (Consumption یا Standard)</td>
<td>Swagger/OpenAPI، SOAP، Azure Functions</td>
</tr>
<tr>
<td>Extension برای azd</td>
<td>افزودن دستور یا هدف استقرار سفارشی به CLI</td>
<td>Azure Developer CLI</td>
<td>Go (و سایر زبان‌های پشتیبانی‌شده)</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۷</div>
<div class="section-title">
<h3>مسیر پیشنهادی یادگیری و پیاده‌سازی</h3>
<div class="subtitle">Learning Path & Next Steps</div>
</div>
</div>
<div class="section-content">
<p>برای تسلط عملی بر Azure API و توسعه برنامه، مسیر زیر پیشنهاد می‌شود:</p>
<div class="timeline">
<div class="timeline-item">
<div class="timeline-dot"></div>
<div class="timeline-content">
<h5>گام ۱: تسلط بر REST API و احراز هویت</h5>
<p>با ARM API و Microsoft Graph API تمرین کنید. یک Service Principal یا Managed Identity
ایجاد کنید و با curl یا Postman درخواست‌های ساده (لیست منابع، ایجاد گروه منابع)
ارسال کنید.</p>
</div>
</div>
<div class="timeline-item">
<div class="timeline-dot"></div>
<div class="timeline-content">
<h5>گام ۲: استفاده از SDK در زبان انتخابی</h5>
<p>SDK مناسب (Python، .NET یا Node.js) را نصب کنید و همان عملیات REST را با SDK
پیاده‌سازی کنید. تفاوت‌ها و مزایای SDK را تجربه کنید.</p>
</div>
</div>
<div class="timeline-item">
<div class="timeline-dot"></div>
<div class="timeline-content">
<h5>گام ۳: ساخت اولین Azure Function</h5>
<p>با VS Code و Azure Functions Core Tools یک تابع HTTP Trigger بسازید، آن را محلی اجرا
کنید و سپس در Azure مستقر کنید. با بایندینگ‌ها (مثلاً خروجی به Storage) آشنا شوید.
</p>
</div>
</div>
<div class="timeline-item">
<div class="timeline-dot"></div>
<div class="timeline-content">
<h5>گام ۴: انتشار API از طریق APIM</h5>
<p>یک نمونه APIM ایجاد کنید، Azure Function یا API خود را وارد کنید و سیاست‌های امنیتی و
محدودیت نرخ را اعمال کنید.</p>
</div>
</div>
<div class="timeline-item">
<div class="timeline-dot"></div>
<div class="timeline-content">
<h5>گام ۵: یکپارچه‌سازی با سیستم شرکت</h5>
<p>API سفارشی خود را به سیستم مدیریت منابع و پروژه‌های رایان پرداز کاوش Azure متصل کنید
و گردش‌کارهای خودکار طراحی کنید.</p>
</div>
</div>
</div>
<div class="conclusion-box">
<h3>🎯 جمع‌بندی</h3>
<p>Azure مجموعه‌ای قدرتمند از APIها، SDKها و سرویس‌های محاسباتی ارائه می‌دهد که به شما امکان
می‌دهد برنامه‌های سفارشی بسازید، آن‌ها را در محیط Azure اجرا کنید و قابلیت‌های جدیدی به
اکوسیستم Azure اضافه کنید.</p>
<p>کلید شروع، درک REST API و احراز هویت با Managed Identity است. سپس با Azure Functions و APIM
می‌توانید منطق سفارشی خود را پیاده‌سازی و منتشر کنید.</p>
<div class="highlight"> <strong>💎 ارزش پیشنهادی برای شرکت:</strong><br> خودکارسازی فرآیندهای
مدیریت منابع + یکپارچه‌سازی سیستم‌ها + افزودن قابلیت‌های سفارشی + امنیت و کنترل متمرکز
</div>
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۸</div>
<div class="section-title">
<h3>منابع و مستندات رسمی</h3>
<div class="subtitle">Official References</div>
</div>
</div>
<div class="section-content">
<ul class="reference-list">
<li> <strong>Microsoft Learn — Azure REST API Reference</strong> مستندات جامع تمام APIهای Azure،
شامل توضیحات، پارامترها و نمونه‌های درخواست. <div class="ref-source">
https://learn.microsoft.com/rest/api/azure/</div>
</li>
<li> <strong>Microsoft Learn — Azure Resource Manager REST API</strong> مرجع API مدیریت منابع
Azure (ARM). <div class="ref-source">https://learn.microsoft.com/rest/api/resources/</div>
</li>
<li> <strong>Microsoft Learn — Microsoft Graph API Overview</strong> مستندات Microsoft Graph
برای دسترسی به داده‌های هویت و بهره‌وری. <div class="ref-source">
https://learn.microsoft.com/graph/api/overview</div>
</li>
<li> <strong>Microsoft Learn — Managed Identities for Azure Resources</strong> راهنمای استفاده
از Managed Identity برای احراز هویت بدون رمز. <div class="ref-source">
https://learn.microsoft.com/entra/identity/managed-identities-azure-resources/</div>
</li>
<li> <strong>Microsoft Learn — Azure Functions Developer Guide</strong> راهنمای جامع توسعه Azure
Functions در زبان‌های مختلف. <div class="ref-source">
https://learn.microsoft.com/azure/azure-functions/functions-reference-python</div>
</li>
<li> <strong>Microsoft Learn — Azure API Management Documentation</strong> مستندات APIM شامل
ایجاد، پیکربندی سیاست‌ها و نسخه‌بندی. <div class="ref-source">
https://learn.microsoft.com/azure/api-management/</div>
</li>
<li> <strong>Microsoft Learn — Custom Connectors for Azure Logic Apps</strong> راهنمای ساخت
کانکتور سفارشی برای Logic Apps. <div class="ref-source">
https://learn.microsoft.com/connectors/custom-connectors/</div>
</li>
<li> <strong>GitHub — Azure SDKs</strong> مخازن رسمی SDKهای Azure برای .NET، Java، Python،
JavaScript و Go. <div class="ref-source">https://github.com/Azure</div>
</li>
</ul>
</div>
</div>
<div class="page-info"> این مستند محرمانه بوده و صرفاً جهت استفاده داخلی تیم فنی شرکت رایان پرداز کاوش Azure
تهیه شده است. </div>
</div>
<footer class="document-footer">
<div class="footer-brand">تدوین: تیم فنی رایان پرداز کاوش Azure</div>
<div class="footer-divider"></div>
<div>تاریخ تهیه: آبان ۱۴۰۵ &nbsp;|&nbsp; نسخه: ۱.۰ &nbsp;|&nbsp; طبقه‌بندی: محرمانه</div>
</footer>
</div>
</body>
</html>