GET https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/ConstosoRG/providers/Microsoft.Compute/cloudServices/{cs-name}/instanceView?api-version=2024-11-04
/**
* Samples for CloudServices GetInstanceView.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2024-11-04/examples/
* CloudService_Get_InstanceViewWithMultiRole.json
*/
/**
* Sample code: Get Cloud Service Instance View with Multiple Roles.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
getCloudServiceInstanceViewWithMultipleRoles(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getCloudServices().getInstanceViewWithResponse("ConstosoRG",
"{cs-name}", com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python cloud_service_get_instance_view_with_multi_role.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.cloud_services.get_instance_view(
resource_group_name="ConstosoRG",
cloud_service_name="{cs-name}",
)
print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2024-11-04/examples/CloudService_Get_InstanceViewWithMultiRole.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7033e85e1f80ef5cd9ca664b538ed193a8fd815b/specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2024-11-04/examples/CloudService_Get_InstanceViewWithMultiRole.json
func ExampleCloudServicesClient_GetInstanceView() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewCloudServicesClient().GetInstanceView(ctx, "ConstosoRG", "{cs-name}", nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.CloudServiceInstanceView = armcompute.CloudServiceInstanceView{
// PrivateIDs: []*string{
// to.Ptr("3491bc0c-1f6c-444f-b1d0-ec0751a74e3e")},
// RoleInstance: &armcompute.InstanceViewStatusesSummary{
// StatusesSummary: []*armcompute.StatusCodeCount{
// {
// Code: to.Ptr("ProvisioningState/succeeded"),
// Count: to.Ptr[int32](4),
// },
// {
// Code: to.Ptr("PowerState/started"),
// Count: to.Ptr[int32](4),
// },
// {
// Code: to.Ptr("RoleState/RoleStateStarted"),
// Count: to.Ptr[int32](4),
// }},
// },
// SdkVersion: to.Ptr("2.9.6496.3"),
// Statuses: []*armcompute.ResourceInstanceViewStatus{
// {
// Code: to.Ptr("ProvisioningState/succeeded"),
// DisplayStatus: to.Ptr("Provisioning succeeded"),
// Level: to.Ptr(armcompute.StatusLevelTypesInfo),
// Time: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-12T11:20:07.095Z"); return t}()),
// },
// {
// Code: to.Ptr("PowerState/started"),
// DisplayStatus: to.Ptr("Started"),
// Level: to.Ptr(armcompute.StatusLevelTypesInfo),
// Time: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-12T11:20:07.095Z"); return t}()),
// },
// {
// Code: to.Ptr("CurrentUpgradeDomain/-1"),
// DisplayStatus: to.Ptr("Current Upgrade Domain of cloud service is -1."),
// Level: to.Ptr(armcompute.StatusLevelTypesInfo),
// },
// {
// Code: to.Ptr("MaxUpgradeDomain/1"),
// DisplayStatus: to.Ptr("Max Upgrade Domain of cloud service is 1."),
// Level: to.Ptr(armcompute.StatusLevelTypesInfo),
// }},
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Gets the status of a cloud service.
*
* @summary Gets the status of a cloud service.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2024-11-04/examples/CloudService_Get_InstanceViewWithMultiRole.json
*/
async function getCloudServiceInstanceViewWithMultipleRoles() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "ConstosoRG";
const cloudServiceName = "{cs-name}";
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.cloudServices.getInstanceView(resourceGroupName, cloudServiceName);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2024-11-04/examples/CloudService_Get_InstanceViewWithMultiRole.json
// this example is just showing the usage of "CloudServices_GetInstanceView" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this CloudServiceResource created on azure
// for more information of creating CloudServiceResource, please refer to the document of CloudServiceResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "ConstosoRG";
string cloudServiceName = "{cs-name}";
ResourceIdentifier cloudServiceResourceId = CloudServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cloudServiceName);
CloudServiceResource cloudService = client.GetCloudServiceResource(cloudServiceResourceId);
// invoke the operation
CloudServiceInstanceView result = await cloudService.GetInstanceViewAsync();
Console.WriteLine($"Succeeded: {result}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue