我正在尝试通过在通过Resource Manager API创建资源时将合作伙伴产品 GUID 添加到 User-Agent 标头来实现Azure 资源的合作伙伴标记,但它没有任何可见的效果。我检查了“标记”资源的 ARM 模板,但 GUID 不存在。文章中描述的验证方法也给出了否定的结果。
它对任何人都有效吗?
这是基于上述指南的 Powershell 代码,它重现了该问题:
Install-Module -Name Az -AllowClobber -Scope CurrentUser # installs Azure Powerhsell module
$partnerID = "pid-3fd1a53d-3ef0-4111-8a66-211ed6470935" # Product GUID
$VMLocalAdminUser = "partneridtest" # test VM username
$VMLocalAdminSecurePassword = ConvertTo-SecureString "Pa$$word123" -AsPlainText -Force # test VM password
$resourceGroupName=[guid]::NewGuid().ToString() # randomly generated resource group name
Import-Module -Name Az # import Azure Powerhsell module
[Microsoft.Azure.Common.Authentication.AzureSession]::ClientFactory.AddUserAgent($partnerID) # add user-agent for partner tracking
Connect-AzAccount # login to Azure
New-AzResourceGroup -Name $resourceGroupName -Location eastus # create a resource group
Write-Host Resource group name $resourceGroupName
$vmParams = @{
ResourceGroupName = $resourceGroupName
Name = 'PartnerIdTest1'
Location = 'eastus'
ImageName = 'Win2016Datacenter'
PublicIpAddressName = 'partnerIdTestPublicIp'
Credential = New-Object System.Management.Automation.PSCredential ($VMLocalAdminUser, $VMLocalAdminSecurePassword)
OpenPorts = 3389
}
$newVM1 = New-AzVM @vmParams # create a test VM (should be tagged with the partner product guid)
Get-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -Name $partnerID # fails with Get-AzResourceGroupDeployment : Deployment 'pid-3fd1a53d-3ef0-4111-8a66-211ed6470935' could not be found.
注意:上面的 GUID 是随机的 - 不是真实的。应将其替换为已注册的合作伙伴 GUID。