https://pulumi.com logo
Title
o

orange-dog-73995

10/06/2020, 1:21 PM
Please take a look on my LoadBalancer config:
var publicIp = new PublicIPAddress("public-ip", new Pulumi.AzureNextGen.Network.Latest.PublicIPAddressArgs
        {
            PublicIpAddressName = "public-ip",
            Location = _resourceGroup.Location,
            ResourceGroupName = _resourceGroup.Name,
            PublicIPAllocationMethod = "Static"
        });

        var frontendIPConfiguration = new FrontendIPConfigurationArgs
        {
            Name = "PublicIPAddress",
            PublicIPAddress = new Pulumi.AzureNextGen.Network.Latest.Inputs.PublicIPAddressArgs
            {
                Id = publicIp.Id,
            }
        };

        var NatRuleArgs_dc = new Pulumi.AzureNextGen.Network.Latest.Inputs.InboundNatRuleArgs
        {
            Name = "dc_rdp",
            Protocol = "Tcp",
            FrontendPort = 33390,
            BackendPort = 3389,
            EnableTcpReset = false,
            FrontendIPConfiguration = new Pulumi.AzureNextGen.Network.Latest.Inputs.SubResourceArgs { Id = frontendIPConfiguration.Id },
        };
...//2 more rules
var NatRulesArgs = new List<Pulumi.AzureNextGen.Network.Latest.Inputs.InboundNatRuleArgs> { NatRuleArgs_dc, NatRuleArgs_aap, NatRuleArgs_vui };

        var loadBalancer = new LoadBalancer("LoadBalancer", new LoadBalancerArgs
        {
            LoadBalancerName = "LoadBalancer",
            ResourceGroupName = _resourceGroup.Name,
            Location = _resourceGroup.Location,
            FrontendIPConfigurations = frontendIPConfiguration,
            InboundNatRules = NatRulesArgs,
        });
On
pulumi up
it fails with following:
error: Code="InvalidRequestFormat" Message="Cannot parse the request." Details=[{"code":"MissingJsonReferenceId","message":"Value for reference id is missing. Path properties.inboundNatRules[0].properties.frontendIPConfiguration."}
Apparently it fails to link frontendIPConfig to rule, but how to do that right, please?
@tall-librarian-49374 any clues, please?
t

tall-librarian-49374

10/07/2020, 6:23 AM
frontendIPConfiguration.Id
is never assigned in your program
I’m not sure what exactly needs to be there, but there’s nothing now, thus the error
o

orange-dog-73995

10/07/2020, 6:28 AM
thought .Id is assigned upon resource creation by pulumi?
replaced it with publicIP.Id and got this error: Code="InvalidRequestFormat" Message="Cannot parse the request." Details=[{"code":"InvalidJsonReferenceWrongType","message":"Reference Id /subscriptions/64fd453f-6026-4825-9ad7-a13a770350b8/resourceGroups/server-rg/providers/Microsoft.Network/publicIPAddresses/public-ip is referencing resource of a wrong type. The Id is expected to reference resources of type loadBalancers/frontendIPConfigurations. Path properties.inboundNatRules[0].properties.frontendIPConfiguration."
If I supply Id manually like this:
var frontendIPConfiguration = new Pulumi.AzureNextGen.Network.Latest.Inputs.FrontendIPConfigurationArgs
        {
            Id = "PublicIPAddress",
            Name = "PublicIPAddress",
            PublicIPAddress = new Pulumi.AzureNextGen.Network.Latest.Inputs.PublicIPAddressArgs
            {
                Id = publicIp.Id,
            }
        };
then error is: error: Code="InvalidRequestFormat" Message="Cannot parse the request." Details=[{"code":"InvalidJsonReferenceFormat","message":"Reference Id PublicIPAddress is not formatted correctly. The Id is expected to reference resources of type loadBalancers/frontendIPConfigurations. Path properties.inboundNatRules[0].properties.frontendIPConfiguration."
t

tall-librarian-49374

10/07/2020, 6:55 AM
thought .Id is assigned upon resource creation by pulumi?
It’s not assigned in the args, it’s assigned in the resource ouputs
Reference Id PublicIPAddress is not formatted correctly
You need to provide a real ID, not a fake ID. I’m not familiar enough with this resource to give a more specific advice.
o

orange-dog-73995

10/07/2020, 8:39 AM
@broad-dog-22463 Can you please clarify, how to properly link frontendIPConfiguration to InboundNatRule?
t

tall-librarian-49374

10/07/2020, 9:26 AM
As I said, I haven’t done that. Do you have an ARM template that does so?
o

orange-dog-73995

10/07/2020, 9:35 AM
hope this helps
t

tall-librarian-49374

10/07/2020, 9:47 AM
So you seem to be missing the
"id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('loadBalancers_access_gateway_name')), '/frontendIPConfigurations/LoadBalancerFrontEnd')]"
part
o

orange-dog-73995

10/07/2020, 9:58 AM
so I should set this manually, but how to compose it properly in code? here it consists of "LBid"+"/frontendIPConfigurations/LoadBalancerFrontEnd" but I don't have LBid on that moment, it gets created later.
t

tall-librarian-49374

10/07/2020, 10:09 AM
Yeah, it’s an odd design of the resource. You probably need to copy an existing ID and then make a string.Format() out of it with your parameters.
You can use resource group’s ID as the first part and then append the other parts
o

orange-dog-73995

10/07/2020, 10:57 AM
can't get rg ID like that var rg_id = _resourceGroup.Id.Apply((v) => v);
t

tall-librarian-49374

10/07/2020, 10:58 AM
You may want to use
Output.Format($"{_resourceGroup.Id}/allyour/other/segments/here")
o

orange-dog-73995

10/07/2020, 11:14 AM
Made it like this:
Id = Output.Format($"{_resourceGroup.Id}/providers/Microsoft.Network/loadBalancers/Loadbalancer/frontendIPConfigurations/LoadBalancerFrontEnd")
Still no go... error: Code="InvalidRequestFormat" Message="Cannot parse the request." Details=[{"code":"MissingJsonReferenceId","message":"Value for reference id is missing. Path properties.frontendIPConfigurations[0].properties.publicIPAddress."}]
"Loadbalancer" in the middle is the dream-name for new LB
t

tall-librarian-49374

10/07/2020, 11:55 AM
This worked for me:
var frontendIPConfiguration = new FrontendIPConfigurationArgs
        {
            Id = Output.Format($"{resourceGroup.Id}/providers/Microsoft.Network/loadBalancers/LoadBalancer/frontendIPConfigurations/LoadBalancerFrontEnd"),
            Name = "LoadBalancerFrontEnd",
            PublicIPAddress = new Pulumi.AzureNextGen.Network.Latest.Inputs.PublicIPAddressArgs
            {
                Id = publicIp.Id,
            }
        };
latest:LoadBalancer     LoadBalancer     created
o

orange-dog-73995

10/07/2020, 12:41 PM
how did you made LB itself? still fails for me...
t

tall-librarian-49374

10/07/2020, 12:42 PM
Copy-pasted your code, no changes
o

orange-dog-73995

10/07/2020, 12:58 PM
doesn't work for me, sorry
private List<Pulumi.AzureNextGen.Network.Latest.Inputs.InboundNatRuleArgs> BuildLoadBalancer()
    {
        var publicIp = new Pulumi.AzureNextGen.Network.Latest.PublicIPAddressArgs
        {
            PublicIpAddressName = "public-ip",
            Location = _resourceGroup.Location,
            ResourceGroupName = _resourceGroup.Name,
            PublicIPAllocationMethod = "Static"
        };

        var frontendIPConfiguration = new FrontendIPConfigurationArgs
        {
            Id = Output.Format($"{_resourceGroup.Id}/providers/Microsoft.Network/loadBalancers/test-lb/frontendIPConfigurations/LoadBalancerFrontEnd"),
            Name = "LoadBalancerFrontEnd",
            PublicIPAddress = new Pulumi.AzureNextGen.Network.Latest.Inputs.PublicIPAddressArgs
            {
                Id = publicIp.Id,
            }
        };

        var NatRuleArgs_dc = new Pulumi.AzureNextGen.Network.Latest.Inputs.InboundNatRuleArgs
        {
            Name = "dc_rdp",
            Protocol = "Tcp",
            FrontendPort = 33390,
            BackendPort = 3389,
            EnableTcpReset = false,
            FrontendIPConfiguration = new Pulumi.AzureNextGen.Network.Latest.Inputs.SubResourceArgs
            {
                Id = frontendIPConfiguration.Id,
            },
        };

        var NatRuleArgs_aap = new Pulumi.AzureNextGen.Network.Latest.Inputs.InboundNatRuleArgs
        {
            Name = "aap_rdp",
            Protocol = "Tcp",
            FrontendPort = 33391,
            BackendPort = 3389,
            EnableTcpReset = false,
            FrontendIPConfiguration = new Pulumi.AzureNextGen.Network.Latest.Inputs.SubResourceArgs
            {
                Id = frontendIPConfiguration.Id,
            },
        };

        var NatRuleArgs_vui = new Pulumi.AzureNextGen.Network.Latest.Inputs.InboundNatRuleArgs
        {
            Name = "vui_rdp",
            Protocol = "Tcp",
            FrontendPort = 33392,
            BackendPort = 3389,
            EnableTcpReset = false,
            FrontendIPConfiguration = new Pulumi.AzureNextGen.Network.Latest.Inputs.SubResourceArgs
            {
                Id = frontendIPConfiguration.Id,
            },
        };

        var NatRulesArgs = new List<Pulumi.AzureNextGen.Network.Latest.Inputs.InboundNatRuleArgs> { NatRuleArgs_dc, NatRuleArgs_aap, NatRuleArgs_vui };

        var loadBalancer = new LoadBalancer("test-lb", new LoadBalancerArgs
        {
            LoadBalancerName = "test-lb",
            ResourceGroupName = _resourceGroup.Name,
            Location = _resourceGroup.Location,
            FrontendIPConfigurations = frontendIPConfiguration,
            InboundNatRules = NatRulesArgs,
        });

        return NatRulesArgs;
    }
t

tall-librarian-49374

10/07/2020, 1:02 PM
Are you on version 0.2.1 (or 0.2.0)?
o

orange-dog-73995

10/07/2020, 1:05 PM
0.2.1, updated yesterday
t

tall-librarian-49374

10/07/2020, 1:05 PM
My public IP is a real resource, not args:
var publicIp = new PublicIPAddress("public-ip", new Pulumi.AzureNextGen.Network.Latest.PublicIPAddressArgs
{
    PublicIpAddressName = "public-ip",
    Location = resourceGroup.Location,
    ResourceGroupName = resourceGroup.Name,
    PublicIPAllocationMethod = "Static"
});
For the rest your code works.
o

orange-dog-73995

10/07/2020, 1:11 PM
hm, that took me further, but still 🙂 error: Running program 'D:\Pulumi\azure-cs-webserver\bin\Debug\netcoreapp3.1\Azure.WebServer.dll' failed with an unhandled exception: System.InvalidOperationException: This operation cannot be performed on a default instance of ImmutableArray<T>. Consider initializing the array, or checking the ImmutableArray<T>.IsDefault property. at System.Collections.Immutable.ImmutableArray`1.ThrowInvalidOperationIfNotInitialized() at System.Collections.Immutable.ImmutableArray`1.System.Collections.ICollection.get_Count() at Pulumi.Serialization.Serializer.SerializeListAsync(String ctx, IList list) at Pulumi.Serialization.Serializer.SerializeAsync(String ctx, Object prop) at Pulumi.Serialization.Serializer.SerializeAsync(String ctx, Object prop) at Pulumi.Serialization.Serializer.SerializeAsync(String ctx, Object prop) at Pulumi.Serialization.Serializer.SerializeDictionaryAsync(String ctx, IDictionary dictionary) at Pulumi.Serialization.Serializer.SerializeInputArgsAsync(String ctx, InputArgs args) at Pulumi.Serialization.Serializer.SerializeAsync(String ctx, Object prop) at Pulumi.Serialization.Serializer.SerializeAsync(String ctx, Object prop) at Pulumi.Serialization.Serializer.SerializeAsync(String ctx, Object prop) at Pulumi.Serialization.Serializer.SerializeDictionaryAsync(String ctx, IDictionary dictionary) at Pulumi.Serialization.Serializer.SerializeInputArgsAsync(String ctx, InputArgs args) at Pulumi.Serialization.Serializer.SerializeAsync(String ctx, Object prop) at Pulumi.Serialization.Serializer.SerializeListAsync(String ctx, IList list) at Pulumi.Serialization.Serializer.SerializeAsync(String ctx, Object prop) at Pulumi.Serialization.Serializer.SerializeAsync(String ctx, Object prop) at Pulumi.Serialization.Serializer.SerializeAsync(String ctx, Object prop) at Pulumi.Deployment.SerializeFilteredPropertiesAsync(String label, IDictionary`2 args, Predicate`1 acceptKey) at Pulumi.Deployment.PrepareResourceAsync(String label, Resource res, Boolean custom, ResourceArgs args, ResourceOptions options) at Pulumi.Deployment.RegisterResourceAsync(Resource resource, ResourceArgs args, ResourceOptions options) at Pulumi.Deployment.ReadOrRegisterResourceAsync(Resource resource, ResourceArgs args, ResourceOptions options) at Pulumi.Deployment.CompleteResourceAsync(Resource resource, ResourceArgs args, ResourceOptions options, ImmutableDictionary`2 completionSources) at Pulumi.Output`1.Pulumi.IOutput.GetDataAsync() at Pulumi.Serialization.Serializer.SerializeAsync(String ctx, Object prop) at Pulumi.Serialization.Serializer.SerializeAsync(String ctx, Object prop) at Pulumi.Serialization.Serializer.SerializeDictionaryAsync(String ctx, IDictionary dictionary) at Pulumi.Serialization.Serializer.SerializeInputArgsAsync(String ctx, InputArgs args) at Pulumi.Serialization.Serializer.SerializeAsync(String ctx, Object prop) at Pulumi.Serialization.Serializer.SerializeListAsync(String ctx, IList list) at Pulumi.Serialization.Serializer.SerializeAsync(String ctx, Object prop) at Pulumi.Serialization.Serializer.SerializeAsync(String ctx, Object prop) at Pulumi.Serialization.Serializer.SerializeAsync(String ctx, Object prop) at Pulumi.Serialization.Serializer.SerializeDictionaryAsync(String ctx, IDictionary dictionary) at Pulumi.Serialization.Serializer.SerializeInputArgsAsync(String ctx, InputArgs args) at Pulumi.Serialization.Serializer.SerializeAsync(String ctx, Object prop) at Pulumi.Serialization.Serializer.SerializeAsync(String ctx, Object prop) at Pulumi.Serialization.Serializer.SerializeAsync(String ctx, Object prop) at Pulumi.Deployment.SerializeFilteredPropertiesAsync(String label, IDictionary`2 args, Predicate`1 acceptKey) at Pulumi.Deployment.PrepareResourceAsync(String label, Resource res, Boolean custom, ResourceArgs args, ResourceOptions options) at Pulumi.Deployment.RegisterResourceAsync(Resource resource, ResourceArgs args, ResourceOptions options) at Pulumi.Deployment.ReadOrRegisterResourceAsync(Resource resource, ResourceArgs args, ResourceOptions options) at Pulumi.Deployment.CompleteResourceAsync(Resource resource, ResourceArgs args, ResourceOptions options, ImmutableDictionary`2 completionSources) at Pulumi.Deployment.Runner.<>c__DisplayClass7_0.<<WhileRunningAsync>g__HandleCompletion|0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Pulumi.Deployment.Runner.WhileRunningAsync()
perhaps issue is other part than LB 🙂
LB was created!
t

tall-librarian-49374

10/07/2020, 1:17 PM
That’s great!