This message was deleted.
# general
s
This message was deleted.
s
It’d be best to share code here if possible.
w
Copy code
var function = new WebApp("Function", new WebAppArgs
        {
            Name = name,
            ResourceGroupName = appPlan.ResourceGroup,
            Location = appPlan.Location,
            ServerFarmId = appPlan.Id,
            Tags = CustomConfigs.GetTags(environment),
            SiteConfig = new SiteConfigArgs
            {

                AppSettings = new NameValuePairArgs[] {
                        new NameValuePairArgs {
                            Name = "FUNCTIONS_WORKER_RUNTIME",
                            Value = "dotnet"
                            },
                        new NameValuePairArgs {
                            Name = "FUNCTIONS_EXTENSION_VERSION",
                            Value = "~3"
                        },
                        new NameValuePairArgs {
                            Name = "AzureWebJobsStorage",
                            Value = storageAccount.PrimaryEndpoints.Apply(e => e.Blob),
                        }
                    }
            },

            Kind = "functionapp,linux",
            ClientAffinityEnabled = true,
            Enabled = true
        }, new CustomResourceOptions { DependsOn = { appPlan, storageAccount } });


        string vnetSubnetId = vnet.Subnets.Where(s => s.Name == $"snet-{appPlan.GetResourceName()}").FirstOrDefault()?.Id;

        var swiftVnet = new WebAppSwiftVirtualNetworkConnection($"vnetintegration-{function.GetResourceName()}", new WebAppSwiftVirtualNetworkConnectionArgs
        {
            Name = function.GetResourceName(),
            ResourceGroupName = function.ResourceGroup,
            SubnetResourceId = vnetSubnetId

        }, new CustomResourceOptions { DependsOn = function });
The error happens only when I create a WebAppSwiftVirtualNetworkConnections
s
are you specifically looking to add the function to the vnet? Did you consider setting the vnet in the SiteConfig (SiteConfigArgs)?
extension resources in things like ARM templates translate slightly differently in the REST API… You should be able to roll them into the arguments to the resource itself.
I am not familiar with the swift virtual network connection though. My assumption is that all you are looking to do is use an existing vnet…
w
In SiteConfigArgs the only setting I can set about VnetSubnet is inside IpSecurityRestrictionArgs, but is not what I want
Yes, i'm looking to use an existing VNet and link with an WebApp
Using ARM this is what I want to do:
Copy code
{
  "apiVersion": "2016-08-01",
  "type": "Microsoft.Web/sites",
  "kind": "app",
  "name": "[variables('webAppName')]",
  "location": "[parameters('location')]",
  "properties": {
    "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
  },
  "resources": [
    {
      "name": "virtualNetwork",
      "type": "config",
      "apiVersion": "2018-02-01",
      "location": "[parameters('location')]",
      "dependsOn": [
        "[concat('Microsoft.Web/sites/', variables('WebAppName'))]",
        "[concat('Microsoft.Network/virtualNetworks/', variables('vnetName'))]"
      ],
      "properties": {
        "subnetResourceId": "[variables('subnetRef')]",
        "swiftSupported": true
      }
    }
  ],
  "dependsOn": [
    "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
  ]
}
The complete ARM example can be found here: https://github.com/ScottHolden/ARMExamples/blob/master/AppService-VnetNew-Storage/deploy.json And the code generated by ARM2Pulumi don't have any code associating an WebApp to VirtualNetwork :(
s
Could you cut an issue on https://github.com/pulumi/pulumi-azure-nextgen/ with the above details for the “cannot create already existing resource” error?
1
I think I have a partial repro, I can follow up with the details on the ticket to further investigate.
🙏 1