如何按名称测试Azure服务是否存在?

时间:2016-01-18 00:59:54

标签: powershell azure azure-powershell

例如,我将在PowerShell ISE中使用此功能(具有管理员权限),per the documentation:

Test-AzureName –Service "MyNameService1"

预期结果:

此命令测试以查看" MyNameService1"是现有的Microsoft Azure云服务名称。

实际结果:

Test-AzureName : Could not load file or assembly 'Microsoft.ServiceBus, Version=2.3.0.0, Culture=neutral, 
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
At line:1 char:1
+ Test-AzureName –Service "MyNameService1"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Test-AzureName], FileNotFoundException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.CloudService.TestAzureNameCommand

我只是不明白这告诉我什么,特别是因为我复制+粘贴文档中的代码。我本来应该在这里安装一些东西吗?

1 个答案:

答案 0 :(得分:0)

您可以使用以下PowerShell检查云环境中是否存在服务。

Get-AzureRmResourceProvider

注意:您需要安装Azure PowerShell 1.0.0或更高版本。

在使用此命令之前,您需要登录Azure云。

Login-AzureRmAccount

您将获得类似于此的输出:

ProviderNamespace               RegistrationState ResourceTypes                                                                                          Locations
-----------------               ----------------- -------------                                                                                          ---------
Microsoft.AppService            Registered        {apiapps, appIdentities, gateways, deploymenttemplates...}                                             {East US, West US, South Central US, North Europe...}
Microsoft.Backup                Registered        {BackupVault}                                                                                          {West US, East US, North Europe, West Europe...}
Microsoft.Batch                 Registered        {batchAccounts, operations, locations, locations/quotas}                                               {West Europe, East US, East US 2, West US...}
Microsoft.ClassicCompute        Registered        {domainNames, checkDomainNameAvailability, domainNames/slots, domainNames/slots/roles...}              {East Asia, Southeast Asia, East US, East US 2...}
Microsoft.ClassicNetwork        Registered        {virtualNetworks, reservedIps, quotas, gatewaySupportedDevices...}                                     {East Asia, Southeast Asia, East US, East US 2...}
Microsoft.ClassicStorage        Registered        {storageAccounts, quotas, checkStorageAccountAvailability, storageAccounts/services...}                {East Asia, Southeast Asia, East US, East US 2...}
Microsoft.Compute               Registered        {availabilitySets, virtualMachines, virtualMachines/extensions, virtualMachines/diagnosticSettings...} {East US, East US 2, West US, Central US...}
microsoft.insights              Registered        {components, webtests, queries, alertrules...}                                                         {Central US, West US, East US, North Europe...}
Microsoft.MobileEngagement      Registered        {appcollections, appcollections/apps, checkappcollectionnameavailability, supportedplatforms}          {Central US, North Europe}
Microsoft.Network               Registered        {virtualNetworks, publicIPAddresses, networkInterfaces, loadBalancers...}                              {West US, East US, North Europe, West Europe...}
Microsoft.OperationalInsights   Registered        {workspaces, storageInsightConfigs, linkTargets, operations}                                           {East US, West Europe}
Microsoft.Scheduler             Registered        {jobcollections, operations}                                                                           {North Central US, South Central US, North Europe, West Europe...}
Microsoft.Sql                   Registered        {operations, locations, locations/capabilities, checkNameAvailability...}                              {West Europe, South Central US, East US 2, Central US...}
Microsoft.Storage               Registered        {storageAccounts, operations, usages, checkNameAvailability...}                                        {East US, East US 2, East US 2 (Stage), West US...}
Microsoft.Web                   Registered        {sites/extensions, sites/slots/extensions, sites/instances, sites/slots/instances...}                  {Brazil South, East Asia, East US, Japan East...}
Microsoft.ADHybridHealthService Registered        {services, addsservices, configuration, operations...}                                                 {West US}
Microsoft.Authorization         Registered        {roleAssignments, roleDefinitions, classicAdministrators, permissions...}                              {}
Microsoft.Features              Registered        {features, providers}                                                                                  {}
Microsoft.Resources             Registered        {subscriptions, subscriptions/providers, subscriptions/operationresults, resourceGroups...}            {Central US, East Asia, Southeast Asia, East US...}
microsoft.support               Registered        {operations, supporttickets}                                                                           {North Central US, South Central US, Central US, West Europe...}
microsoft.visualstudio          Registered        {account, account/project}                                                                             {North Central US, South Central US, East US, West US...}

每个ProviderNamespace对应一个大型服务,您可以使用以下命令获取命名空间中的详细信息:

Get-AzureRmResourceProvider -ProviderNamespace Microsoft.AppService

注意:此命令将为您提供AppService提供的所有资源类型。

此列表中未显示某些服务。我不知道为什么。例如:

Get-AzureRmResourceProvider -ProviderNamespace Microsoft.HDInsight

Microsoft.HDInsight不在列表中。

您可以在Get-AzureRmResourceProvider

获得更多