In this case, when the storage account name is known and independent of the resource group (for example, uniqueString (resourceGroup (). Id)), you can simply use a longer form for resourceId () . The full form looks like this:
resourceId([subscriptionId], [resourceGroupName], resourceType, resourceName1, [resourceName2]...)
therefore, we can optionally provide the names subscriptionId and resourceGroupName.
listKeys(resourceId(parameters('ResourceGroupAName'), 'Microsoft.Storage/storageAccounts', variables('ccPaymentStorageName'))
If he was in a different subscription, you can also specify a subscription.
listKeys(resourceId(parameters('SubscriptionId'), parameters('ResourceGroupAName'), 'Microsoft.Storage/storageAccounts', variables('ccPaymentStorageName'))
If the storage account name depends on a resource group, for example
"storageName": "[concat('mystorage', uniqueString(resourceGroup().id))]"
then you will also need to always run the template that creates this account and display the repository name and resource group or look for a way to link to another resource group to get an identifier so that the name can be recreated.
I was able to use something like this to "recreate" the resource group identifier so that I could create my own repository account name.
"otherResourceGroupId": "[concat(subscription().id, '/resourceGroups/', parameters('ResourceGroupName'))]"
Then I can use this to generate the name accordingly:
"storageAccountName": "[concat('mystorage', uniqueString(variables('otherResourceGroupId')))]"