<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://freemwiki.com/index.php?action=history&amp;feed=atom&amp;title=Openai%2F693c317b-1938-8004-a51a-2783d95dfc11</id>
	<title>Openai/693c317b-1938-8004-a51a-2783d95dfc11 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://freemwiki.com/index.php?action=history&amp;feed=atom&amp;title=Openai%2F693c317b-1938-8004-a51a-2783d95dfc11"/>
	<link rel="alternate" type="text/html" href="https://freemwiki.com/index.php?title=Openai/693c317b-1938-8004-a51a-2783d95dfc11&amp;action=history"/>
	<updated>2026-05-28T00:58:42Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.3</generator>
	<entry>
		<id>https://freemwiki.com/index.php?title=Openai/693c317b-1938-8004-a51a-2783d95dfc11&amp;diff=594381&amp;oldid=prev</id>
		<title>Lukegao: by freem.ai...</title>
		<link rel="alternate" type="text/html" href="https://freemwiki.com/index.php?title=Openai/693c317b-1938-8004-a51a-2783d95dfc11&amp;diff=594381&amp;oldid=prev"/>
		<updated>2025-12-13T05:25:34Z</updated>

		<summary type="html">&lt;p&gt;by freem.ai...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
{{DISPLAYTITLE:Cross-tenant app access}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;This conversation was exported from ChatGPT&amp;#039;&amp;#039;&amp;lt;ref&amp;gt;{{cite web|title=Cross-tenant app access|url=https://chatgpt.com/share/693c317b-1938-8004-a51a-2783d95dfc11|publisher=ChatGPT|access-date=2025-12-13}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== gpt-5-1 ==&lt;br /&gt;
=== User: Give an azure ad app registration from one directory key vault secrets officer access to a key vault on another directo… ===&lt;br /&gt;
Give an azure ad app registration from one directory key vault secrets officer access to a key vault on another directory&lt;br /&gt;
&lt;br /&gt;
=== Assistant: To give an Azure AD App Registration from Tenant A Key Vault Secrets Officer access to a Key Vault in Tenant B, you mus… ===&lt;br /&gt;
To give an Azure AD App Registration from Tenant A Key Vault Secrets Officer access to a Key Vault in Tenant B, you must do cross-tenant service principal assignment + Key Vault RBAC.&lt;br /&gt;
Here is the exact process.&lt;br /&gt;
&lt;br /&gt;
=== ✅ Goal ===&lt;br /&gt;
&lt;br /&gt;
App in Tenant A → Access Key Vault in Tenant B → Role = Key Vault Secrets Officer&lt;br /&gt;
&lt;br /&gt;
=== 🟦 1. Ensure the App Exists in Tenant A ===&lt;br /&gt;
&lt;br /&gt;
You already have an App Registration in Tenant A with an application (client) ID:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;App (client) ID = &amp;lt;APP-ID-A&amp;gt;&lt;br /&gt;
Directory (tenant) ID = &amp;lt;TENANT-A-ID&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 🟪 2. Create a Service Principal for That App in Tenant B ===&lt;br /&gt;
&lt;br /&gt;
Azure AD apps are not automatically known in other tenants.&lt;br /&gt;
You must create a service principal for the foreign app in Tenant B.&lt;br /&gt;
&lt;br /&gt;
You run this in Tenant B:&lt;br /&gt;
&lt;br /&gt;
===== Option A – Azure Portal (simple) =====&lt;br /&gt;
# Go to Azure Portal → Azure AD (Tenant B) → Enterprise Applications&lt;br /&gt;
# Click + New application&lt;br /&gt;
# Select “Create your own application”&lt;br /&gt;
# Choose “Integrate any other application you don’t find in the gallery (non-gallery)”&lt;br /&gt;
# Type the App ID from Tenant A&lt;br /&gt;
# This creates a cross-tenant service principal.&lt;br /&gt;
&lt;br /&gt;
===== Option B – Azure CLI =====&lt;br /&gt;
&lt;br /&gt;
Log in to Tenant B, then run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;az ad sp create --id &amp;lt;APP-ID-A&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If already created, it will tell you.&lt;br /&gt;
&lt;br /&gt;
=== 🟩 3. Assign RBAC Role on the Key Vault in Tenant B ===&lt;br /&gt;
&lt;br /&gt;
Use Azure RBAC, not Key Vault access policies (unless you are using legacy).&lt;br /&gt;
&lt;br /&gt;
===== Role to assign: =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;Key Vault Secrets Officer&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Using Azure CLI: =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;az role assignment create \&lt;br /&gt;
  --assignee &amp;lt;APP-ID-A&amp;gt; \&lt;br /&gt;
  --role &amp;quot;Key Vault Secrets Officer&amp;quot; \&lt;br /&gt;
  --scope /subscriptions/&amp;lt;SUB-ID&amp;gt;/resourceGroups/&amp;lt;RG-NAME&amp;gt;/providers/Microsoft.KeyVault/vaults/&amp;lt;KV-NAME&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Using Azure Portal: =====&lt;br /&gt;
# Go to Key Vault → Access Control (IAM)&lt;br /&gt;
# Add role assignment&lt;br /&gt;
# Role: Key Vault Secrets Officer&lt;br /&gt;
# Assign access to: User, group, or service principal&lt;br /&gt;
# Select the service principal for the app (should now appear since you created it in step 2)&lt;br /&gt;
&lt;br /&gt;
=== 🟨 4. Configure Authentication (Tenant B → Tenant A App) ===&lt;br /&gt;
&lt;br /&gt;
When your app authenticates, it uses its own tenant (Tenant A), not Tenant B.&lt;br /&gt;
&lt;br /&gt;
So your client code must authenticate using:&lt;br /&gt;
* Authority = https://login.microsoftonline.com/&amp;lt;TENANT-A-ID&amp;gt;/&lt;br /&gt;
* Client ID = &amp;lt;APP-ID-A&amp;gt;&lt;br /&gt;
* Client Secret / Certificate = created in Tenant A&lt;br /&gt;
&lt;br /&gt;
And resource scope for Key Vault in Tenant B:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;https://vault.azure.net/.default&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example using MSAL:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;app = ConfidentialClientApplication(&lt;br /&gt;
    client_id=&amp;quot;&amp;lt;APP-ID-A&amp;gt;&amp;quot;,&lt;br /&gt;
    client_credential=&amp;quot;&amp;lt;CLIENT-SECRET&amp;gt;&amp;quot;,&lt;br /&gt;
    authority=&amp;quot;https://login.microsoftonline.com/&amp;lt;TENANT-A-ID&amp;gt;&amp;quot;&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
token = app.acquire_token_for_client(scopes=[&amp;quot;https://vault.azure.net/.default&amp;quot;])&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 🟧 5. Test Access ===&lt;br /&gt;
&lt;br /&gt;
Once the service principal exists in Tenant B and RBAC is assigned, the app from Tenant A can call the Key Vault in Tenant B normally.&lt;br /&gt;
&lt;br /&gt;
=== ✅ Summary ===&lt;br /&gt;
&lt;br /&gt;
| Step | Where    | Action                                                |&lt;br /&gt;
| ---- | -------- | ----------------------------------------------------- |&lt;br /&gt;
| 1    | Tenant A | Create the App (already done)                         |&lt;br /&gt;
| 2    | Tenant B | Create a service principal for the foreign app        |&lt;br /&gt;
| 3    | Tenant B | Assign Key Vault Secrets Officer using IAM            |&lt;br /&gt;
| 4    | App code | Authenticate using Tenant A and access KV in Tenant B |&lt;br /&gt;
| 5    | Tenant B | Test retrieval/setting of secrets                     |&lt;br /&gt;
&lt;br /&gt;
If you want, I can also provide:&lt;br /&gt;
* a full Terraform example&lt;br /&gt;
* ARM/Bicep template&lt;br /&gt;
* Azure PowerShell version&lt;br /&gt;
* How to restrict the cross-tenant service principal&lt;br /&gt;
* How to do this with Managed Identity instead&lt;br /&gt;
&lt;br /&gt;
Just tell me!&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:ChatGPT Shares]]&lt;br /&gt;
[[Category:openai]]&lt;/div&gt;</summary>
		<author><name>Lukegao</name></author>
	</entry>
</feed>