What does this command do ? "az .\-u" - azure

az .\-u
I accidentally run this command and the cli started some work then I pressed ctrl-c to terminate it but I'm afraid something has been already done. How to check if something changed?
I've checked the cli reference, but couldn't find a similar command.

As there is no such command in Az, even though I entered the same as you, I received an error as shown:
If you want to check your activities for any changes, there are couple of ways:
Check the Log Activity: To check your log activity, use below PowerShell command: (default activity status exists for 90 days)
Get-AzActivityLog -StartTime 2022-11-01T10:30 -EndTime 2022- 11-14T11:30
Note: According to your requirements, you can obtain logs across resource group by applying start time, and end time parameters.
To check for any specific changes held in resources, use below query with "Azcli" command
Search-AzGraph -Query 'resourcechanges | extend changeTime=todatetime(properties.changeAttributes.timestamp) | project changeTime, properties.changeType, properties.targetResourceId, properties.targetResourceType, properties.changes | order by changeTime desc'
Received Output also includes a changetime attribute:
Through Azure portal, Activity logs can also be checked using path: Monitor -> Activity Log
Reference: MSDoc

Related

az sql db show returns $true when database does not exist

Do you have any idea why it's not working correctly?
$resut = az sql db show --name "NotExistingDB" --resource-group "rg" --server "server" | ConvertFrom-Json
checking if database exists - it should return false because it does not.
$? :- Writing result of last command, it returns $true in my case but should return $false.
https://github.com/Azure/azure-cli/pull/24015
#23514 added az.ps1 so that when Azure CLI is invoked in PowerShell, az.ps1 is called instead of az.cmd.
This change caused a number of issues and is being reverted. Though your specific issue is not listed, I can also reproduce it and it fits with the change. A fix will be released soon as far as I can see.
You can also try going back to an old version of Azure CLI to see if that fixes the issue.
I have reproduced in my environment by using your command, and I got the expected results as below:
I got true when the resource is found else, I got false as discussed in comments too.
I used the newer version of powershell and cli , please try to use it:

How to use "AWS logs tail" - syntax question

I'm new to AWS CLI and having trouble getting the tail command to work. I'm using version 2. I try the syntax
aws logs tail group_name /aws/lambda/schedule-jobs --since 1h
and it gives me the error
unknown options: /aws/lambda/schedule-jobs
If I try it without the group_name it tells me the group_name is a required parameter (of course).
If I try it with another log group name it tells me the same error message (with the different log group name).
If I put quotes around the name it gives the same error message.
I know this must be a very simple scenario but I can't find any working examples on Google search or in other SO entries. What am I doing wrong?
Yes, when I call
aws logs describe-log-groups
my log group is there and spelled correctly. I'm in the right account and region.
Yes, I am an admin on the account and have full access to the logs.
Just write aws logs tail /aws/lambda/schedule-jobs --since 1h
aws logs tail command doesn't work on aws cli v2.
You can use the following command to access the logs using v2 API.
aws logs get-log-events --log-group-name <log-group-name> --log-stream-name <log-stream-name> --limit=1000

Why is my powershell DSC failing with the message "An item with the same key has already been added"

We have a powershell DSC that is being executed to bring a vmss to a desired state.
It was working until we added some more parameters, and then it broke.
I removed everything except the parameters from the script and it still doesn't work.
The full error is
The DSC Extension received an incorrect input: An error occurred while
executing script or module 'IISInstall.ps1': An item with the same
key has already been added..
Please correct the input and retry executing the extension.
We even added logging in the DSC to try to troubleshoot.
It doesn't even seem to make it into the body of the DSC.
What am I doing wrong?
The parameter was called $instanceName. We wanted to use it to add a custom header to IIS to track which instance a response came from.
Turns out if you use $instanceName that steps on the internals of DSC in some way and it will never deploy correctly!
As soon as you remove $instanceName from the parameter list, it will work.

Managing Azure Backup (MARS) with Powershell - how to add System State

my current tasks is to set up an automatic configuration for Microsoft Azure Backup.
What i did so far:
wrote scripts and tasks that copy the Installer to a remote server, execute it, make sure it's installed, register the server with Azure, set up the schedule, the file specs and everything around it.
And it all works.
The problem though: I have now recieved the task to also include "System State" within the backup.
I'm aware, that this is about a 60 second task, if you do it using the Azure Console to schedule the backup. I do however have the requirement to build the script in a way, that not a single finger has to be moved to complete the whole thing.
Question: Has anyone figured out, if it's possible to activate and include the System State Backups ( which ends up under %MARSDIR%\Scratch\SSBS ) within the OBPolicy using only powershell?
If i activate it with the console and then execute the command "Get-OBPolicy" i find the System State listed along the other filespecs.
However i can't figure out how i would set it, using New-OBFileSpec or anything alike.
Thanks in advance :)
Edit: To clarify
Assume i'm in the config window seeing this:
I can "check" C: by doing
"New-OBFileSpec -FileSpec #("C:\")"
What command should i use in PS to "check" System State ?
Edit 2:
Below is the part of the code for this.
How do i add System State to the $inclusions?
## Register Server with Azure
$credsfile = ## Path to Vault credential file
Start-OBRegistration -VaultCredentials $credsfile -Confirm:$false
# Create Policy
$newpolicy = New-OBPolicy
$sched = New-OBSchedule -DaysofWeek Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday -TimesofDay 22:00
Set-OBSchedule -Policy $newpolicy -Schedule $sched
# File Spec
$inclusions = New-OBFileSpec -FileSpec #("E:\")
Add-OBFileSpec -Policy $newpolicy -FileSpec $inclusions
# Retention
$retentionpolicy = New-OBRetentionPolicy -RetentionDays 30
Set-OBRetentionPolicy -Policy $newpolicy -RetentionPolicy $retentionpolicy
## Set the Policy
Set-OBPolicy -Policy $newpolicy -Confirm:$false
# Set Machine Encryption Key
$PassPhrase = ConvertTo-SecureString -String "...." -AsPlainText -Force
Set-OBMachineSetting -EncryptionPassPhrase $PassPhrase

How can I troubleshoot Azure ARM template validation errors?

I have made some small changes to an Azure ARM template file and now when I try to deploy or validate via the xplat cli I get this message.
error: InvalidTemplateDeployment : The template deployment
'fakedDeploymentName' is not valid according to the validation
procedure. The tracking id is '\some kind of GUID here\'.
See inner errors for details. Please see http://aka.ms/arm-deploy for
usage details.
error: PreflightValidationCheckFailed : Preflight
validation failed. Please refer to the details for the specific
errors.
I would love to troubleshoot this problem, but I don't see any "inner errors" on the console. It even gives me a unique GUID each time, implying that I could use this GUID to look up a more informative message. Where can I view a more detailed error? (not looking for help on the real source of the error yet)
Log into the azure portal portal.azure.com.
Open the Activity log
Find the record with Operation Name of Validate in the list of activities. It should have a red exclamation mark because it failed.
Click on it that record. Then click on the JSON tab at the bottom. Get reading and somewhere deep down in returned Json you might find an error in the statusMessage such as "The storage account named helloworld is already taken."
Make sure you're running the latest version of the CLI, we're working on bubbling up the detailed error. If that's still not catching it, let us know https://github.com/Azure/azure-xplat-cli/issues
Then if the log isn't showing you the detail, run the deployment with the -vv switch, the detailed debug output (while verbose) will have all the error messages and you can usually sift through and find the specific failure.
azure group deployment create ... --debug
Powershell:
New-AzResourceGroupDeployment ... -debug
Run the following PowerShell Azure cmdlet with the tracking ID supplied:
Get-AzureRMLog -CorrelationId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -DetailedOutput
Building on nftw's answer...
To make it faster/easier to find the error issue I used grep and less with a variable as follows:
$correlationId ='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' # store your correlation ID here
Get-AzureRmLog -CorrelationId $correlationID -DetailedOutput | grep -C 10 $correlationID | less
In my testing the error was close to the top of the output. You could use less and the forward-slash key / and search "error" to find the error even quicker.
I believe that tracking ID is for technical support for looking at their logs, not for the user.
Regarding your exact question, you need to take a look at logs - reference.
Another good way to validate the template is to use Resource Explorer.
Building on #nftw:
$deploymentGroupName = 'deploymentGroupName'
$correlationId = ((Get-AzureRMLog -ResourceGroup $deploymentGroupName)[0]).CorrelationId
$logentry = (Get-AzureRMLog -CorrelationId $correlationId -DetailedOutput)
#$logentry
$rawStatusMessage = $logentry.Properties
$status = $rawStatusMessage.Content.statusMessage | ConvertFrom-Json
$status.error.details
$status.error.details.details
I was running in the same issue. Basically, I couldn't get any details passed "InvalidTemplateDeployment".
I added my ARM template in a Visual Studio: Azure Resource Group project template and tried to deploy it. I got verbose details in the Output tab. That helped me solve my problem.
In my case it was the name of the cluster, it can only be small letters and numbers.
az vm list [--only-show-errors]
[--resource-group]
[--show-details]
[--subscription]

Resources