pulumi / arm2pulumi

Tool to convert Azure ARM templates to Pulumi code
5 stars 3 forks source link

arm2pulumi Unable to generate completely #31

Closed VenkateshSrini closed 11 months ago

VenkateshSrini commented 1 year ago

What happened?

Hi All, I'm trying my first project with pulumi. I had created some resources in the Azure portal. I exported the same as json file. I copied the contents of template.json file in the arm2pulumi input box. The out was generated with below error

collectionResource no metadata found for resource type 'Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/collections' and version '2023-03-15' storageAccountResource no metadata found for resource type 'Microsoft.Storage/storageAccounts' and version '2022-09-01' mongodbDatabaseResource no metadata found for resource type 'Microsoft.DocumentDB/databaseAccounts/mongodbDatabases' and version '2023-03-15' fileServiceResource no metadata found for resource type 'Microsoft.Storage/storageAccounts/fileServices' and version '2022-09-01' tableServiceResource no metadata found for resource type 'Microsoft.Storage/storageAccounts/tableServices' and version '2022-09-01' queueResource no metadata found for resource type 'Microsoft.Storage/storageAccounts/queueServices/queues' and version '2022-09-01' queueServiceResource no metadata found for resource type 'Microsoft.Storage/storageAccounts/queueServices' and version '2022-09-01' databaseAccountResource no metadata found for resource type 'Microsoft.DocumentDB/databaseAccounts' and version '2023-03-15' blobServiceResource no metadata found for resource type 'Microsoft.Storage/storageAccounts/blobServices' and version '2022-09-01' collectionResource0 no metadata found for resource type 'Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/collections' and version '2023-03-15'

Expected Behavior

I expected the code to be generated with out errors.

Steps to reproduce

Please use the Azure resource template in the attached zip file and try it yourself in the tool ExportedTemplate-caliber.zip

Output of pulumi about

generated source code attached herewith and error stated above arm2pulumi.zip

Additional context

No response

Contributing

Vote on this issue by adding a đź‘Ť reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

thomas11 commented 1 year ago

Hi @VenkateshSrini, sorry for your trouble and thank you for reporting this with the template to repro it. We'll be looking into it.

In the meantime, maybe you find pulumi import useful. It can import your Azure resources and generate Pulumi code for them by using the Azure API directly.

VenkateshSrini commented 1 year ago

@thomas11 , I'm unable to use the pulumi import command also with the attached template.json and parameter.json file. I get an error

error: could not read import file: json: cannot unmarshal object into Go struct field importSpec.resources.properties of type > []string Looks like it cannot be used as it as downloaded from the Azure portal and some modification is required. Since I'm new to Pulumi can you please help me to get that done template.json.txt parameters.json.txt

thomas11 commented 1 year ago

@thomas11 , I'm unable to use the pulumi import command also with the attached template.json and parameter.json file. I get an error

error: could not read import file: json: cannot unmarshal object into Go struct field importSpec.resources.properties of type > []string Looks like it cannot be used as it as downloaded from the Azure portal and some modification is required. Since I'm new to Pulumi can you please help me to get that done template.json.txt parameters.json.txt

Hey @VenkateshSrini, import is not for use with ARM templates. It connects directly to your Azure subscription via the Azure API and queries the existing resources. Please refer to the documentation on how to use it.

VenkateshSrini commented 1 year ago

@thomas11, hey there cannot allow pulumi to connect to Azure. It a official subscription I use and I'm yet to demo the concept to org. So something that works with Art offline is my need of the hour

thomas11 commented 1 year ago

@VenkateshSrini I see. In that case, you can try to use arm2pulumi locally. It's a later version than the hosted one (we're working on updating it) so it knows more API versions.

It's built and packaged as part of Azure Native, so you can download the latest binary for your platform from here: https://github.com/pulumi/pulumi-azure-native/releases/tag/v1.102.0

Usage is

$ ./bin/arm2pulumi
Usage: ./arm2pulumi [arm-template path] lang
arm-template   Path to arm-template or assumed to be stdin if omitted
lang           Comma separated list of languages - e.g. nodejs,python,dotnet,go
VenkateshSrini commented 1 year ago

@VenkateshSrini I see. In that case, you can try to use arm2pulumi locally. It's a later version than the hosted one (we're working on updating it) so it knows more API versions.

It's built and packaged as part of Azure Native, so you can download the latest binary for your platform from here: https://github.com/pulumi/pulumi-azure-native/releases/tag/v1.102.0

Usage is

$ ./bin/arm2pulumi
Usage: ./arm2pulumi [arm-template path] lang
arm-template   Path to arm-template or assumed to be stdin if omitted
lang           Comma separated list of languages - e.g. nodejs,python,dotnet,go

@thomas11 , I tried doing the above instruction. The generate code is as below

using System.Collections.Generic;
using Pulumi;

return await Deployment.RunAsync(() =>
{
    var config = new Config();
    var storageAccountsCaliberqueueNameParam = config.Get("storageAccountsCaliberqueueNameParam") ?? "caliberqueue";
    var blobServiceResource = null;

    var databaseAccountsDbcaliberNameParam = config.Get("databaseAccountsDbcaliberNameParam") ?? "dbcaliber";
    var collectionResource = null;

    var collectionResource0 = null;

    var databaseAccountResource = null;

    var fileServiceResource = null;

    var mongodbDatabaseResource = null;

    var queueResource = null;

    var queueServiceResource = null;

    var storageAccountResource = null;

    var tableServiceResource = null;

});

This is not even 10% code generation. Critical aspects for example for Azure cosmos MongoDB like EnableServerless and location of the data center have all not even been generated/captured.

Regarding pulumi import I went through the documentation I see that there is a option '-f' to provide the resource file but that also does not work as it requires from formatting to ARM I guess. Even if you could provide that then it will be very useful

thomas11 commented 1 year ago

I just ran it to double-check and got a reasonable result. Can you share how exactly you ran the command?

$ ./arm2pulumi ~/Downloads/ExportedTemplate-caliber/template.json csharp
2023/05/03 21:11:02 Starting render
config resourceGroupNameParam string {
}

config storageAccountsCaliberqueueNameParam string {
    default = "caliberqueue"
}

resource storageAccountResource "azure-native:storage/v20220901:StorageAccount" {
    accessTier = "Hot"
    accountName = storageAccountsCaliberqueueNameParam
    allowBlobPublicAccess = true
    allowCrossTenantReplication = true
    allowSharedKeyAccess = true
    defaultToOAuthAuthentication = false
    dnsEndpointType = "Standard"
    enableHttpsTrafficOnly = true
    encryption = {
        keySource = "Microsoft.Storage",
        requireInfrastructureEncryption = false,
        services = {
            blob = {
                enabled = true,
                keyType = "Account"
            },
            file = {
                enabled = true,
                keyType = "Account"
            }
        }
    }
    kind = "StorageV2"
    location = "centralindia"
    minimumTlsVersion = "TLS1_2"
    networkRuleSet = {
        bypass = "AzureServices",
        defaultAction = "Allow",
        ipRules = [],
        virtualNetworkRules = []
    }
    publicNetworkAccess = "Enabled"
    resourceGroupName = resourceGroupNameParam
    sku = {
        name = "Standard_LRS",
        tier = "Standard"
    }
}

resource blobServiceResource "azure-native:storage/v20220901:BlobServiceProperties" {
    accountName = storageAccountResource.name
    blobServicesName = "${storageAccountsCaliberqueueNameParam}/default"
    changeFeed = {
        enabled = false
    }
    containerDeleteRetentionPolicy = {
        days = 7,
        enabled = true
    }
    cors = {
        corsRules = []
    }
    deleteRetentionPolicy = {
        allowPermanentDelete = false,
        days = 7,
        enabled = true
    }
    isVersioningEnabled = false
    resourceGroupName = resourceGroupNameParam
    restorePolicy = {
        enabled = false
    }
}

config databaseAccountsDbcaliberNameParam string {
    default = "dbcaliber"
}

resource databaseAccountResource "azure-native:documentdb/v20230315:DatabaseAccount" {
    accountName = databaseAccountsDbcaliberNameParam
    analyticalStorageConfiguration = {
        schemaType = "FullFidelity"
    }
    apiProperties = {
        serverVersion = "4.2"
    }
    backupPolicy = {
        periodicModeProperties = {
            backupIntervalInMinutes = 240,
            backupRetentionIntervalInHours = 8,
            backupStorageRedundancy = "Geo"
        },
        type = "Periodic"
    }
    capabilities = [
        {
            name = "EnableMongo"
        },
        {
            name = "DisableRateLimitingResponses"
        },
        {
            name = "EnableServerless"
        }
    ]
    capacity = {
        totalThroughputLimit = 4000
    }
    consistencyPolicy = {
        defaultConsistencyLevel = "Session",
        maxIntervalInSeconds = 5,
        maxStalenessPrefix = 100
    }
    cors = []
    databaseAccountOfferType = "Standard"
    defaultIdentity = "FirstPartyIdentity"
    disableKeyBasedMetadataWriteAccess = false
    disableLocalAuth = false
    enableAnalyticalStorage = false
    enableAutomaticFailover = false
    enableFreeTier = false
    enableMultipleWriteLocations = false
    enablePartitionMerge = false
    ipRules = []
    isVirtualNetworkFilterEnabled = false
    kind = "MongoDB"
    location = "Central India"
    locations = [{
        failoverPriority = 0,
        isZoneRedundant = true,
        locationName = "Central India"
    }]
    minimalTlsVersion = "Tls12"
    networkAclBypass = "None"
    networkAclBypassResourceIds = []
    publicNetworkAccess = "Enabled"
    resourceGroupName = resourceGroupNameParam
    tags = {
        defaultExperience = "Azure Cosmos DB for MongoDB API",
        hidden-cosmos-mmspecial = ""
    }
    virtualNetworkRules = []
}

resource mongodbDatabaseResource "azure-native:documentdb/v20230315:MongoDBResourceMongoDBDatabase" {
    accountName = databaseAccountResource.name
    databaseName = "${databaseAccountsDbcaliberNameParam}/flashcard"
    resource = {
        id = "flashcard"
    }
    resourceGroupName = resourceGroupNameParam
}

resource collectionResource "azure-native:documentdb/v20230315:MongoDBResourceMongoDBCollection" {
    accountName = databaseAccountResource.name
    collectionName = "${databaseAccountsDbcaliberNameParam}/flashcard/do_not_delete"
    databaseName = mongodbDatabaseResource.name
    resource = {
        id = "do_not_delete",
        indexes = [
            {
                key = {
                    keys = ["_id"]
                }
            },
            {
                key = {
                    keys = ["$**"]
                }
            }
        ],
        shardKey = {
            _id = "Hash"
        }
    }
    resourceGroupName = resourceGroupNameParam
}

resource collectionResource0 "azure-native:documentdb/v20230315:MongoDBResourceMongoDBCollection" {
    accountName = databaseAccountResource.name
    collectionName = "${databaseAccountsDbcaliberNameParam}/flashcard/FCDetails"
    databaseName = mongodbDatabaseResource.name
    resource = {
        id = "FCDetails",
        indexes = [{
            key = {
                keys = ["_id"]
            }
        }]
    }
    resourceGroupName = resourceGroupNameParam
}

resource fileServiceResource "azure-native:storage/v20220901:FileServiceProperties" {
    accountName = storageAccountResource.name
    cors = {
        corsRules = []
    }
    fileServicesName = "${storageAccountsCaliberqueueNameParam}/default"
    protocolSettings = {
        smb = {}
    }
    resourceGroupName = resourceGroupNameParam
    shareDeleteRetentionPolicy = {
        days = 7,
        enabled = true
    }
}

queueResource = null

resource queueServiceResource "azure-native:storage/v20220901:QueueServiceProperties" {
    accountName = storageAccountResource.name
    cors = {
        corsRules = []
    }
    queueServiceName = "${storageAccountsCaliberqueueNameParam}/default"
    resourceGroupName = resourceGroupNameParam
}

resource tableServiceResource "azure-native:storage/v20220901:TableServiceProperties" {
    accountName = storageAccountResource.name
    cors = {
        corsRules = []
    }
    resourceGroupName = resourceGroupNameParam
    tableServiceName = "${storageAccountsCaliberqueueNameParam}/default"
}

2023/05/03 21:11:05 IR generation: 176 ms, program gen 2845 ms
Diagnostics for queueResource
WARN: [High] at '' - 'no metadata found for resource type 'Microsoft.Storage/storageAccounts/queueServices/queues' and version '2022-09-01''
VenkateshSrini commented 1 year ago

@thomas11 , The command that I used was .\arm2pulumi-tool\arm2pulumi.exe .\template.json dotnet. I use windows 11 OS from inside of powershell

I used the same command with csharp as language parameter. Below is the output. I'm using this version

config storageAccountsCaliberqueueNameParam string {
        default = "caliberqueue"
}

blobServiceResource = null

config databaseAccountsDbcaliberNameParam string {
        default = "dbcaliber"
}

collectionResource = null
collectionResource0 = null
databaseAccountResource = null
fileServiceResource = null
mongodbDatabaseResource = null
queueResource = null
queueServiceResource = null
storageAccountResource = null
tableServiceResource = null
thomas11 commented 1 year ago

Hi @VenkateshSrini, in fact, I made the mistake above of using csharp. It generates only the intermediate representation because the argument is supposed to be dotnet. I filed #32 about this.

Using dotnet and the latest arm2pulumi v1.102.0 (for macOS, though), I get reasonable C# code. That is using the template from ExportedTemplate-caliber.zip. I can't see what the problem could be on your side.

using System.Collections.Generic;
using Pulumi;
using AzureNative = Pulumi.AzureNative;

return await Deployment.RunAsync(() =>
{
    var config = new Config();
    var resourceGroupNameParam = config.Require("resourceGroupNameParam");
    var storageAccountsCaliberqueueNameParam = config.Get("storageAccountsCaliberqueueNameParam") ?? "caliberqueue";
    var storageAccountResource = new AzureNative.Storage.V20220901.StorageAccount("storageAccountResource", new()
    {
        AccessTier = AzureNative.Storage.V20220901.AccessTier.Hot,
        AccountName = storageAccountsCaliberqueueNameParam,
        AllowBlobPublicAccess = true,
        AllowCrossTenantReplication = true,
        AllowSharedKeyAccess = true,
        DefaultToOAuthAuthentication = false,
        DnsEndpointType = "Standard",
        EnableHttpsTrafficOnly = true,
        Encryption = new AzureNative.Storage.V20220901.Inputs.EncryptionArgs
        {
            KeySource = "Microsoft.Storage",
            RequireInfrastructureEncryption = false,
            Services = new AzureNative.Storage.V20220901.Inputs.EncryptionServicesArgs
            {
                Blob = new AzureNative.Storage.V20220901.Inputs.EncryptionServiceArgs
                {
                    Enabled = true,
                    KeyType = "Account",
                },
                File = new AzureNative.Storage.V20220901.Inputs.EncryptionServiceArgs
                {
                    Enabled = true,
                    KeyType = "Account",
                },
            },
        },
        Kind = "StorageV2",
        Location = "centralindia",
        MinimumTlsVersion = "TLS1_2",
        NetworkRuleSet = new AzureNative.Storage.V20220901.Inputs.NetworkRuleSetArgs
        {
            Bypass = "AzureServices",
            DefaultAction = AzureNative.Storage.V20220901.DefaultAction.Allow,
            IpRules = new[] {},
            VirtualNetworkRules = new[] {},
        },
        PublicNetworkAccess = "Enabled",
        ResourceGroupName = resourceGroupNameParam,
        Sku = new AzureNative.Storage.V20220901.Inputs.SkuArgs
        {
            Name = "Standard_LRS",
            Tier = "Standard",
        },
    });

    var blobServiceResource = new AzureNative.Storage.V20220901.BlobServiceProperties("blobServiceResource", new()
    {
        AccountName = storageAccountResource.Name,
        BlobServicesName = $"{storageAccountsCaliberqueueNameParam}/default",
        ChangeFeed = new AzureNative.Storage.V20220901.Inputs.ChangeFeedArgs
        {
            Enabled = false,
        },
        ContainerDeleteRetentionPolicy = new AzureNative.Storage.V20220901.Inputs.DeleteRetentionPolicyArgs
        {
            Days = 7,
            Enabled = true,
        },
        Cors = new AzureNative.Storage.V20220901.Inputs.CorsRulesArgs
        {
            CorsRules = new[] {},
        },
        DeleteRetentionPolicy = new AzureNative.Storage.V20220901.Inputs.DeleteRetentionPolicyArgs
        {
            AllowPermanentDelete = false,
            Days = 7,
            Enabled = true,
        },
        IsVersioningEnabled = false,
        ResourceGroupName = resourceGroupNameParam,
        RestorePolicy = new AzureNative.Storage.V20220901.Inputs.RestorePolicyPropertiesArgs
        {
            Enabled = false,
        },
    });

    var databaseAccountsDbcaliberNameParam = config.Get("databaseAccountsDbcaliberNameParam") ?? "dbcaliber";
    var databaseAccountResource = new AzureNative.DocumentDB.V20230315.DatabaseAccount("databaseAccountResource", new()
    {
        AccountName = databaseAccountsDbcaliberNameParam,
        AnalyticalStorageConfiguration = new AzureNative.DocumentDB.V20230315.Inputs.AnalyticalStorageConfigurationArgs
        {
            SchemaType = "FullFidelity",
        },
        ApiProperties = new AzureNative.DocumentDB.V20230315.Inputs.ApiPropertiesArgs
        {
            ServerVersion = "4.2",
        },
        BackupPolicy = new AzureNative.DocumentDB.V20230315.Inputs.PeriodicModeBackupPolicyArgs
        {
            PeriodicModeProperties = new AzureNative.DocumentDB.V20230315.Inputs.PeriodicModePropertiesArgs
            {
                BackupIntervalInMinutes = 240,
                BackupRetentionIntervalInHours = 8,
                BackupStorageRedundancy = "Geo",
            },
            Type = "Periodic",
        },
        Capabilities = new[]
        {
            new AzureNative.DocumentDB.V20230315.Inputs.CapabilityArgs
            {
                Name = "EnableMongo",
            },
            new AzureNative.DocumentDB.V20230315.Inputs.CapabilityArgs
            {
                Name = "DisableRateLimitingResponses",
            },
            new AzureNative.DocumentDB.V20230315.Inputs.CapabilityArgs
            {
                Name = "EnableServerless",
            },
        },
        Capacity = new AzureNative.DocumentDB.V20230315.Inputs.CapacityArgs
        {
            TotalThroughputLimit = 4000,
        },
        ConsistencyPolicy = new AzureNative.DocumentDB.V20230315.Inputs.ConsistencyPolicyArgs
        {
            DefaultConsistencyLevel = AzureNative.DocumentDB.V20230315.DefaultConsistencyLevel.Session,
            MaxIntervalInSeconds = 5,
            MaxStalenessPrefix = 100,
        },
        Cors = new[] {},
        DatabaseAccountOfferType = AzureNative.DocumentDB.V20230315.DatabaseAccountOfferType.Standard,
        DefaultIdentity = "FirstPartyIdentity",
        DisableKeyBasedMetadataWriteAccess = false,
        DisableLocalAuth = false,
        EnableAnalyticalStorage = false,
        EnableAutomaticFailover = false,
        EnableFreeTier = false,
        EnableMultipleWriteLocations = false,
        EnablePartitionMerge = false,
        IpRules = new[] {},
        IsVirtualNetworkFilterEnabled = false,
        Kind = "MongoDB",
        Location = "Central India",
        Locations = new[]
        {
            new AzureNative.DocumentDB.V20230315.Inputs.LocationArgs
            {
                FailoverPriority = 0,
                IsZoneRedundant = true,
                LocationName = "Central India",
            },
        },
        MinimalTlsVersion = "Tls12",
        NetworkAclBypass = AzureNative.DocumentDB.V20230315.NetworkAclBypass.None,
        NetworkAclBypassResourceIds = new[] {},
        PublicNetworkAccess = "Enabled",
        ResourceGroupName = resourceGroupNameParam,
        Tags =
        {
            { "defaultExperience", "Azure Cosmos DB for MongoDB API" },
            { "hidden-cosmos-mmspecial", "" },
        },
        VirtualNetworkRules = new[] {},
    });

    var mongodbDatabaseResource = new AzureNative.DocumentDB.V20230315.MongoDBResourceMongoDBDatabase("mongodbDatabaseResource", new()
    {
        AccountName = databaseAccountResource.Name,
        DatabaseName = $"{databaseAccountsDbcaliberNameParam}/flashcard",
        Resource = new AzureNative.DocumentDB.V20230315.Inputs.MongoDBDatabaseResourceArgs
        {
            Id = "flashcard",
        },
        ResourceGroupName = resourceGroupNameParam,
    });

    var collectionResource = new AzureNative.DocumentDB.V20230315.MongoDBResourceMongoDBCollection("collectionResource", new()
    {
        AccountName = databaseAccountResource.Name,
        CollectionName = $"{databaseAccountsDbcaliberNameParam}/flashcard/do_not_delete",
        DatabaseName = mongodbDatabaseResource.Name,
        Resource = new AzureNative.DocumentDB.V20230315.Inputs.MongoDBCollectionResourceArgs
        {
            Id = "do_not_delete",
            Indexes = new[]
            {
                new AzureNative.DocumentDB.V20230315.Inputs.MongoIndexArgs
                {
                    Key = new AzureNative.DocumentDB.V20230315.Inputs.MongoIndexKeysArgs
                    {
                        Keys = new[]
                        {
                            "_id",
                        },
                    },
                },
                new AzureNative.DocumentDB.V20230315.Inputs.MongoIndexArgs
                {
                    Key = new AzureNative.DocumentDB.V20230315.Inputs.MongoIndexKeysArgs
                    {
                        Keys = new[]
                        {
                            "$**",
                        },
                    },
                },
            },
            ShardKey =
            {
                { "_id", "Hash" },
            },
        },
        ResourceGroupName = resourceGroupNameParam,
    });

    var collectionResource0 = new AzureNative.DocumentDB.V20230315.MongoDBResourceMongoDBCollection("collectionResource0", new()
    {
        AccountName = databaseAccountResource.Name,
        CollectionName = $"{databaseAccountsDbcaliberNameParam}/flashcard/FCDetails",
        DatabaseName = mongodbDatabaseResource.Name,
        Resource = new AzureNative.DocumentDB.V20230315.Inputs.MongoDBCollectionResourceArgs
        {
            Id = "FCDetails",
            Indexes = new[]
            {
                new AzureNative.DocumentDB.V20230315.Inputs.MongoIndexArgs
                {
                    Key = new AzureNative.DocumentDB.V20230315.Inputs.MongoIndexKeysArgs
                    {
                        Keys = new[]
                        {
                            "_id",
                        },
                    },
                },
            },
        },
        ResourceGroupName = resourceGroupNameParam,
    });

    var fileServiceResource = new AzureNative.Storage.V20220901.FileServiceProperties("fileServiceResource", new()
    {
        AccountName = storageAccountResource.Name,
        Cors = new AzureNative.Storage.V20220901.Inputs.CorsRulesArgs
        {
            CorsRules = new[] {},
        },
        FileServicesName = $"{storageAccountsCaliberqueueNameParam}/default",
        ProtocolSettings = new AzureNative.Storage.V20220901.Inputs.ProtocolSettingsArgs
        {
            Smb = null,
        },
        ResourceGroupName = resourceGroupNameParam,
        ShareDeleteRetentionPolicy = new AzureNative.Storage.V20220901.Inputs.DeleteRetentionPolicyArgs
        {
            Days = 7,
            Enabled = true,
        },
    });

    var queueResource = null;

    var queueServiceResource = new AzureNative.Storage.V20220901.QueueServiceProperties("queueServiceResource", new()
    {
        AccountName = storageAccountResource.Name,
        Cors = new AzureNative.Storage.V20220901.Inputs.CorsRulesArgs
        {
            CorsRules = new[] {},
        },
        QueueServiceName = $"{storageAccountsCaliberqueueNameParam}/default",
        ResourceGroupName = resourceGroupNameParam,
    });

    var tableServiceResource = new AzureNative.Storage.V20220901.TableServiceProperties("tableServiceResource", new()
    {
        AccountName = storageAccountResource.Name,
        Cors = new AzureNative.Storage.V20220901.Inputs.CorsRulesArgs
        {
            CorsRules = new[] {},
        },
        ResourceGroupName = resourceGroupNameParam,
        TableServiceName = $"{storageAccountsCaliberqueueNameParam}/default",
    });
});
VenkateshSrini commented 1 year ago

@thomas11 I'm also using the same input files. One thing is I'm on window 11 and using powershell. Could you please check the window version please

VenkateshSrini commented 1 year ago

@thomas11 , Please see the attached video that I had made for you to see issue

https://user-images.githubusercontent.com/1167152/236369081-225660ad-43ee-469c-8b81-ae69b18b351d.mp4

VenkateshSrini commented 1 year ago

@thomas11 , I have downloaded the Linux version of the code and tried the same from Linux subsystem. I used the command arm2pulumi-linux/arm2pulumi template.json dotnet. I get the below error

config resourceGroupNameParam string { }

config storageAccountsCaliberqueueNameParam string { default = "caliberqueue" }

resource storageAccountResource "azure-native:storage/v20220901:StorageAccount" { accessTier = "Hot" accountName = storageAccountsCaliberqueueNameParam allowBlobPublicAccess = true allowCrossTenantReplication = true allowSharedKeyAccess = true defaultToOAuthAuthentication = false dnsEndpointType = "Standard" enableHttpsTrafficOnly = true encryption = { keySource = "Microsoft.Storage", requireInfrastructureEncryption = false,

        services = {
                 blob = {
                        enabled = true,
                         keyType = "Account"
                 },
                 file = {
                       enabled = true,
                     keyType = "Account"
                 }
         }
 }
 kind = "StorageV2"
 location = "centralindia"
 minimumTlsVersion = "TLS1_2"
 networkRuleSet = {
          bypass = "AzureServices",
          defaultAction = "Allow",
         ipRules = [],
           virtualNetworkRules = []
   }
   publicNetworkAccess = "Enabled"
   resourceGroupName = resourceGroupNameParam
   sku = {
           name = "Standard_LRS",
           tier = "Standard"
   }

}

resource blobServiceResource "azure-native:storage/v20220901:BlobServiceProperties" { accountName = storageAccountResource.name blobServicesName = "${storageAccountsCaliberqueueNameParam}/default" changeFeed = { enabled = false } containerDeleteRetentionPolicy = { days = 7, enabled = true } cors = { corsRules = [] } deleteRetentionPolicy = { allowPermanentDelete = false, days = 7, enabled = true } isVersioningEnabled = false resourceGroupName = resourceGroupNameParam restorePolicy = { enabled = false } }

config databaseAccountsDbcaliberNameParam string { default = "dbcaliber" }

resource databaseAccountResource "azure-native:documentdb/v20230315:DatabaseAccount" { accountName = databaseAccountsDbcaliberNameParam analyticalStorageConfiguration = { schemaType = "FullFidelity" } apiProperties = { serverVersion = "4.2" } backupPolicy = { periodicModeProperties = { backupIntervalInMinutes = 240, backupRetentionIntervalInHours = 8, backupStorageRedundancy = "Geo" }, type = "Periodic" } capabilities = [ { name = "EnableMongo" }, { name = "DisableRateLimitingResponses" }, { name = "EnableServerless" } ] capacity = { totalThroughputLimit = 4000 } consistencyPolicy = { defaultConsistencyLevel = "Session", maxIntervalInSeconds = 5, maxStalenessPrefix = 100 } cors = [] databaseAccountOfferType = "Standard" defaultIdentity = "FirstPartyIdentity" disableKeyBasedMetadataWriteAccess = false disableLocalAuth = false enableAnalyticalStorage = false enableAutomaticFailover = false enableFreeTier = false enableMultipleWriteLocations = false enablePartitionMerge = false ipRules = [] isVirtualNetworkFilterEnabled = false kind = "MongoDB" location = "Central India" locations = [{ failoverPriority = 0, isZoneRedundant = true, locationName = "Central India" }] minimalTlsVersion = "Tls12" networkAclBypass = "None" networkAclBypassResourceIds = [] publicNetworkAccess = "Enabled" resourceGroupName = resourceGroupNameParam tags = { defaultExperience = "Azure Cosmos DB for MongoDB API", hidden-cosmos-mmspecial = "" } virtualNetworkRules = [] }

resource mongodbDatabaseResource "azure-native:documentdb/v20230315:MongoDBResourceMongoDBDatabase" { accountName = databaseAccountResource.name databaseName = "${databaseAccountsDbcaliberNameParam}/flashcard" resource = { id = "flashcard" } resourceGroupName = resourceGroupNameParam }

resource collectionResource "azure-native:documentdb/v20230315:MongoDBResourceMongoDBCollection" { accountName = databaseAccountResource.name collectionName = "${databaseAccountsDbcaliberNameParam}/flashcard/do_not_delete" databaseName = mongodbDatabaseResource.name resource = {

         id = "do_not_delete",
            indexes = [
                    {
                            key = {
                                    keys = ["_id"]
                            }
                    },
                    {
                            key = {
                                    keys = ["$**"]
                            }
                    }
            ],
            shardKey = {
                    _id = "Hash"
            }
    }
    resourceGroupName = resourceGroupNameParam

}

resource collectionResource0 "azure-native:documentdb/v20230315:MongoDBResourceMongoDBCollection" { accountName = databaseAccountResource.name collectionName = "${databaseAccountsDbcaliberNameParam}/flashcard/FCDetails" databaseName = mongodbDatabaseResource.name resource = { id = "FCDetails", indexes = [{ key = { keys = ["_id"] } }] } resourceGroupName = resourceGroupNameParam }

resource fileServiceResource "azure-native:storage/v20220901:FileServiceProperties" { accountName = storageAccountResource.name cors = { corsRules = [] } fileServicesName = "${storageAccountsCaliberqueueNameParam}/default" protocolSettings = { smb = {} } resourceGroupName = resourceGroupNameParam shareDeleteRetentionPolicy = { days = 7, enabled = true } }

queueResource = null

resource queueServiceResource "azure-native:storage/v20220901:QueueServiceProperties" { accountName = storageAccountResource.name cors = { corsRules = [] } queueServiceName = "${storageAccountsCaliberqueueNameParam}/default" resourceGroupName = resourceGroupNameParam }

resource tableServiceResource "azure-native:storage/v20220901:TableServiceProperties" { accountName = storageAccountResource.name cors = { corsRules = [] } resourceGroupName = resourceGroupNameParam tableServiceName = "${storageAccountsCaliberqueueNameParam}/default" }

Error: unknown property 'tier' among [name]

on program.pp line 43: 44: tier = "Standard"

Error: unknown property 'tier' among [name]

on program.pp line 43: 44: tier = "Standard"

** Error: cannot traverse value of type union(object({name = union(enum(azure-native:storage/v20220901:SkuName(string): cty.StringVal("Standard_LRS"),cty.StringVal("Standard_GRS"),cty.StringVal("Standard_RAGRS"),cty.StringVal("Standard_ZRS"),cty.StringVal("Premium_LRS"),cty.StringVal("Premium_ZRS"),cty.StringVal("Standard_GZRS"),cty.StringVal("Standard_RAGZRS")), output(enum(azure-native:storage/v20220901:SkuName(string): cty.StringVal("Standard_LRS"),cty.StringVal("Standard_GRS"),cty.StringVal("Standard_RAGRS"),cty.StringVal("Standard_ZRS"),cty.StringVal("Premium_LRS"),cty.StringVal("Premium_ZRS"),cty.StringVal("Standard_GZRS"),cty.StringVal("Standard_RAGZRS"))), output(string), output(union(enum(azure-native:storage/v20220901:SkuName(string): cty.StringVal("Standard_LRS"),cty.StringVal("Standard_GRS"),cty.StringVal("Standard_RAGRS"),cty.StringVal("Standard_ZRS"),cty.StringVal("Premium_LRS"),cty.StringVal("Premium_ZRS"),cty.StringVal("Standard_GZRS"),cty.StringVal("Standard_RAGZRS")), string)), string, annotated(0xc047a19980))}, annotated(0xc047a19500)), output(object({name = union(enum(azure-native:storage/v20220901:SkuName(string): cty.StringVal("Standard_LRS"),cty.StringVal("Standard_GRS"),cty.StringVal("Standard_RAGRS"),cty.StringVal("Standard_ZRS"),cty.StringVal("Premium_LRS"),cty.StringVal("Premium_ZRS"),cty.StringVal("Standard_GZRS"),cty.StringVal("Standard_RAGZRS")), string)}, annotated(0xc047a199c0))), annotated(0xc047a19a80))

on program.pp line 43: 44: tier = "Standard" **

But one good thing is that I got a fair output

using System.Collections.Generic;
using Pulumi;
using AzureNative = Pulumi.AzureNative;

return await Deployment.RunAsync(() =>
{
    var config = new Config();
    var resourceGroupNameParam = config.Require("resourceGroupNameParam");
    var storageAccountsCaliberqueueNameParam = config.Get("storageAccountsCaliberqueueNameParam") ?? "caliberqueue";
    var storageAccountResource = new AzureNative.Storage.V20220901.StorageAccount("storageAccountResource", new()
    {
        AccessTier = AzureNative.Storage.V20220901.AccessTier.Hot,
        AccountName = storageAccountsCaliberqueueNameParam,
        AllowBlobPublicAccess = true,
        AllowCrossTenantReplication = true,
        AllowSharedKeyAccess = true,
        DefaultToOAuthAuthentication = false,
        DnsEndpointType = "Standard",
        EnableHttpsTrafficOnly = true,
        Encryption = new AzureNative.Storage.V20220901.Inputs.EncryptionArgs
        {
            KeySource = "Microsoft.Storage",
            RequireInfrastructureEncryption = false,
            Services = new AzureNative.Storage.V20220901.Inputs.EncryptionServicesArgs
            {
                Blob = new AzureNative.Storage.V20220901.Inputs.EncryptionServiceArgs
                {
                    Enabled = true,
                    KeyType = "Account",
                },
                File = new AzureNative.Storage.V20220901.Inputs.EncryptionServiceArgs
                {
                    Enabled = true,
                    KeyType = "Account",
                },
            },
        },
        Kind = "StorageV2",
        Location = "centralindia",
        MinimumTlsVersion = "TLS1_2",
        NetworkRuleSet = new AzureNative.Storage.V20220901.Inputs.NetworkRuleSetArgs
        {
            Bypass = "AzureServices",
            DefaultAction = AzureNative.Storage.V20220901.DefaultAction.Allow,
            IpRules = new[] {},
            VirtualNetworkRules = new[] {},
        },
        PublicNetworkAccess = "Enabled",
        ResourceGroupName = resourceGroupNameParam,
        Sku = new AzureNative.Storage.V20220901.Inputs.SkuArgs
        {
            Name = "Standard_LRS",
            Tier = "Standard",
        },
    });

    var blobServiceResource = new AzureNative.Storage.V20220901.BlobServiceProperties("blobServiceResource", new()
    {
        AccountName = storageAccountResource.Name,
        BlobServicesName = $"{storageAccountsCaliberqueueNameParam}/default",
        ChangeFeed = new AzureNative.Storage.V20220901.Inputs.ChangeFeedArgs
        {
            Enabled = false,
        },
        ContainerDeleteRetentionPolicy = new AzureNative.Storage.V20220901.Inputs.DeleteRetentionPolicyArgs
        {
            Days = 7,
            Enabled = true,
        },
        Cors = new AzureNative.Storage.V20220901.Inputs.CorsRulesArgs
        {
            CorsRules = new[] {},
        },
        DeleteRetentionPolicy = new AzureNative.Storage.V20220901.Inputs.DeleteRetentionPolicyArgs
        {
            AllowPermanentDelete = false,
            Days = 7,
            Enabled = true,
        },
        IsVersioningEnabled = false,
        ResourceGroupName = resourceGroupNameParam,
        RestorePolicy = new AzureNative.Storage.V20220901.Inputs.RestorePolicyPropertiesArgs
        {
            Enabled = false,
        },
    });

    var databaseAccountsDbcaliberNameParam = config.Get("databaseAccountsDbcaliberNameParam") ?? "dbcaliber";
    var databaseAccountResource = new AzureNative.DocumentDB.V20230315.DatabaseAccount("databaseAccountResource", new()
    {
        AccountName = databaseAccountsDbcaliberNameParam,
        AnalyticalStorageConfiguration = new AzureNative.DocumentDB.V20230315.Inputs.AnalyticalStorageConfigurationArgs
        {
            SchemaType = "FullFidelity",
        },
        ApiProperties = new AzureNative.DocumentDB.V20230315.Inputs.ApiPropertiesArgs
        {
            ServerVersion = "4.2",
        },
        BackupPolicy = new AzureNative.DocumentDB.V20230315.Inputs.PeriodicModeBackupPolicyArgs
        {
            PeriodicModeProperties = new AzureNative.DocumentDB.V20230315.Inputs.PeriodicModePropertiesArgs
            {
                BackupIntervalInMinutes = 240,
                BackupRetentionIntervalInHours = 8,
                BackupStorageRedundancy = "Geo",
            },
            Type = "Periodic",
        },
        Capabilities = new[]
        {
            new AzureNative.DocumentDB.V20230315.Inputs.CapabilityArgs
            {
                Name = "EnableMongo",
            },
            new AzureNative.DocumentDB.V20230315.Inputs.CapabilityArgs
            {
                Name = "DisableRateLimitingResponses",
            },
            new AzureNative.DocumentDB.V20230315.Inputs.CapabilityArgs
            {
                Name = "EnableServerless",
            },
        },
        Capacity = new AzureNative.DocumentDB.V20230315.Inputs.CapacityArgs
        {
            TotalThroughputLimit = 4000,
        },
        ConsistencyPolicy = new AzureNative.DocumentDB.V20230315.Inputs.ConsistencyPolicyArgs
        {
            DefaultConsistencyLevel = AzureNative.DocumentDB.V20230315.DefaultConsistencyLevel.Session,
            MaxIntervalInSeconds = 5,
            MaxStalenessPrefix = 100,
        },
        Cors = new[] {},
        DatabaseAccountOfferType = AzureNative.DocumentDB.V20230315.DatabaseAccountOfferType.Standard,
        DefaultIdentity = "FirstPartyIdentity",
        DisableKeyBasedMetadataWriteAccess = false,
        DisableLocalAuth = false,
        EnableAnalyticalStorage = false,
        EnableAutomaticFailover = false,
        EnableFreeTier = false,
        EnableMultipleWriteLocations = false,
        EnablePartitionMerge = false,
        IpRules = new[] {},
        IsVirtualNetworkFilterEnabled = false,
        Kind = "MongoDB",
        Location = "Central India",
        Locations = new[]
        {
            new AzureNative.DocumentDB.V20230315.Inputs.LocationArgs
            {
                FailoverPriority = 0,
                IsZoneRedundant = true,
                LocationName = "Central India",
            },
        },
        MinimalTlsVersion = "Tls12",
        NetworkAclBypass = AzureNative.DocumentDB.V20230315.NetworkAclBypass.None,
        NetworkAclBypassResourceIds = new[] {},
        PublicNetworkAccess = "Enabled",
        ResourceGroupName = resourceGroupNameParam,
        Tags =
        {
            { "defaultExperience", "Azure Cosmos DB for MongoDB API" },
            { "hidden-cosmos-mmspecial", "" },
        },
        VirtualNetworkRules = new[] {},
    });

    var mongodbDatabaseResource = new AzureNative.DocumentDB.V20230315.MongoDBResourceMongoDBDatabase("mongodbDatabaseResource", new()
    {
        AccountName = databaseAccountResource.Name,
        DatabaseName = $"{databaseAccountsDbcaliberNameParam}/flashcard",
        Resource = new AzureNative.DocumentDB.V20230315.Inputs.MongoDBDatabaseResourceArgs
        {
            Id = "flashcard",
        },
        ResourceGroupName = resourceGroupNameParam,
    });

    var collectionResource = new AzureNative.DocumentDB.V20230315.MongoDBResourceMongoDBCollection("collectionResource", new()
    {
        AccountName = databaseAccountResource.Name,
        CollectionName = $"{databaseAccountsDbcaliberNameParam}/flashcard/do_not_delete",
        DatabaseName = mongodbDatabaseResource.Name,
        Resource = new AzureNative.DocumentDB.V20230315.Inputs.MongoDBCollectionResourceArgs
        {
            Id = "do_not_delete",
            Indexes = new[]
            {
                new AzureNative.DocumentDB.V20230315.Inputs.MongoIndexArgs
                {
                    Key = new AzureNative.DocumentDB.V20230315.Inputs.MongoIndexKeysArgs
                    {
                        Keys = new[]
                        {
                            "_id",
                        },
                    },
                },
                new AzureNative.DocumentDB.V20230315.Inputs.MongoIndexArgs
                {
                    Key = new AzureNative.DocumentDB.V20230315.Inputs.MongoIndexKeysArgs
                    {
                        Keys = new[]
                        {
                            "$**",
                        },
                    },
                },
            },
            ShardKey =
            {
                { "_id", "Hash" },
            },
        },
        ResourceGroupName = resourceGroupNameParam,
    });

    var collectionResource0 = new AzureNative.DocumentDB.V20230315.MongoDBResourceMongoDBCollection("collectionResource0", new()
    {
        AccountName = databaseAccountResource.Name,
        CollectionName = $"{databaseAccountsDbcaliberNameParam}/flashcard/FCDetails",
        DatabaseName = mongodbDatabaseResource.Name,
        Resource = new AzureNative.DocumentDB.V20230315.Inputs.MongoDBCollectionResourceArgs
        {
            Id = "FCDetails",
            Indexes = new[]
            {
                new AzureNative.DocumentDB.V20230315.Inputs.MongoIndexArgs
                {
                    Key = new AzureNative.DocumentDB.V20230315.Inputs.MongoIndexKeysArgs
                    {
                        Keys = new[]
                        {
                            "_id",
                        },
                    },
                },
            },
        },
        ResourceGroupName = resourceGroupNameParam,
    });

    var fileServiceResource = new AzureNative.Storage.V20220901.FileServiceProperties("fileServiceResource", new()
    {
        AccountName = storageAccountResource.Name,
        Cors = new AzureNative.Storage.V20220901.Inputs.CorsRulesArgs
        {
            CorsRules = new[] {},
        },
        FileServicesName = $"{storageAccountsCaliberqueueNameParam}/default",
        ProtocolSettings = new AzureNative.Storage.V20220901.Inputs.ProtocolSettingsArgs
        {
            Smb = null,
        },
        ResourceGroupName = resourceGroupNameParam,
        ShareDeleteRetentionPolicy = new AzureNative.Storage.V20220901.Inputs.DeleteRetentionPolicyArgs
        {
            Days = 7,
            Enabled = true,
        },
    });

    var queueResource = null;

    var queueServiceResource = new AzureNative.Storage.V20220901.QueueServiceProperties("queueServiceResource", new()
    {
        AccountName = storageAccountResource.Name,
        Cors = new AzureNative.Storage.V20220901.Inputs.CorsRulesArgs
        {
            CorsRules = new[] {},
        },
        QueueServiceName = $"{storageAccountsCaliberqueueNameParam}/default",
        ResourceGroupName = resourceGroupNameParam,
    });

    var tableServiceResource = new AzureNative.Storage.V20220901.TableServiceProperties("tableServiceResource", new()
    {
        AccountName = storageAccountResource.Name,
        Cors = new AzureNative.Storage.V20220901.Inputs.CorsRulesArgs
        {
            CorsRules = new[] {},
        },
        ResourceGroupName = resourceGroupNameParam,
        TableServiceName = $"{storageAccountsCaliberqueueNameParam}/default",
    });

});

So I suspect the issue is with Windows 11 executable.

mikhailshilkov commented 11 months ago

The standalone arm2pulumi tool has been deprecated in favor of the Pulumi CLI built-in command pulumi convert --from arm. Therefore, I'm closing all issues in this repository as "won't fix". Please file any issue related to pulumi convert in https://github.com/pulumi/pulumi/issues/