如何创建Powershell脚本以创建Azure API管理资源
我试图弄清楚如何从脚本创建API管理资源和API管理API。我相信有两个选择:如何创建Powershell脚本以创建Azure API管理资源,azure,powershell,azure-api-management,api-management,apim,Azure,Powershell,Azure Api Management,Api Management,Apim,我试图弄清楚如何从脚本创建API管理资源和API管理API。我相信有两个选择: 使用AzureRm.ApiManagement中的powershell管理api 为此,我相信要使用的两个命令是: 新AzureRmApiManagement 新AzureRmApiManagementApi 使用管理RESTAPI 为此,我认为要创建资源,您需要使用第一个选项,然后可以通过Invoke RestMethod powershell命令使用以下方法: PUT{subscriptionId}/reso
$ResourceGroupName=""
$sku=""
$name=""
$Location=""
$Organization=""
$AdminEmail=""
$apiName=" #the name of the web API."
$url="" #the URL of the web service that exposes the API.
$path="" #the web API path, which is the last part of the API's public URL and corresponds to the Web API URL suffix field in the admin portal.
#login azure
Connect-AzureRmAccount
#create api management instance with required parameters
New-AzureRmApiManagement -ResourceGroupName $ResourceGroupName -Name $name -Sku $sku -Location $Location -Organization $Organization -AdminEmail $AdminEmail
$ApiMgmtContext =New-AzureRmApiManagementContext -ResourceGroupName $ResourceGroupName -ServiceName $name
#create api
$api = New-AzureRmApiManagementApi -Context $ApiMgmtContext -Name $apiName -ServiceUrl $url -Protocols @("http", "https") -Path $path
#run the command if you do not know product id
Get-AzureRmApiManagementProduct -Context $ApiMgmtContext
#add api to product
Add-AzApiManagementApiToProduct -Context $ApiMgmtContext -ProductId "" -ApiId $api.ApiId
有关Azure API管理powershell命令的更多详细信息,请参阅@JackSojourn这对您合适吗?你有什么更新吗?谢谢吉姆!正是我需要的。