diff --git a/agentops-cli/src/commands/azure-ingest.js b/agentops-cli/src/commands/azure-ingest.js index beb5c54..1d0264a 100644 --- a/agentops-cli/src/commands/azure-ingest.js +++ b/agentops-cli/src/commands/azure-ingest.js @@ -14,6 +14,7 @@ const { } = require('../lib/azure/v2-ingest-plan'); const repoRoot = path.resolve(__dirname, '..', '..', '..'); +const logsIngestionResource = 'https://monitor.azure.com/'; function azureIngestCommand(args = []) { const [subcommand = 'plan'] = args; @@ -96,6 +97,8 @@ function runLogsIngestionUpload(plan, options = {}) { 'post', '--uri', upload.uri, + '--resource', + logsIngestionResource, '--headers', 'Content-Type=application/json', '--body', diff --git a/agentops-cli/src/lib/azure/v2-ingest-plan.js b/agentops-cli/src/lib/azure/v2-ingest-plan.js index ad4f171..4c7f2f5 100644 --- a/agentops-cli/src/lib/azure/v2-ingest-plan.js +++ b/agentops-cli/src/lib/azure/v2-ingest-plan.js @@ -34,6 +34,7 @@ const optionalEmptyTables = new Set([ ]); const schemaVersionTables = new Set(tableNames.filter(table => table.endsWith('_CL'))); +const logsIngestionResource = 'https://monitor.azure.com/'; const schemaMigrationPolicy = { current_version: AGENTOPS_SCHEMA_VERSION, @@ -344,6 +345,8 @@ function buildLogsIngestionUploadPlan({ 'post', '--uri', uri || '', + '--resource', + logsIngestionResource, '--headers', 'Content-Type=application/json', '--body', diff --git a/agentops-cli/test/index.test.js b/agentops-cli/test/index.test.js index ca7e443..ff57a3c 100644 --- a/agentops-cli/test/index.test.js +++ b/agentops-cli/test/index.test.js @@ -671,6 +671,7 @@ test('azure-ingest logs-upload plans reviewed Logs Ingestion API calls', () => { assert.equal(result.endpoint, 'https://dce.example.ingest.monitor.azure.com'); assert.equal(result.uploads.find(upload => upload.table === 'AgentOpsRunSummary_CL').stream, 'Custom-AgentOpsRunSummary_CL'); assert.match(result.uploads[0].uri, /dataCollectionRules\/dcr-abc\/streams\/Custom-/); + assert.equal(result.uploads[0].command[result.uploads[0].command.indexOf('--resource') + 1], 'https://monitor.azure.com/'); assert.equal(logsIngestionUri('https://dce.example/', 'dcr id', 'Custom-AgentOpsRunSummary_CL'), 'https://dce.example/dataCollectionRules/dcr%20id/streams/Custom-AgentOpsRunSummary_CL?api-version=2023-01-01'); } finally { fs.rmSync(tempDir, { recursive: true, force: true }); @@ -700,6 +701,7 @@ test('azure-ingest logs-upload executes az rest only after a ready plan', () => assert.equal(result.executed, true); assert.equal(calls[0].command, 'az'); assert.deepEqual(calls[0].args.slice(0, 4), ['rest', '--method', 'post', '--uri']); + assert.equal(calls[0].args[calls[0].args.indexOf('--resource') + 1], 'https://monitor.azure.com/'); assert.ok(calls[0].args.includes('Content-Type=application/json')); assert.ok(calls[0].args.some(arg => /^@.*AgentOpsRunSummary_CL\.json$/.test(arg))); assert.equal(JSON.parse(fs.readFileSync(calls[0].args.at(-1).slice(1), 'utf8')).length, 1);