先决条件:
- 在应用服务上配置的同一应用服务计划中不能有重复的应用服务混合连接
使用他们网站(https://www.pulumi.com/docs/reference/pkg/azure/appservice/hybridconnection/)提供的示例:
using Pulumi;
using Azure = Pulumi.Azure;
using Pulumi.AzureNextGen;
class MyStack : Stack
{
public MyStack()
{
var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new Azure.Core.ResourceGroupArgs
{
Location = "West Europe",
});
var examplePlan = new Azure.AppService.Plan("examplePlan", new Azure.AppService.PlanArgs
{
Location = exampleResourceGroup.Location,
ResourceGroupName = exampleResourceGroup.Name,
Sku = new Azure.AppService.Inputs.PlanSkuArgs
{
Tier = "Standard",
Size = "S1",
},
});
var exampleAppService = new Azure.AppService.AppService("exampleAppService", new Azure.AppService.AppServiceArgs
{
Location = exampleResourceGroup.Location,
ResourceGroupName = exampleResourceGroup.Name,
AppServicePlanId = examplePlan.Id,
});
var exampleNamespace = new Azure.Relay.Namespace("exampleNamespace", new Azure.Relay.NamespaceArgs
{
Location = exampleResourceGroup.Location,
ResourceGroupName = exampleResourceGroup.Name,
SkuName = "Standard",
});
var exampleHybridConnection = new Azure.Relay.HybridConnection("exampleHybridConnection", new Azure.Relay.HybridConnectionArgs
{
ResourceGroupName = exampleResourceGroup.Name,
RelayNamespaceName = exampleNamespace.Name,
UserMetadata = "examplemetadata",
});
var exampleAppservice_hybridConnectionHybridConnection = new Azure.AppService.HybridConnection("exampleAppservice/hybridConnectionHybridConnection", new Azure.AppService.HybridConnectionArgs
{
AppServiceName = exampleAppService.Name,
ResourceGroupName = exampleResourceGroup.Name,
RelayId = exampleHybridConnection.Id,
Hostname = "testhostname.example",
Port = 8080,
SendKeyName = "RootManageSharedAccessKey",
});
}
}
我收到以下错误:
错误:无法列出命名空间“XXX”(资源组“XXX”)的访问密钥:relay.NamespacesClient#ListKeys:响应请求失败:StatusCode=404 - 原始错误:autorest/azure:无法解析错误响应:“ “请求的资源 defaultSender 不存在。”“错误:json:无法将字符串解组为 azure.RequestError 类型的 Go 值
为了解决这个问题,我必须添加一个中继命名空间授权规则:
using Pulumi;
using Azure = Pulumi.Azure;
using Pulumi.AzureNextGen;
class MyStack : Stack
{
public MyStack()
{
var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new Azure.Core.ResourceGroupArgs
{
Location = "West Europe",
});
var examplePlan = new Azure.AppService.Plan("examplePlan", new Azure.AppService.PlanArgs
{
Location = exampleResourceGroup.Location,
ResourceGroupName = exampleResourceGroup.Name,
Sku = new Azure.AppService.Inputs.PlanSkuArgs
{
Tier = "Standard",
Size = "S1",
},
});
var exampleAppService = new Azure.AppService.AppService("exampleAppService", new Azure.AppService.AppServiceArgs
{
Location = exampleResourceGroup.Location,
ResourceGroupName = exampleResourceGroup.Name,
AppServicePlanId = examplePlan.Id,
});
var exampleNamespace = new Azure.Relay.Namespace("exampleNamespace", new Azure.Relay.NamespaceArgs
{
Location = exampleResourceGroup.Location,
ResourceGroupName = exampleResourceGroup.Name,
SkuName = "Standard",
});
var defaultSenderAuthorizationRule = new Pulumi.AzureNextGen.Relay.Latest.NamespaceAuthorizationRule("defaultSenderAuthorizationRule",
new AzureProviderNextGen.Relay.Latest.NamespaceAuthorizationRuleArgs
{
AuthorizationRuleName = "defaultSender",
NamespaceName = exampleNamespace .Name,
ResourceGroupName = exampleNamespace .ResourceGroupName,
Rights =
{
"Manage",
"Listen",
"Send",
},
});
var exampleHybridConnection = new Azure.Relay.HybridConnection("exampleHybridConnection", new Azure.Relay.HybridConnectionArgs
{
ResourceGroupName = exampleResourceGroup.Name,
RelayNamespaceName = exampleNamespace.Name,
UserMetadata = "examplemetadata",
});
var exampleAppservice_hybridConnectionHybridConnection = new Azure.AppService.HybridConnection("exampleAppservice/hybridConnectionHybridConnection", new Azure.AppService.HybridConnectionArgs
{
AppServiceName = exampleAppService.Name,
ResourceGroupName = exampleResourceGroup.Name,
RelayId = exampleHybridConnection.Id,
Hostname = "testhostname.example",
Port = 8080,
SendKeyName = "RootManageSharedAccessKey",
});
}
}
在此之后,它工作正常,堆栈完成,说我的 Appservice:HybridConnection 已创建。然而,当我导航到应用服务网络/HybridConnection 设置时,它不存在。
预期行为:
成功创建 AppService.HybridConnection 后,它应该出现在 Azure 门户中应用服务的混合连接列表中。
实际行为:
AppService.HybridConnection 创建成功但未出现在 App Service\Hybrid Connection 列表中