为订阅启用串行控制台
为所提供的订阅中的所有 VM 和 VM 规模集启用串行控制台服务
POST https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.SerialConsole/consoleServices/{default}/enableConsole?api-version=2018-05-01
URI 参数
名称 |
在 |
必需 |
类型 |
说明 |
default
|
path |
True
|
string
|
默认参数。 将该值保留为“default”。
|
subscriptionId
|
path |
True
|
string
|
唯一标识 Microsoft Azure 订阅的订阅 ID。 订阅 ID 构成了每个需要它的服务调用的 URI 的一部分。
|
api-version
|
query |
True
|
string
|
要用于此操作的 API 版本。
|
响应
安全性
azure_auth
Azure Active Directory OAuth2 流
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
名称 |
说明 |
user_impersonation
|
模拟用户帐户
|
示例
Enable Serial Console for a subscription
Sample Request
POST https://management.azure.com/subscriptions/00000000-00000-0000-0000-000000000000/providers/Microsoft.SerialConsole/consoleServices/default/enableConsole?api-version=2018-05-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.serialconsole import MicrosoftSerialConsoleClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-serialconsole
# USAGE
python enable_serial_console_for_a_subscription.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 = MicrosoftSerialConsoleClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-00000-0000-0000-000000000000",
)
response = client.enable_console(
default="default",
)
print(response)
# x-ms-original-file: specification/serialconsole/resource-manager/Microsoft.SerialConsole/stable/2018-05-01/examples/EnableConsoleExamples.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 armserialconsole_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/serialconsole/armserialconsole"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/serialconsole/resource-manager/Microsoft.SerialConsole/stable/2018-05-01/examples/EnableConsoleExamples.json
func ExampleMicrosoftSerialConsoleClient_EnableConsole() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armserialconsole.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewMicrosoftSerialConsoleClient().EnableConsole(ctx, "default", 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.Value = armserialconsole.EnableSerialConsoleResult{
// Disabled: to.Ptr(false),
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { MicrosoftSerialConsoleClient } = require("@azure/arm-serialconsole");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Enables the Serial Console service for all VMs and VM scale sets in the provided subscription
*
* @summary Enables the Serial Console service for all VMs and VM scale sets in the provided subscription
* x-ms-original-file: specification/serialconsole/resource-manager/Microsoft.SerialConsole/stable/2018-05-01/examples/EnableConsoleExamples.json
*/
async function enableSerialConsoleForASubscription() {
const subscriptionId = "00000000-00000-0000-0000-000000000000";
const defaultParam = "default";
const credential = new DefaultAzureCredential();
const client = new MicrosoftSerialConsoleClient(credential, subscriptionId);
const result = await client.enableConsole(defaultParam);
console.log(result);
}
enableSerialConsoleForASubscription().catch(console.error);
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"properties": {
"disabled": false
}
}
{
"code": "SubscriptionNotFound",
"message": "The subscription '00000000-00000-0000-0000-000000000000' could not be found."
}
定义
EnableSerialConsoleResult
串行控制台启用结果
名称 |
类型 |
说明 |
disabled
|
boolean
|
是否禁用串行控制台 (启用) 。
|
GetSerialConsoleSubscriptionNotFound
找不到串行控制台订阅
名称 |
类型 |
说明 |
code
|
string
|
错误代码
|
message
|
string
|
找不到订阅消息
|