将主连接字符串或辅助连接字符串重新生成到混合连接。
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules/{authorizationRuleName}/regenerateKeys?api-version=2021-11-01
URI 参数
名称 |
在 |
必需 |
类型 |
说明 |
authorizationRuleName
|
path |
True
|
string
|
授权规则名称。
|
hybridConnectionName
|
path |
True
|
string
|
混合连接名称。
|
namespaceName
|
path |
True
|
string
|
命名空间名称
|
resourceGroupName
|
path |
True
|
string
|
Azure 订阅中的资源组的名称。
|
subscriptionId
|
path |
True
|
string
|
唯一标识 Microsoft Azure 订阅的订阅凭据。 此订阅 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
|
模拟用户帐户
|
示例
RelayHybridConnectionAuthorizationRuleRegenerateKey
Sample Request
POST https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/resourcegroup/providers/Microsoft.Relay/namespaces/example-RelayNamespace-01/hybridConnections/example-Relay-Hybrid-01/authorizationRules/example-RelayAuthRules-01/regenerateKeys?api-version=2021-11-01
{
"keyType": "PrimaryKey"
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.relay import RelayAPI
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-relay
# USAGE
python relay_hybrid_connection_authorization_rule_regenerate_key.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 = RelayAPI(
credential=DefaultAzureCredential(),
subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff",
)
response = client.hybrid_connections.regenerate_keys(
resource_group_name="resourcegroup",
namespace_name="example-RelayNamespace-01",
hybrid_connection_name="example-Relay-Hybrid-01",
authorization_rule_name="example-RelayAuthRules-01",
parameters={"keyType": "PrimaryKey"},
)
print(response)
# x-ms-original-file: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionAuthorizationRuleRegenerateKey.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 armrelay_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/relay/armrelay"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionAuthorizationRuleRegenerateKey.json
func ExampleHybridConnectionsClient_RegenerateKeys() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armrelay.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewHybridConnectionsClient().RegenerateKeys(ctx, "resourcegroup", "example-RelayNamespace-01", "example-Relay-Hybrid-01", "example-RelayAuthRules-01", armrelay.RegenerateAccessKeyParameters{
KeyType: to.Ptr(armrelay.KeyTypePrimaryKey),
}, 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.AccessKeys = armrelay.AccessKeys{
// KeyName: to.Ptr("example-RelayAuthRules-01"),
// PrimaryConnectionString: to.Ptr("Endpoint=sb://example-Relaynamespace-01.servicebus.windows.net/;SharedAccessKeyName=example-RelayAuthRules-01;SharedAccessKey=############################################"),
// PrimaryKey: to.Ptr("############################################"),
// SecondaryConnectionString: to.Ptr("Endpoint=sb://example-Relaynamespace-01.servicebus.windows.net/;SharedAccessKeyName=example-RelayAuthRules-01;SharedAccessKey=############################################"),
// SecondaryKey: to.Ptr("############################################"),
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Relay;
using Azure.ResourceManager.Relay.Models;
// Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionAuthorizationRuleRegenerateKey.json
// this example is just showing the usage of "HybridConnections_RegenerateKeys" 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 RelayHybridConnectionAuthorizationRuleResource created on azure
// for more information of creating RelayHybridConnectionAuthorizationRuleResource, please refer to the document of RelayHybridConnectionAuthorizationRuleResource
string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
string resourceGroupName = "resourcegroup";
string namespaceName = "example-RelayNamespace-01";
string hybridConnectionName = "example-Relay-Hybrid-01";
string authorizationRuleName = "example-RelayAuthRules-01";
ResourceIdentifier relayHybridConnectionAuthorizationRuleResourceId = RelayHybridConnectionAuthorizationRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, hybridConnectionName, authorizationRuleName);
RelayHybridConnectionAuthorizationRuleResource relayHybridConnectionAuthorizationRule = client.GetRelayHybridConnectionAuthorizationRuleResource(relayHybridConnectionAuthorizationRuleResourceId);
// invoke the operation
RelayRegenerateAccessKeyContent content = new RelayRegenerateAccessKeyContent(RelayAccessKeyType.PrimaryKey);
RelayAccessKeys result = await relayHybridConnectionAuthorizationRule.RegenerateKeysAsync(content);
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
Sample Response
{
"primaryConnectionString": "Endpoint=sb://example-Relaynamespace-01.servicebus.windows.net/;SharedAccessKeyName=example-RelayAuthRules-01;SharedAccessKey=############################################",
"secondaryConnectionString": "Endpoint=sb://example-Relaynamespace-01.servicebus.windows.net/;SharedAccessKeyName=example-RelayAuthRules-01;SharedAccessKey=############################################",
"primaryKey": "############################################",
"secondaryKey": "############################################",
"keyName": "example-RelayAuthRules-01"
}
定义
AccessKeys
命名空间/中继连接字符串
名称 |
类型 |
说明 |
keyName
|
string
|
描述授权规则的字符串。
|
primaryConnectionString
|
string
|
创建命名空间授权规则的主连接字符串。
|
primaryKey
|
string
|
用于签名和验证 SAS 令牌的 Base64 编码的 256 位主密钥。
|
secondaryConnectionString
|
string
|
创建的命名空间授权规则的辅助连接字符串。
|
secondaryKey
|
string
|
用于签名和验证 SAS 令牌的 Base64 编码的 256 位备用密钥。
|
ErrorAdditionalInfo
资源管理错误附加信息。
名称 |
类型 |
说明 |
info
|
object
|
其他信息。
|
type
|
string
|
其他信息类型。
|
ErrorDetail
错误详细信息。
ErrorResponse
错误响应
KeyType
要重新生成的访问密钥。
名称 |
类型 |
说明 |
PrimaryKey
|
string
|
|
SecondaryKey
|
string
|
|
RegenerateAccessKeyParameters
为重新生成授权规则提供的参数。
名称 |
类型 |
说明 |
key
|
string
|
可选。 如果提供了键值,则此值设置为键类型,或为键类型设置自动生成的键值。
|
keyType
|
KeyType
|
要重新生成的访问密钥。
|