清單 訂用帳戶中的所有 SSH 公鑰。 使用回應中的 nextLink 屬性來取得 SSH 公鑰的下一頁。
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Compute/sshPublicKeys?api-version=2024-03-01
URI 參數
名稱 |
位於 |
必要 |
類型 |
Description |
subscriptionId
|
path |
True
|
string
|
可唯一識別 Microsoft Azure 訂用帳戶的訂用帳戶認證。 訂用帳戶識別碼會構成每個服務呼叫 URI 的一部分。
|
api-version
|
query |
True
|
string
|
用戶端 API 版本。
|
回應
安全性
azure_auth
Azure Active Directory OAuth2 Flow
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
名稱 |
Description |
user_impersonation
|
模擬您的用戶帳戶
|
範例
SshPublicKey_ListBySubscription_MaximumSet_Gen
Sample Request
GET https://management.azure.com/subscriptions/{subscription-id}/providers/Microsoft.Compute/sshPublicKeys?api-version=2024-03-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python ssh_public_key_list_by_subscription_maximum_set_gen.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.ssh_public_keys.list_by_subscription()
for item in response:
print(item)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-03-01/examples/sshPublicKeyExamples/SshPublicKey_ListBySubscription_MaximumSet_Gen.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/v5"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/92de53a5f1e0e03c94b40475d2135d97148ed014/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-03-01/examples/sshPublicKeyExamples/SshPublicKey_ListBySubscription_MaximumSet_Gen.json
func ExampleSSHPublicKeysClient_NewListBySubscriptionPager_sshPublicKeyListBySubscriptionMaximumSetGen() {
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)
}
pager := clientFactory.NewSSHPublicKeysClient().NewListBySubscriptionPager(nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page.SSHPublicKeysGroupListResult = armcompute.SSHPublicKeysGroupListResult{
// Value: []*armcompute.SSHPublicKeyResource{
// {
// Name: to.Ptr("mySshPublicKeyName"),
// Type: to.Ptr("aaaa"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/sshPublicKeys/mySshPublicKeyName"),
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "key6396": to.Ptr("aaaaaaaaaaaaa"),
// "key8839": to.Ptr("aaa"),
// },
// Properties: &armcompute.SSHPublicKeyResourceProperties{
// PublicKey: to.Ptr("{ssh-rsa public key}"),
// },
// }},
// }
}
}
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");
/**
* This sample demonstrates how to Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to get the next page of SSH public keys.
*
* @summary Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to get the next page of SSH public keys.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-03-01/examples/sshPublicKeyExamples/SshPublicKey_ListBySubscription_MaximumSet_Gen.json
*/
async function sshPublicKeyListBySubscriptionMaximumSetGen() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.sshPublicKeys.listBySubscription()) {
resArray.push(item);
}
console.log(resArray);
}
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
{
"value": [
{
"location": "westus",
"properties": {
"publicKey": "{ssh-rsa public key}"
},
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/sshPublicKeys/mySshPublicKeyName",
"name": "mySshPublicKeyName",
"type": "aaaa",
"tags": {
"key6396": "aaaaaaaaaaaaa",
"key8839": "aaa"
}
}
],
"nextLink": "aaaa"
}
SshPublicKey_ListBySubscription_MinimumSet_Gen
Sample Request
GET https://management.azure.com/subscriptions/{subscription-id}/providers/Microsoft.Compute/sshPublicKeys?api-version=2024-03-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python ssh_public_key_list_by_subscription_minimum_set_gen.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.ssh_public_keys.list_by_subscription()
for item in response:
print(item)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-03-01/examples/sshPublicKeyExamples/SshPublicKey_ListBySubscription_MinimumSet_Gen.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/v5"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/92de53a5f1e0e03c94b40475d2135d97148ed014/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-03-01/examples/sshPublicKeyExamples/SshPublicKey_ListBySubscription_MinimumSet_Gen.json
func ExampleSSHPublicKeysClient_NewListBySubscriptionPager_sshPublicKeyListBySubscriptionMinimumSetGen() {
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)
}
pager := clientFactory.NewSSHPublicKeysClient().NewListBySubscriptionPager(nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page.SSHPublicKeysGroupListResult = armcompute.SSHPublicKeysGroupListResult{
// Value: []*armcompute.SSHPublicKeyResource{
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/rgcompute/providers/Microsoft.Compute/sshPublicKeys/mySshPublicKeyName"),
// Location: to.Ptr("westus"),
// }},
// }
}
}
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");
/**
* This sample demonstrates how to Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to get the next page of SSH public keys.
*
* @summary Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to get the next page of SSH public keys.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-03-01/examples/sshPublicKeyExamples/SshPublicKey_ListBySubscription_MinimumSet_Gen.json
*/
async function sshPublicKeyListBySubscriptionMinimumSetGen() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.sshPublicKeys.listBySubscription()) {
resArray.push(item);
}
console.log(resArray);
}
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
{
"value": [
{
"location": "westus",
"id": "/subscriptions/{subscription-id}/resourceGroups/rgcompute/providers/Microsoft.Compute/sshPublicKeys/mySshPublicKeyName"
}
]
}
定義
ApiError
API 錯誤。
名稱 |
類型 |
Description |
code
|
string
|
錯誤碼。
|
details
|
ApiErrorBase[]
|
API 錯誤詳細數據
|
innererror
|
InnerError
|
Api 內部錯誤
|
message
|
string
|
錯誤訊息。
|
target
|
string
|
特定錯誤的目標。
|
ApiErrorBase
API 錯誤基底。
名稱 |
類型 |
Description |
code
|
string
|
錯誤碼。
|
message
|
string
|
錯誤訊息。
|
target
|
string
|
特定錯誤的目標。
|
CloudError
來自計算服務的錯誤回應。
名稱 |
類型 |
Description |
error
|
ApiError
|
API 錯誤。
|
InnerError
內部錯誤詳細數據。
名稱 |
類型 |
Description |
errordetail
|
string
|
內部錯誤訊息或例外狀況傾印。
|
exceptiontype
|
string
|
例外狀況型別。
|
SshPublicKeyResource
指定 SSH 公鑰的相關資訊。
名稱 |
類型 |
Description |
id
|
string
|
資源標識碼
|
location
|
string
|
資源位置
|
name
|
string
|
資源名稱
|
properties.publicKey
|
string
|
用來透過 ssh 向虛擬機驗證的 SSH 公鑰。 如果一開始未在建立資源時提供這個屬性,則會在呼叫 generateKeyPair 時填入 publicKey 屬性。 如果在資源建立時提供公鑰,則提供的公鑰至少必須是 2048 位,且使用 ssh-rsa 格式。
|
tags
|
object
|
資源標籤
|
type
|
string
|
資源類型
|
SshPublicKeysGroupListResult
清單 SSH 公鑰作業回應。
名稱 |
類型 |
Description |
nextLink
|
string
|
要擷取下一頁 SSH 公鑰的 URI。 使用此 URI 呼叫 ListNext () ,以擷取 SSH 公鑰的下一頁。
|
value
|
SshPublicKeyResource[]
|
SSH 公鑰清單
|