|
5 | 5 | "_generator": { |
6 | 6 | "name": "bicep", |
7 | 7 | "version": "0.35.1.17967", |
8 | | - "templateHash": "708671422034288821" |
| 8 | + "templateHash": "12841296004328754819" |
9 | 9 | } |
10 | 10 | }, |
11 | 11 | "parameters": { |
|
121 | 121 | "metadata": { |
122 | 122 | "description": "Set this flag to true only if you are deplpoying from Local" |
123 | 123 | } |
| 124 | + }, |
| 125 | + "existingLogAnalyticsWorkspaceId": { |
| 126 | + "type": "string", |
| 127 | + "defaultValue": "", |
| 128 | + "metadata": { |
| 129 | + "description": "Optional: Existing Log Analytics Workspace Resource ID" |
| 130 | + } |
124 | 131 | } |
125 | 132 | }, |
126 | 133 | "variables": { |
|
565 | 572 | }, |
566 | 573 | "mode": "Incremental", |
567 | 574 | "parameters": { |
| 575 | + "existingLogAnalyticsWorkspaceId": { |
| 576 | + "value": "[parameters('existingLogAnalyticsWorkspaceId')]" |
| 577 | + }, |
568 | 578 | "applicationInsightsName": { |
569 | 579 | "value": "[format('{0}{1}', variables('abbrs').managementGovernance.applicationInsights, variables('solutionPrefix'))]" |
570 | 580 | }, |
|
579 | 589 | "_generator": { |
580 | 590 | "name": "bicep", |
581 | 591 | "version": "0.35.1.17967", |
582 | | - "templateHash": "16868995909099501999" |
| 592 | + "templateHash": "4417744862326794406" |
583 | 593 | } |
584 | 594 | }, |
585 | 595 | "parameters": { |
|
588 | 598 | }, |
589 | 599 | "logAnalyticsWorkspaceName": { |
590 | 600 | "type": "string" |
| 601 | + }, |
| 602 | + "existingLogAnalyticsWorkspaceId": { |
| 603 | + "type": "string", |
| 604 | + "defaultValue": "" |
591 | 605 | } |
592 | 606 | }, |
| 607 | + "variables": { |
| 608 | + "useExisting": "[not(empty(parameters('existingLogAnalyticsWorkspaceId')))]", |
| 609 | + "existingLawResourceGroup": "[if(variables('useExisting'), split(parameters('existingLogAnalyticsWorkspaceId'), '/')[4], '')]", |
| 610 | + "existingLawName": "[if(variables('useExisting'), split(parameters('existingLogAnalyticsWorkspaceId'), '/')[8], '')]" |
| 611 | + }, |
593 | 612 | "resources": [ |
594 | 613 | { |
| 614 | + "condition": "[not(variables('useExisting'))]", |
595 | 615 | "type": "Microsoft.OperationalInsights/workspaces", |
596 | 616 | "apiVersion": "2023-09-01", |
597 | 617 | "name": "[parameters('logAnalyticsWorkspaceName')]", |
|
623 | 643 | "publicNetworkAccessForIngestion": "Enabled", |
624 | 644 | "publicNetworkAccessForQuery": "Disabled", |
625 | 645 | "Request_Source": "rest", |
626 | | - "WorkspaceResourceId": "[resourceId('Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceName'))]" |
| 646 | + "WorkspaceResourceId": "[if(variables('useExisting'), extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, variables('existingLawResourceGroup')), 'Microsoft.OperationalInsights/workspaces', variables('existingLawName')), resourceId('Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceName')))]" |
627 | 647 | }, |
628 | 648 | "dependsOn": [ |
629 | 649 | "[resourceId('Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceName'))]" |
|
637 | 657 | }, |
638 | 658 | "logAnalyticsWorkspaceName": { |
639 | 659 | "type": "string", |
640 | | - "value": "[parameters('logAnalyticsWorkspaceName')]" |
| 660 | + "value": "[if(variables('useExisting'), variables('existingLawName'), parameters('logAnalyticsWorkspaceName'))]" |
| 661 | + }, |
| 662 | + "logAnalyticsWorkspaceResourceGroup": { |
| 663 | + "type": "string", |
| 664 | + "value": "[if(variables('useExisting'), variables('existingLawResourceGroup'), resourceGroup().name)]" |
641 | 665 | } |
642 | 666 | } |
643 | 667 | } |
|
1460 | 1484 | }, |
1461 | 1485 | "logAnalyticsWorkspaceName": { |
1462 | 1486 | "value": "[reference(resourceId('Microsoft.Resources/deployments', 'deploy_app_insights'), '2022-09-01').outputs.logAnalyticsWorkspaceName.value]" |
| 1487 | + }, |
| 1488 | + "logAnalyticsWorkspaceResourceGroup": { |
| 1489 | + "value": "[reference(resourceId('Microsoft.Resources/deployments', 'deploy_app_insights'), '2022-09-01').outputs.logAnalyticsWorkspaceResourceGroup.value]" |
1463 | 1490 | } |
1464 | 1491 | }, |
1465 | 1492 | "template": { |
|
1469 | 1496 | "_generator": { |
1470 | 1497 | "name": "bicep", |
1471 | 1498 | "version": "0.35.1.17967", |
| 1499 | + "templateHash": "12849612969576340024" |
| 1500 | + "version": "0.35.1.17967", |
1472 | 1501 | "templateHash": "1901255801577127677" |
1473 | 1502 | } |
1474 | 1503 | }, |
|
1484 | 1513 | }, |
1485 | 1514 | "logAnalyticsWorkspaceName": { |
1486 | 1515 | "type": "string" |
| 1516 | + }, |
| 1517 | + "logAnalyticsWorkspaceResourceGroup": { |
| 1518 | + "type": "string" |
1487 | 1519 | } |
1488 | 1520 | }, |
1489 | 1521 | "resources": [ |
|
1506 | 1538 | "appLogsConfiguration": { |
1507 | 1539 | "destination": "log-analytics", |
1508 | 1540 | "logAnalyticsConfiguration": { |
1509 | | - "customerId": "[reference(resourceId('Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceName')), '2023-09-01').customerId]", |
1510 | | - "sharedKey": "[listKeys(resourceId('Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceName')), '2023-09-01').primarySharedKey]" |
| 1541 | + "customerId": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, parameters('logAnalyticsWorkspaceResourceGroup')), 'Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceName')), '2023-09-01').customerId]", |
| 1542 | + "sharedKey": "[listKeys(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, parameters('logAnalyticsWorkspaceResourceGroup')), 'Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceName')), '2023-09-01').primarySharedKey]" |
1511 | 1543 | } |
1512 | 1544 | }, |
1513 | 1545 | "zoneRedundant": false, |
|
0 commit comments