问题描述
我有一个经典的 Compute 资源。我需要将一些使用 Azure.Service 模块的旧部署代码移动到 Az,我想知道有没有办法用 Az 或最新的东西来管理它? 我必须上传一些 .cspkg 和一些 .cscfg 文件。还有更多内容,但基本上,这是使用 this cmdlet 和相关的 Set、Get 等完成的。
我使用 Az.Resources 的 cmdlet New-AzResource 创建它:
New-AzResource `
-Location 'location' `
-ResourceGroupName 'rgName' `
-ResourceType 'Microsoft.ClassicCompute/domainNames' `
-ResourceName 'rName' `
-ApiVersion '2018-06-01'
我可以使用哪些 cmdlet 来管理此资源?
解决方法
在您的情况下,您可以使用 Az.CloudService
模块命令上传一些 .cspkg 和一些 .cscfg 文件,使用 New-AzCloudService
和参数 -PackageUrl
和 -ConfigurationUrl
(或-Configuration
).
命令New-AzCloudService
可以Create or update a cloud service
,即New
、Set
操作,要进行Get
操作,使用Get-AzCloudService
命令。>
无论如何,请参阅 here 以了解管理 Microsoft.ClassicCompute/domainNames
即 Cloud service
的所有命令,使用它们取决于您的要求。
更新:
在这种情况下,看起来您无法将命令迁移到 Az
模块,Az.CloudService
用于基于 ARM(Azure 资源管理器)的新 Cloud Service(extended support),它在预览版,见Deploy a Cloud Service (extended support) using Azure PowerShell,有些功能可能不支持,我认为错误是由这个引起的。
您使用的是云服务(经典),它基于 ASM(Azure 服务管理),新的 Az
模块仅用于 ARM 资源。
所以在你的情况下,你可能需要继续使用Azure.Service
模块,或者你可以将ASM迁移到ARM,即Cloud Service(classic)
到Cloud Service(extended support)
,参见Migration to Azure Resource Manager
,但不建议您在生产环境中使用它,因为它处于预览状态。