{"id":21145364,"url":"https://github.com/jsa2/aadmon2othertenant","last_synced_at":"2025-03-14T13:42:35.832Z","repository":{"id":41244065,"uuid":"455802234","full_name":"jsa2/AADmon2otherTenant","owner":"jsa2","description":null,"archived":false,"fork":false,"pushed_at":"2022-09-02T05:55:50.000Z","size":39,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-21T07:27:22.636Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsa2.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-05T07:12:49.000Z","updated_at":"2023-03-16T14:25:54.000Z","dependencies_parsed_at":"2023-01-17T19:47:38.435Z","dependency_job_id":null,"html_url":"https://github.com/jsa2/AADmon2otherTenant","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsa2%2FAADmon2otherTenant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsa2%2FAADmon2otherTenant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsa2%2FAADmon2otherTenant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsa2%2FAADmon2otherTenant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsa2","download_url":"https://codeload.github.com/jsa2/AADmon2otherTenant/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243589255,"owners_count":20315467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T08:39:45.217Z","updated_at":"2025-03-14T13:42:35.803Z","avatar_url":"https://github.com/jsa2.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Create Logs redirection from another tenant with Azure CLI in Bash\n\nI often need to send logs from a demo tenant which does not have Azure Subscription to Log Analytics. \n\n✅ This guide is based on [deep-diver-azure-ad-b2c-azure-monitor](https://securecloud.blog/2020/05/30/deep-diver-azure-ad-b2c-azure-monitor-integration-configuration-and-delegation-explained/) which is based on Azure AD B2C guide for similar use case\n\n## pre-reqs\n- Azure Cloud shell (bash) - or suitable linux distribution and Azure CLI installed \n\n## Guide\n**In the AAD tenant where you want the logs to be redirected FROM**\n1. Create group and take the note of the objectId\n2. Copy tenantId of the group\n\n**In The subscription where the logs will be redirected TO**\n\n3. Create new RG and Log Analytics space, and take not of the resource group [depl.sh](depl.sh)\n\n```sh\n#Define starting variables\nrnd=$RANDOM\nautodg=redirectLogs-$rnd\nrg=RG-redirectLogs-$rnd\nlocation=westeurope\n# Create Resource Group\naz group create -n $rg \\\n-l $location \\\n--tags=\"svc=autoDiag\"\n\naz monitor log-analytics workspace create --location $location -g $rg  -n laws${autodg}\n```\n\n4. Populate [redirectLogsParams.json](redirectLogsParams.json) with the values gathered in steps 1-2-3\n\n```\n{\n    \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#\",\n    \"contentVersion\": \"1.0.0.0\",\n    \"parameters\": {\n        \"mspOfferName\": {\n            \"value\": \"SecureCloudBlog AAD log redirect\"\n        },\n        \"rgName\": {\n            \"value\": \"rg-redirectlogs-11978\"\n        },\n        \"mspOfferDescription\": {\n            \"value\": \"Provide Azure Monitor for B2C resource\"\n        },\n        \"managedByTenantId\": {\n            \"value\": \"\u003c✅tenantId\"\n        },\n        \"authorizations\": {\n            \"value\": [\n                {\n                    \"principalId\": \"\u003c✅GroupObjectId\u003e\",\n                    \"principalIdDisplayName\": \" Contributor\",\n                    \"roleDefinitionId\": \"b24988ac-6180-42a0-ab88-20f7382dd24c\"\n                }\n            ]\n        }\n    }\n}\n```\n\n5. Create the deployment\n\n```sh\naz deployment create --location $location --template-file redirectLogsTemplate.json  --parameters @redirectLogsParams.json\n```\n\n**In the AAD tenant where you want the logs to be redirected FROM**\n\n6. Go to Azure AD and send the logs you want to be exported to the log analytics workspace \n   \n\n[https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/Overview ](https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/DiagnosticSettings)\n\n\n![image](https://user-images.githubusercontent.com/58001986/152632523-9e3d7a4c-6bcb-4f77-9d1e-926563af1a9f.png)\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsa2%2Faadmon2othertenant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsa2%2Faadmon2othertenant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsa2%2Faadmon2othertenant/lists"}