Tag: Azure
-
Add a Document to CosmosDB via the REST API using PowerShell
There are a lot of examples out there on how to POST a document to Cosmos DB, but they weren’t working for me. I kept getting a 400 Bad Request. After far to long, I finally got it to work. I need the “x-ms-documentdb-partitionkey” header to make it work. Code for anyone who needs it…
-
Connecting to the Azure REST API from an Azure Automation RunBook
I was looking for data that I couldn’t find in a PowerShell command, so I needed an access token to run a query against an Azure API. I was stuck with the basic problem of how do I query the Azure REST endpoints from a RunBook. In my last post, I just learned that you…
-
Azure Runbook to enable Auto-Shutdown for New VMs
I have an azure lab subscription (as do you, I am sure). In this lab, I am always provisioning and deleting and scaling VMs. In order to keep my costs down, I want to enable the AutoShutdown feature on all new VMs. I can do that easily with an ARM template. But for machines that…
-
Moving to the new (and future) Azure PowerShell Module : Az
It looks like we need to move to the new Az module. It is not required, but future functionality will not be added to AzureRM, so I decided to make the switch. Here is how I went about it. First, to enable backwards compatibility, you need to add this command to your profile : “Enable-AzureRmAlias”…
-
Code to query Azure Load Balancer Metrics to verify Availability (VipAvailability )
This one was fun to put together. I wanted to write code to query the status of an Azure Load Balancer. I couldn’t find much out there. This code query’s the Azure Load Balancer’s Metrics for VipAvailability – through the REST API. If it returns 100 then are good to go. Anyting else, then there may…
-

Using Azure Traffic Manager with IP White-listed resources
The question was, how can you use Azure Traffic Manager if the destinations are restricted with IP white lists?This is the only way I could find: There is a blob that contains the source IPs of the probes. Here is the file, And here is the reference This list would need to be queried often…
-
PowerShell to move a VM to a new Log Analytics WorkSpace
This code uninstalls the Microsoft Monitoring agent and re-installs it to a new WorkSpace. Nothing special, just thought I would put it here. Mayby it will help someone?
-
Use the REST API to create a new Project in Azure DevOps
As the title says, I wanted to create a new project in VSTS / Azure DevOps, whatever you want to call it. Here is the code to do that. You need a Personal Access Token to authenticate with. Hope that helps someone?
-
Using PowerShell to query Azure Log Analytics via the REST API
I wanted to pull some data out of Azure Log Analytics using PowerShell and the REST API. Here is the code to Pull all errors in the Application event logs on VMs that are pushing their logs into Log Analytics via MicrosoftMonitoringAgent. Hopefully this may help someone: Notes: I keep my subscription information in Env Varaibles.…
-
Removing machines from Azure State Configuration (DSC)
I have been provisioning machines over an over trying to learn all the VM Extensions. One of the extensions that I have been playing with is the DSC extension. Every time I provision with this extension, it adds an additional record into the State Configuration, resulting in many stale machines. I wanted to clear out…
