8

I'm trying to implement partner tagging of Azure resources by adding a partner product GUID to the User-Agent header when creating resources via the Resource Manager API, but it doesn't have any visible effect. I checked the ARM template of a "tagged" resource, but the GUID is not there. Verification method described in the article also gives negative results.

Does it work for anyone?

Here's the Powershell code based on the above guide that reproduces the issue:

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.

Note: the GUID above is random - not a real one. It should be replaced with a registered partner GUID.

2 Answers2

2

When tagging resources for attribution during deployment, there isn't anything visible on the resource itself that indicates the association, it's an internal implementation.

If your goal is to verify that the code you've written is working correctly (such that the resource will be properly attributed) there's currently no way to do this externally for the UserAgent method - we can only do it internally. You can verify for a template deployment using the script in the doc you linked to, but that will only work for template deployments not, API calls (TF, SDK, etc).

You won't see anything in the Partner Portal unless 1) the GUID is registered and 2) there is billable usage for the resource.

All that said - I did a quick peek in the logs and I do see some resources provisioned with 3fd1a53d-3ef0-4111-8a66-211ed6470935 in the userAgent.

That help?

bmoore-msft
  • 6,629
  • 16
  • 20
0

This is not a working example and does not fit into comments.

The line Get-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -Name $partnerID tries to search for a deployment with name as $partnerID in the resource group, but New-AzVM might be using a name like virtualmachine-<some_random_id>. To use the command like you are trying, the deployment must have the same name. This name can be given in ARM template or using New-AzResourceGroupDeployment command.

I do not know much about partner tagging, but the command normally does not work like you are trying to use it.

Also, if your $productID value stays same for multiple deployments, but using same name for deployments will overwrite the previous deployments (basically you loose deployment history only). I suggest to check the resource group in portal and get the deployment name, or use Get-AzResourceGroupDeployment without Name parameter to get all deployments and find the related deployment as per time of deployment.

I would also point out that you seem to be using Resource Manager API process, but documentation states following for verification method -

You can use the script to verify that the GUID is successfully added to your Resource Manager template. The script doesn't apply to Resource Manager API or Terraform deployments.

Your code might be working, but I do not see a clear verification method for while using User-Agent method. (Probably check the reports in Partner Center Analyze dashboard as per documentation?). Since ARM templates seem to have a verification method, you can try using that.

  • The method with user agent is suggested in the article:Tag a deployment by using the Azure PowerShell If you deploy resources via Azure PowerShell, append your GUID by using the following method: PowerShell Copy [Microsoft.Azure.Common.Authentication.AzureSession]::ClientFactory.AddUserAgent("pid-eb7927c8-dd66-43e1-b0cf-c346a422063 – Ruslan Mukhamedov Feb 26 '20 at 11:21
  • Yes, I saw that, but do not see a clear verification method when using User-Agent method mentioned in the documentation. If you already know a verification method, I suggest you use that. The `Get-AzResourceGroupDeployment` command as you have written in code is expected to fail, since you are trying to get a deployment with name as your `productID` without creating it first. – stackoverflowusrone Feb 26 '20 at 11:25
  • Try checking your report as mentioned in same article and see if intended results are present.- https://docs.microsoft.com/en-us/azure/marketplace/azure-partner-customer-usage-attribution#report – stackoverflowusrone Feb 26 '20 at 11:29