Hi everyone. Does anyone know if it’s possible to ...
# azure
p
Hi everyone. Does anyone know if it’s possible to look up resources from another Azure subscription than the one currently being deployed to? For example, we use code like this to find a shared key vault:
Copy code
// Get a reference to our centralized key vault service which lives
// in another resource group. The key vault service itself is not created or maintained
// by this program.
var keyVault =
  Output.Create(GetVault.InvokeAsync(
    new GetVaultArgs()
    {
      ResourceGroupName = sharedResourceGroupName,
      VaultName = sharedKeyVaultName
    }));
Is there any way to do this if that key vault is in a different subscription?
Figured it out. For anyone else wondering, here’s how to do this:
Copy code
var sharedSubscriptionProvider = new Provider(sharedSubscriptionName, new ProviderArgs() { SubscriptionId = sharedSubscriptionId });

var keyVault =
	Output.Create(GetVault.InvokeAsync(
		new GetVaultArgs()
		{
			ResourceGroupName = sharedResourceGroupName,
			VaultName = sharedKeyVaultName
		},
		new InvokeOptions()
		{
			Provider = sharedSubscriptionProvider
		}));