skip to Main Content

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
Azure Web Portal Insights create

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


  1. You can use the flag --workspace and pass your workspace resource id to the command

    There is also documentation from Microsoft regarding the command

    Login or Signup to reply.
  2. How do I designate the 2nd subscription name for Application Insights CLI Create 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.

    az account set --subscription "Workspacesubscription"
    name=$(az monitor log-analytics workspace show --name "newws" --resource-group "Jahnavi" --subscription "Workspacesubscription" --query name --output tsv)
    

    enter image description here

    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 using az account set.

    az account clear
    az login
    az account set --subscription "1stSubscription"
    

    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.

    az monitor app-insights component create --app "appin" --resource-group "Jahnavi" --workspace $name --location centralus --kind 
    web --application-type web  --subscription "1stsubscription"
    

    enter image description here

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search