My command:
az monitor app-insights component create --app $appin --subscription $sub --resource-group $rg-for-insights-component --workspace workspace-in-different-Subscription --location centralus
error:
Could not retrieve the Log Analytics workspace from ARM: /subscriptions/GUID/resourceGroups/rg-for-insights-component/providers/microsoft.OperationalInsights/workspaces/workspace-in-different-Subscription
Of course that workspace exists in a different subscription, how would it find? How do I provide the 2nd subscription name using the CLI?
The GUI version allows for a seperate name
edit: When I view the parameters JSON in the GUI Azure Portal, is see
"workspaceResourceId": {
"value": "/subscriptions/**GUID**/resourcegroups/ResourceGroupOfWorkspace/providers/microsoft.operationalinsights/workspaces/LAWorkspaceName" }
can this UNCish workspace name be entered into the CLI command somehow?
2
Answers
You can use the flag
--workspace
and pass your workspace resource id to the commandThere is also documentation from Microsoft regarding the command
You cannot directly pass the workspace existed in another subscription with
az monitor app-insights component create
commands —workspace
argument.In order to achieve that, you first set the workspace subscription and retrieve the workspace ID or name as shown below.
Once you are done with the above, clear the subscriptions and CLI cache using
az account clear
command and authenticate to azure account with your corresponding credentials. Now set the current subscription in which you want to create an insights component usingaz account set
.Note: Make sure that the logged in user has a necessary permission (Eg: Contributor role) to access and retrieve the resource from the other subscription.
I have created an insights component with the below command format by passing the workspace name as shown.