Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arcbox jumpbox itpros #2835

Open
isheaffer opened this issue Nov 8, 2024 · 2 comments
Open

arcbox jumpbox itpros #2835

isheaffer opened this issue Nov 8, 2024 · 2 comments
Assignees
Labels
triage issue or feature up for triage
Milestone

Comments

@isheaffer
Copy link

arcbox itpros

Note: For ease of issues and pull requests management and tracking, we kindly ask you to provide a meaningful and concise title to this issue and answer all questions to the best of your ability.

Is your issue related to a Jumpstart scenario, ArcBox, HCIBox, or Agora?

https://azurearcjumpstart.io/azure_jumpstart_arcbox/ITPro/#basic-troubleshooting
Describe the issue or the bug

1 fail on SQL best practices
Enabling SQL server best practices assessment.
{"status":"Failed","error":{"code":"DeploymentFailed","target":"/subscriptions/ebf3e8b0-4fcc-4e6b-9831-ba5cb35dd506/reso
urceGroups/azurearc3-rg/providers/Microsoft.Resources/deployments/sqlbpa","message":"At least one resource deployment op
eration failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for u
sage details.","details":[{"code":"MissingSubscriptionRegistration","message":"The subscription is not registered to use
namespace 'microsoft.insights'. See https://aka.ms/rps-not-found for how to register subscriptions.","details":[{"code"
:"MissingSubscriptionRegistration","target":"microsoft.insights","message":"The subscription is not registered to use na
mespace 'microsoft.insights'. See https://aka.ms/rps-not-found for how to register subscriptions."}]}]}}

I have registered the microsoft.insights then tried to run the script again via the windows terminal, but it fails with
| "archiveRetentionInDays": 0,
| ~
| Unexpected token ':' in expression or statement.

To Reproduce

Expected behavior

Environment summary

Have you looked at the Troubleshooting and Logs section?

Screenshots

Additional context

how can i rerun all sql scripts itself such that it works? - cut/paste from the log to the windows terminal shell isn't working

@isheaffer isheaffer added the triage issue or feature up for triage label Nov 8, 2024

Hi isheaffer! Thank you for opening this issue. We appreciate your contribution and welcome you to our community! We are glad to have you here and to have your input on the Arc Jumpstart.

@janegilring janegilring self-assigned this Nov 15, 2024
@janegilring janegilring added this to the November 2024 milestone Nov 15, 2024
@janegilring
Copy link
Contributor

janegilring commented Nov 15, 2024

Hi @isheaffer

Could you save the following to C:\ArcBox\sql-bpa.ps1 and try to run it from Windows Terminal?

# Enable Best practices assessment

# Variables
$subscriptionId = $env:subscriptionId
$resourceGroup = $env:resourceGroup
$namingPrefix = $env:namingPrefix
$azureLocation = $env:azureLocation
$SQLvmName = "$namingPrefix-SQL"

# Get access token to make ARM REST API call for SQL server BPA and migration assessments
$token = (az account get-access-token --subscription $subscriptionId --query accessToken --output tsv)
$headers = @{"Authorization" = "Bearer $token"; "Content-Type" = "application/json" }

# Create custom log analytics table for SQL assessment
az monitor log-analytics workspace table create --resource-group $resourceGroup --workspace-name $Env:workspaceName -n SqlAssessment_CL --columns RawData=string TimeGenerated=datetime --only-show-errors

# Verify if ArcBox SQL resource is created
Write-Host "Enabling SQL server best practices assessment"
$bpaDeploymentTemplateUrl = "$Env:templateBaseUrl/artifacts/sqlbpa.json"
az deployment group create --resource-group $resourceGroup --template-uri $bpaDeploymentTemplateUrl --parameters workspaceName=$Env:workspaceName vmName=$SQLvmName arcSubscriptionId=$subscriptionId

# Run Best practices assessment
Write-Host "Execute SQL server best practices assessment"

# Wait for a minute to finish everyting and run assessment
Start-Sleep(60)

$armRestApiEndpoint = "https://management.azure.com/subscriptions/$subscriptionId/resourcegroups/$resourceGroup/providers/Microsoft.HybridCompute/machines/$SQLvmName/extensions/WindowsAgent.SqlServer?api-version=2019-08-02-preview"

# Build API request payload
$worspaceResourceId = "/subscriptions/$subscriptionId/resourcegroups/$resourceGroup/providers/microsoft.operationalinsights/workspaces/$Env:workspaceName".ToLower()
$sqlExtensionId = "/subscriptions/$subscriptionId/resourceGroups/$resourceGroup/providers/Microsoft.HybridCompute/machines/$SQLvmName/extensions/WindowsAgent.SqlServer"
$sqlbpaPayloadTemplate = "$Env:templateBaseUrl/artifacts/sqlbpa.payload.json"
$settingsSaveTime = [DateTimeOffset]::UtcNow.ToUnixTimeSeconds()
$apiPayload = (Invoke-WebRequest -Uri $sqlbpaPayloadTemplate).Content -replace '{{RESOURCEID}}', $sqlExtensionId -replace '{{LOCATION}}', $azureLocation -replace '{{WORKSPACEID}}', $worspaceResourceId -replace '{{SAVETIME}}', $settingsSaveTime

# Call REST API to run best practices assessment
$httpResp = Invoke-WebRequest -Method Patch -Uri $armRestApiEndpoint -Body $apiPayload -Headers $headers
if (($httpResp.StatusCode -eq 200) -or ($httpResp.StatusCode -eq 202)) {
    Write-Host "Arc-enabled SQL server best practices assessment executed. Wait for assessment to complete to view results."
}
else {
    <# Action when all if and elseif conditions are false #>
    Write-Host "SQL Best Practices Assessment faild. Please refer troubleshooting guide to run manually."
}

Expected output:
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage issue or feature up for triage
Projects
Status: No status
Development

No branches or pull requests

2 participants