Get Azure VM status : "running , stopped" using resource manager deployment and rest api - rest

i've deployed a vm using Resource Manager deployment model.
Using rest api as described here: https://msdn.microsoft.com/en-us/library/azure/mt163682.aspx
i'm able to get informations about my VM. But i cannot see if the VM is running or not. I want that information to start/stop the VM Automatically via code.
Does anyone have tried that and get the VM powerstate?
best regards...
i make a GET using this URI
string.Format("https://management.azure.com/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualMachines/{2}?api-version={3}", subscriptionID, resssourcegroup, vmname,apiversion);
apiversion is 2016-03-30.

The API call for this information is:
https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}/InstanceView?api-version={api-version}

Needed to use the second request uri "Get information about the instance view of a virtual machine" from the following url https://msdn.microsoft.com/en-us/library/azure/mt163682.aspx to get the instance powerstate.
Thank you.

This is the link to the documentation where you can see the Status of the VM:
https://learn.microsoft.com/en-us/rest/api/compute/virtual-machines/instance-view?tabs=HTTP
This is an example of the output
"statuses": [
{
"code": "ProvisioningState/succeeded",
"level": "Info",
"displayStatus": "Provisioning succeeded",
"time": "2022-07-25T02:12:52.7726725+00:00"
},
{
"code": "PowerState/running",
"level": "Info",
"displayStatus": "VM running"
}
]

Related

Deploying azure storage fileServices/shares - error: The value for one of the HTTP headers is not in the correct format

As part of a durable function app deployment, I am deploying azure storage.
On deploying the fileServices/shares, I am getting the following error:
error": {
"code": "InvalidHeaderValue",
"message": "The value for one of the HTTP headers is not in the correct format.\nRequestId:6c0b3fb0-701a-0058-0509-a8af5d000000\nTime:2022-08-04T13:49:24.6378224Z"
}
I would appreciate any advice as this is eating up a lot of time and I am no closer to resolving it.
Section of arm template for the share deployment is below:
{
"type": "Microsoft.Storage/storageAccounts/fileServices/shares",
"apiVersion": "2021-09-01",
"name": "[concat(parameters('storageAccount1_name'), '/default/FuncAppName')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/fileServices', parameters('storageAccount1_name'), 'default')]",
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccount1_name'))]"
],
"properties": {
"accessTier": "TransactionOptimized",
"shareQuota": 5120,
"enabledProtocols": "SMB"
}
}
Answer to this: removing the property "accessTier": "TransactionOptimized" resolves the issue. The default value for this is TransactionOptimized.
Although the template exported from azure portal includes this property, deployment fails if this parameter is present.

Cannot create Topic with ARM to Service Bus Namespaces with Geo-Redundant Disaster Recovery

I have created "Service Bus Namespaces with Geo-Redundant Disaster Recovery", which creates 2 premium namespaces with 1 units each as it should. https://github.com/Azure/azure-quickstart-templates/tree/master/101-servicebus-create-namespace-geo-recoveryconfiguration
Then I try to create Topic, but failing. I like to create with own ARM so that any day I can add new Topics. I would like to create several topics here.
This ARM seems to try create new namespace while I would like to use existing namespace created earlier.
https://github.com/Azure/azure-quickstart-templates/tree/master/101-servicebus-topic
New-AzResourceGroupDeployment : 11.05.49 - Resource Microsoft.ServiceBus/namespaces 'sb-namepace-a' failed with message '{
"error": {
"message": "SKU change invalid for ServiceBus namespace. Cannot downgrade premium namespace. CorrelationId: 1111f842-1ddf-417a-a302-
829b6445e30c",
"code": "BadRequest"
}
}'
the error pretty clearly says - you are trying to change the SKU. add the SKU part back and it should work:
"sku": {
"name": "Premium",
"tier": "Premium",
"capacity": 4
},

How to create/start cluster from data bricks web activity by invoking databricks rest api

I have 2 requirements:
1:I have a clusterID. I need to start the cluster from a "Wb Activity" in ADF. The activity parameters look like this:
url:https://XXXX..azuredatabricks.net/api/2.0/clusters/start
body: {"cluster_id":"0311-004310-cars577"}
Authentication: Azure Key Vault Client Certificate
Upon running this activity I am encountering with below error:
"errorCode": "2108",
"message": "Error calling the endpoint
'https://xxxxx.azuredatabricks.net/api/2.0/clusters/start'. Response status code: ''. More
details:Exception message: 'Cannot find the requested object.\r\n'.\r\nNo response from the
endpoint. Possible causes: network connectivity, DNS failure, server certificate validation or
timeout.",
"failureType": "UserError",
"target": "GetADBToken",
"GetADBToken" is my activity name.
The above security mechanism is working for other Databricks related activity such a running jar which is already installed on my databricks cluster.
2: I want to create a new cluster with the below settings:
url:https://XXXX..azuredatabricks.net/api/2.0/clusters/create
body:{
"cluster_name": "my-cluster",
"spark_version": "5.3.x-scala2.11",
"node_type_id": "i3.xlarge",
"spark_conf": {
"spark.speculation": true
},
"num_workers": 2
}
Upon calling this api, if a cluster creation is successful I would like to capture the cluster id in the next activity.
So what would be the output of the above activity and how can I access them in an immediate ADF activity?
For #2 ) Can you please check if you change the version
"spark_version": "5.3.x-scala2.11"
to
"spark_version": "6.4.x-scala2.11"
if that helps

SAP Hana Service Layer Error "Unknown entity" accessing the service via Postman

I created the "UDO" & "UDT", register it using object registration wizard but whenever I try to access the table via Service Layer I am getting the following error can you one please let me know some solution on this :
{
"error": {
"code": -1000,
"message": {
"lang": "en-us",
"value": "Unknown entity."
}
}
}
Restart the service, and try again
/etc/init.d/b1s restart
Stop the service for about 2 minutes and then start it again:
/etc/init.d/b1s stop
...
/etc/init.d/b1s start

IBM Blockchain (Hyperledger) - "Error when deploying chaincode"

I'm following the instructions to deploy some chaincode to the IBM Hyperledger Blockchain, using the swagger API on the IBM Bluemix dashboard.
In order to deploy some chaincode, I need to submit a JSON request, which contains the path to the chaincode repository:
{
"jsonrpc": "2.0",
"method": "deploy",
"params": {
"type": 1,
"chaincodeID": {
"path": "https://github.com/series0ne/learn-chaincode/tree/master/finished"
},
"ctorMsg": {
"function": "init",
"args": [
"Hello, world"
]
},
"secureContext": "user_type1_0"
},
"id": 0
}
I have logged in user_type1_0 before attempting to deploy, but this is the result I get:
{
"jsonrpc": "2.0",
"error": {
"code": -32001,
"message": "Deployment failure",
"data": "Error when deploying chaincode: Error getting chaincode package bytes: Error getting code 'go get' failed with error: \"exit status 1\"\npackage github.com/series0ne/learn-chaincode/tree/master/finished: cannot find package \"github.com/series0ne/learn-chaincode/tree/master/finished\" in any of:\n\t/opt/go/src/github.com/series0ne/learn-chaincode/tree/master/finished (from $GOROOT)\n\t/opt/gopath/_usercode_/424324290/src/github.com/series0ne/learn-chaincode/tree/master/finished (from $GOPATH)\n\t/opt/gopath/src/github.com/series0ne/learn-chaincode/tree/master/finished\n"
},
"id": 0
}
Any ideas?
P.S. Currently running commit level 0.6.1 of the Hyperledger blockchain on Bluemix.
Try stripping out the 'tree/master' portion of your deployment url. Notice that the example linked below does not include this portion of the url:
https://github.com/IBM-Blockchain/learn-chaincode#deploying-the-chaincode
This url is going to be passed into a go get <url> command inside the peer, which will download the chaincode so that it can be compiled. So, this url must match the format accepted by this command.
I tried using the Learn Chaincode example based on the advice from Dale to change the address of the repository from https://github.com/GitHub_ID/learn-chaincode/tree/master/finished to https://github.com/GitHub_ID/learn-chaincode/finished. The Blockchain network used for this test was running on Bluemix with version 0.6.1 of the Hyperledger Fabric. With the modified path, it was possible to use the APIs tab within the interface for the Blockchain network to deploy the chaincode.
Following are some things to check.
The v2.0 branch from https://github.com/IBM-Blockchain/learn-chaincode should be used with a Blockchain network running Hyperledger Fabric version 0.6.1. Is your personal fork even with the v2.0 branch from https://github.com/IBM-Blockchain/learn-chaincode?
Was the chaincode deployment issued from the same validating peer used to register the user_type1_0 user? The validating peer can be selected at the top of the APIs tab. There is a note in the Learn Chaincode instructions indicating that the same validating peer must register the user and deploy the chaincode.
Your go get is command either not able to access Location of your package due to ACL or its parameters are invalid as per IBM doc. Please recheck its format