تغيير حجم مثيل الخدمة

يؤدي هذا إلى تغيير حجم البرنامج النصي النموذجي ويضيف منطقة إلى مثيل خدمة إدارة واجهة برمجة التطبيقات.

ملاحظة

تستخدم هذه المقالة الوحدة النمطية Azure Az PowerShell، وهي الوحدة النمطية PowerShell الموصى بها للتفاعل مع Azure. لبدء استخدام الوحدة النمطية Az PowerShell، راجع تثبيت Azure PowerShell. لمعرفة كيفية الترحيل إلى الوحدة النمطية Az PowerShell، راجع ترحيل Azure PowerShell من AzureRM إلى Az.

استخدام Azure Cloud Shell

Azure يستضيف Azure Cloud Shell، بيئة تفاعلية يمكن استخدامها من خلال المستعرض. يمكنك استخدام Bash أو PowerShell مع Cloud Shell للعمل مع خدمات Azure. يمكنك استخدام أوامر Cloud Shell المثبتة مسبقًا لتشغيل التعليمات البرمجية في هذه المقالة دون الحاجة إلى تثبيت أي شيء على البيئة المحلية.

لبدء Azure Cloud Shell:

خيار مثال/ رابط
انقر فوق ⁧⁩جربه⁧⁩ في الزاوية العلوية اليسرى من كتلة التعليمات البرمجية. تحديد ⁧⁩جربه⁧⁩ لا يقوم بنسخ التعليمات البرمجية تلقائيًا إلى Cloud Shell. Screenshot that shows an example of Try It for Azure Cloud Shell.
انتقل إلى ⁧⁩⁧ https://shell.azure.com⁩⁧⁩، أو حدد زر ⁩تشغيل Cloud Shell لفتح Cloud Shell في المتصفح لديك. Screenshot that shows how to launch Cloud Shell in a new window.
حدد زر ⁧⁩Cloud Shell⁧⁩ في شريط القوائم في أعلى اليمين في ⁧⁩مدخل Azure⁧⁩. Screenshot that shows the Cloud Shell button in the Azure portal

لتشغيل التعليمة البرمجية في هذا المقال في Azure Cloud Shell:

  1. ابدأ تشغيل Cloud Shell.

  2. حدد الزر ⁧⁩نسخ⁧⁩ على كتلة التعليمات البرمجية لنسخ التعليمات البرمجية.

  3. ألصق تعليمة البرمجية في جلسة Cloud Shell بتحديد Ctrl+Shift+Vعلى Windows وLunix، أو بتحديد Cmd+Shift+Vعلى macOS.

  4. اكتب ⁧⁩"Enter"⁧⁩ لتشغيل الأمر.

إذا اخترت تثبيت PowerShell واستخدامه محلياً، فإن هذا البرنامج التعليمي يتطلب إصدار الوحدة النمطية Azure PowerShell 1.0 أو إصدار أحدث. قم بتشغيل Get-Module -ListAvailable Az للعثور على الإصدار. إذا كنت بحاجة إلى الترقية، فراجع تثبيت الوحدة النمطية Azure PowerShell. إذا كنت تقوم بتشغيل PowerShell محلياً، تحتاج أيضاً إلى تشغيل Connect-AzAccount لإنشاء اتصال مع Azure.

عينة برنامج نصي

##########################################################
#  Script to create an apim service and scale to premium 
#  with an additional region.
###########################################################

$random = (New-Guid).ToString().Substring(0,8)

#Azure specific details
$subscriptionId = "my-azure-subscription-id"

# Api Management service specific details
$apimServiceName = "apim-$random"
$resourceGroupName = "apim-rg-$random"
$location = "Japan East"
$organisation = "Contoso"
$adminEmail = "admin@contoso.com"

# Set the context to the subscription Id where the cluster will be created
Select-AzSubscription -SubscriptionId $subscriptionId

# Create a resource group.
New-AzResourceGroup -Name $resourceGroupName -Location $location

# Create the Api Management service. Since the SKU is not specified, it creates a service with Developer SKU. 
New-AzApiManagement -ResourceGroupName $resourceGroupName -Name $apimServiceName -Location $location -Organization $organisation -AdminEmail $adminEmail

# Scale master region to 'Premium' 1
$sku = "Premium"
$capacity = 1

# Add new 'Premium' region 1 unit
$additionLocation = Get-ProviderLocations "Microsoft.ApiManagement/service" | Where-Object {$_ -ne $location} | Select-Object -First 1

Get-AzApiManagement -ResourceGroupName $resourceGroupName -Name $apimServiceName |
Update-AzApiManagementRegion -Sku $sku -Capacity $capacity |
Add-AzApiManagementRegion -Location $additionLocation -Sku $sku |
Update-AzApiManagementDeployment

Get-AzApiManagement -ResourceGroupName $resourceGroupName -Name $apimServiceName

تنظيف الموارد

عندما لم تعد هناك حاجة، يمكنك استخدام الأمر Remove- AzResourceGroup لإزالة مجموعة الموارد وجميع الموارد ذات الصلة.

Remove-AzResourceGroup -Name myResourceGroup

الخطوات التالية

لمزيد من المعلومات حول وحدة Azure PowerShell، راجع وثائق Azure PowerShell.

يمكن العثور على عينات Azure PowerShell الإضافية لإدارة Azure API في عينات PowerShell.