Seems you have hardcoded values in the script and a missing variable

Open
#120 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
powershell
Domain
cloud

Research direction

Find the script containing $subId, $SubscriptionId, $rgNameWorkspace, and $workspaceName, then compare its parameter definitions with the reported commands. Confirm that the subscription and workspace values come from the supplied parameters rather than hardcoded values, and run the script to verify Set-AzContext no longer receives a null subscription.

Written by the indexing model from the issue text.

Description

Hi there
where running your script, always got the below error
Set-AzContext : Cannot validate argument on parameter 'Subscription'. The argument is null or empty. Provide an argument that is not null or empty

Looking at the script code you are using a variable $subId which does not exist; the parameter one is $SubscriptionId

Then, you have also hardcoded value for the workspace RG and and name
$rgNameWorkspace = 'rg-jamui-workspace'
$workspaceName = 'workspace-jamui-1'

When fixing these issues, the script can run successfully as per below

Connect-AzAccount
Select-AzSubscription -Subscription $SubscriptionId

$rgNameWorkspace = $ResourceGroupName
$workspaceName = $WorkspaceName

Dominant language
PowerShell
Stars
1.2k
Forks
493
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/AzureMonitorCommunity

All issues in microsoft/AzureMonitorCommunity

Similar issues

More Cloud issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.