Rus*_*dov 8 azure azure-resource-manager azure-rest-api
在通过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.
Run Code Online (Sandbox Code Playgroud)
注意:上面的 GUID 是随机的 - 不是真实的。它应该替换为注册的合作伙伴 GUID。
在部署期间标记资源的归因时,资源本身没有任何可见的内容表明关联,它是内部实现。
如果您的目标是验证您编写的代码是否正常工作(以便正确归属资源),则当前无法在 UserAgent 方法的外部执行此操作 - 我们只能在内部执行此操作。您可以使用链接到的文档中的脚本验证模板部署,但这仅适用于模板部署,不适用于 API 调用(TF、SDK 等)。
您不会在合作伙伴门户中看到任何内容,除非 1) GUID 已注册并且 2) 资源的使用情况是可计费的。
话虽如此,我快速浏览了日志,确实看到了 userAgent 中使用 3fd1a53d-3ef0-4111-8a66-211ed6470935 配置的一些资源。
这种帮助?
| 归档时间: |
|
| 查看次数: |
360 次 |
| 最近记录: |