"use strict";
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ManagedInstance = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
 * Manages a Microsoft SQL Azure Managed Instance.
 *
 * > **Note:** All arguments including the administrator login and password will be stored in the raw state as plain-text. [Read more about sensitive data in state](https://www.terraform.io/docs/state/sensitive-data.html).
 *
 * > **Note:** SQL Managed Instance needs permission to read Azure Active Directory when configuring the AAD administrator. [Read more about provisioning AAD administrators](https://learn.microsoft.com/en-us/azure/azure-sql/database/authentication-aad-configure?view=azuresql#provision-azure-ad-admin-sql-managed-instance).
 *
 * ## Example Usage
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 *
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "database-rg",
 *     location: "West Europe",
 * });
 * const exampleNetworkSecurityGroup = new azure.network.NetworkSecurityGroup("example", {
 *     name: "mi-security-group",
 *     location: example.location,
 *     resourceGroupName: example.name,
 * });
 * const allowManagementInbound = new azure.network.NetworkSecurityRule("allow_management_inbound", {
 *     name: "allow_management_inbound",
 *     priority: 106,
 *     direction: "Inbound",
 *     access: "Allow",
 *     protocol: "Tcp",
 *     sourcePortRange: "*",
 *     destinationPortRanges: [
 *         "9000",
 *         "9003",
 *         "1438",
 *         "1440",
 *         "1452",
 *     ],
 *     sourceAddressPrefix: "*",
 *     destinationAddressPrefix: "*",
 *     resourceGroupName: example.name,
 *     networkSecurityGroupName: exampleNetworkSecurityGroup.name,
 * });
 * const allowMisubnetInbound = new azure.network.NetworkSecurityRule("allow_misubnet_inbound", {
 *     name: "allow_misubnet_inbound",
 *     priority: 200,
 *     direction: "Inbound",
 *     access: "Allow",
 *     protocol: "*",
 *     sourcePortRange: "*",
 *     destinationPortRange: "*",
 *     sourceAddressPrefix: "10.0.0.0/24",
 *     destinationAddressPrefix: "*",
 *     resourceGroupName: example.name,
 *     networkSecurityGroupName: exampleNetworkSecurityGroup.name,
 * });
 * const allowHealthProbeInbound = new azure.network.NetworkSecurityRule("allow_health_probe_inbound", {
 *     name: "allow_health_probe_inbound",
 *     priority: 300,
 *     direction: "Inbound",
 *     access: "Allow",
 *     protocol: "*",
 *     sourcePortRange: "*",
 *     destinationPortRange: "*",
 *     sourceAddressPrefix: "AzureLoadBalancer",
 *     destinationAddressPrefix: "*",
 *     resourceGroupName: example.name,
 *     networkSecurityGroupName: exampleNetworkSecurityGroup.name,
 * });
 * const allowTdsInbound = new azure.network.NetworkSecurityRule("allow_tds_inbound", {
 *     name: "allow_tds_inbound",
 *     priority: 1000,
 *     direction: "Inbound",
 *     access: "Allow",
 *     protocol: "Tcp",
 *     sourcePortRange: "*",
 *     destinationPortRange: "1433",
 *     sourceAddressPrefix: "VirtualNetwork",
 *     destinationAddressPrefix: "*",
 *     resourceGroupName: example.name,
 *     networkSecurityGroupName: exampleNetworkSecurityGroup.name,
 * });
 * const denyAllInbound = new azure.network.NetworkSecurityRule("deny_all_inbound", {
 *     name: "deny_all_inbound",
 *     priority: 4096,
 *     direction: "Inbound",
 *     access: "Deny",
 *     protocol: "*",
 *     sourcePortRange: "*",
 *     destinationPortRange: "*",
 *     sourceAddressPrefix: "*",
 *     destinationAddressPrefix: "*",
 *     resourceGroupName: example.name,
 *     networkSecurityGroupName: exampleNetworkSecurityGroup.name,
 * });
 * const allowManagementOutbound = new azure.network.NetworkSecurityRule("allow_management_outbound", {
 *     name: "allow_management_outbound",
 *     priority: 102,
 *     direction: "Outbound",
 *     access: "Allow",
 *     protocol: "Tcp",
 *     sourcePortRange: "*",
 *     destinationPortRanges: [
 *         "80",
 *         "443",
 *         "12000",
 *     ],
 *     sourceAddressPrefix: "*",
 *     destinationAddressPrefix: "*",
 *     resourceGroupName: example.name,
 *     networkSecurityGroupName: exampleNetworkSecurityGroup.name,
 * });
 * const allowMisubnetOutbound = new azure.network.NetworkSecurityRule("allow_misubnet_outbound", {
 *     name: "allow_misubnet_outbound",
 *     priority: 200,
 *     direction: "Outbound",
 *     access: "Allow",
 *     protocol: "*",
 *     sourcePortRange: "*",
 *     destinationPortRange: "*",
 *     sourceAddressPrefix: "10.0.0.0/24",
 *     destinationAddressPrefix: "*",
 *     resourceGroupName: example.name,
 *     networkSecurityGroupName: exampleNetworkSecurityGroup.name,
 * });
 * const denyAllOutbound = new azure.network.NetworkSecurityRule("deny_all_outbound", {
 *     name: "deny_all_outbound",
 *     priority: 4096,
 *     direction: "Outbound",
 *     access: "Deny",
 *     protocol: "*",
 *     sourcePortRange: "*",
 *     destinationPortRange: "*",
 *     sourceAddressPrefix: "*",
 *     destinationAddressPrefix: "*",
 *     resourceGroupName: example.name,
 *     networkSecurityGroupName: exampleNetworkSecurityGroup.name,
 * });
 * const exampleVirtualNetwork = new azure.network.VirtualNetwork("example", {
 *     name: "vnet-mi",
 *     resourceGroupName: example.name,
 *     addressSpaces: ["10.0.0.0/16"],
 *     location: example.location,
 * });
 * const exampleSubnet = new azure.network.Subnet("example", {
 *     name: "subnet-mi",
 *     resourceGroupName: example.name,
 *     virtualNetworkName: exampleVirtualNetwork.name,
 *     addressPrefixes: ["10.0.0.0/24"],
 *     delegations: [{
 *         name: "managedinstancedelegation",
 *         serviceDelegation: {
 *             name: "Microsoft.Sql/managedInstances",
 *             actions: [
 *                 "Microsoft.Network/virtualNetworks/subnets/join/action",
 *                 "Microsoft.Network/virtualNetworks/subnets/prepareNetworkPolicies/action",
 *                 "Microsoft.Network/virtualNetworks/subnets/unprepareNetworkPolicies/action",
 *             ],
 *         },
 *     }],
 * });
 * const exampleSubnetNetworkSecurityGroupAssociation = new azure.network.SubnetNetworkSecurityGroupAssociation("example", {
 *     subnetId: exampleSubnet.id,
 *     networkSecurityGroupId: exampleNetworkSecurityGroup.id,
 * });
 * const exampleRouteTable = new azure.network.RouteTable("example", {
 *     name: "routetable-mi",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     bgpRoutePropagationEnabled: true,
 * }, {
 *     dependsOn: [exampleSubnet],
 * });
 * const exampleSubnetRouteTableAssociation = new azure.network.SubnetRouteTableAssociation("example", {
 *     subnetId: exampleSubnet.id,
 *     routeTableId: exampleRouteTable.id,
 * });
 * const exampleManagedInstance = new azure.mssql.ManagedInstance("example", {
 *     name: "managedsqlinstance",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     licenseType: "BasePrice",
 *     skuName: "GP_Gen5",
 *     storageSizeInGb: 32,
 *     subnetId: exampleSubnet.id,
 *     vcores: 4,
 *     administratorLogin: "mradministrator",
 *     administratorLoginPassword: "thisIsDog11",
 * }, {
 *     dependsOn: [
 *         exampleSubnetNetworkSecurityGroupAssociation,
 *         exampleSubnetRouteTableAssociation,
 *     ],
 * });
 * ```
 *
 * ## API Providers
 *
 * <!-- This section is generated, changes will be overwritten -->
 * This resource uses the following Azure API Providers:
 *
 * * `Microsoft.Sql` - 2023-08-01-preview
 *
 * ## Import
 *
 * Microsoft SQL Managed Instances can be imported using the `resource id`, e.g.
 *
 * ```sh
 * $ pulumi import azure:mssql/managedInstance:ManagedInstance example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.Sql/managedInstances/myserver
 * ```
 */
class ManagedInstance extends pulumi.CustomResource {
    /**
     * Get an existing ManagedInstance resource's state with the given name, ID, and optional extra
     * properties used to qualify the lookup.
     *
     * @param name The _unique_ name of the resulting resource.
     * @param id The _unique_ provider ID of the resource to lookup.
     * @param state Any extra arguments used during the lookup.
     * @param opts Optional settings to control the behavior of the CustomResource.
     */
    static get(name, id, state, opts) {
        return new ManagedInstance(name, state, { ...opts, id: id });
    }
    /** @internal */
    static __pulumiType = 'azure:mssql/managedInstance:ManagedInstance';
    /**
     * Returns true if the given object is an instance of ManagedInstance.  This is designed to work even
     * when multiple copies of the Pulumi SDK have been loaded into the same process.
     */
    static isInstance(obj) {
        if (obj === undefined || obj === null) {
            return false;
        }
        return obj['__pulumiType'] === ManagedInstance.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["administratorLogin"] = state?.administratorLogin;
            resourceInputs["administratorLoginPassword"] = state?.administratorLoginPassword;
            resourceInputs["azureActiveDirectoryAdministrator"] = state?.azureActiveDirectoryAdministrator;
            resourceInputs["collation"] = state?.collation;
            resourceInputs["databaseFormat"] = state?.databaseFormat;
            resourceInputs["dnsZone"] = state?.dnsZone;
            resourceInputs["dnsZonePartnerId"] = state?.dnsZonePartnerId;
            resourceInputs["fqdn"] = state?.fqdn;
            resourceInputs["generalPurposeV2Enabled"] = state?.generalPurposeV2Enabled;
            resourceInputs["hybridSecondaryUsage"] = state?.hybridSecondaryUsage;
            resourceInputs["identity"] = state?.identity;
            resourceInputs["licenseType"] = state?.licenseType;
            resourceInputs["location"] = state?.location;
            resourceInputs["maintenanceConfigurationName"] = state?.maintenanceConfigurationName;
            resourceInputs["minimumTlsVersion"] = state?.minimumTlsVersion;
            resourceInputs["name"] = state?.name;
            resourceInputs["proxyOverride"] = state?.proxyOverride;
            resourceInputs["publicDataEndpointEnabled"] = state?.publicDataEndpointEnabled;
            resourceInputs["resourceGroupName"] = state?.resourceGroupName;
            resourceInputs["servicePrincipalType"] = state?.servicePrincipalType;
            resourceInputs["skuName"] = state?.skuName;
            resourceInputs["storageAccountType"] = state?.storageAccountType;
            resourceInputs["storageSizeInGb"] = state?.storageSizeInGb;
            resourceInputs["subnetId"] = state?.subnetId;
            resourceInputs["tags"] = state?.tags;
            resourceInputs["timezoneId"] = state?.timezoneId;
            resourceInputs["vcores"] = state?.vcores;
            resourceInputs["zoneRedundantEnabled"] = state?.zoneRedundantEnabled;
        }
        else {
            const args = argsOrState;
            if (args?.licenseType === undefined && !opts.urn) {
                throw new Error("Missing required property 'licenseType'");
            }
            if (args?.resourceGroupName === undefined && !opts.urn) {
                throw new Error("Missing required property 'resourceGroupName'");
            }
            if (args?.skuName === undefined && !opts.urn) {
                throw new Error("Missing required property 'skuName'");
            }
            if (args?.storageSizeInGb === undefined && !opts.urn) {
                throw new Error("Missing required property 'storageSizeInGb'");
            }
            if (args?.subnetId === undefined && !opts.urn) {
                throw new Error("Missing required property 'subnetId'");
            }
            if (args?.vcores === undefined && !opts.urn) {
                throw new Error("Missing required property 'vcores'");
            }
            resourceInputs["administratorLogin"] = args?.administratorLogin;
            resourceInputs["administratorLoginPassword"] = args?.administratorLoginPassword ? pulumi.secret(args.administratorLoginPassword) : undefined;
            resourceInputs["azureActiveDirectoryAdministrator"] = args?.azureActiveDirectoryAdministrator;
            resourceInputs["collation"] = args?.collation;
            resourceInputs["databaseFormat"] = args?.databaseFormat;
            resourceInputs["dnsZonePartnerId"] = args?.dnsZonePartnerId;
            resourceInputs["generalPurposeV2Enabled"] = args?.generalPurposeV2Enabled;
            resourceInputs["hybridSecondaryUsage"] = args?.hybridSecondaryUsage;
            resourceInputs["identity"] = args?.identity;
            resourceInputs["licenseType"] = args?.licenseType;
            resourceInputs["location"] = args?.location;
            resourceInputs["maintenanceConfigurationName"] = args?.maintenanceConfigurationName;
            resourceInputs["minimumTlsVersion"] = args?.minimumTlsVersion;
            resourceInputs["name"] = args?.name;
            resourceInputs["proxyOverride"] = args?.proxyOverride;
            resourceInputs["publicDataEndpointEnabled"] = args?.publicDataEndpointEnabled;
            resourceInputs["resourceGroupName"] = args?.resourceGroupName;
            resourceInputs["servicePrincipalType"] = args?.servicePrincipalType;
            resourceInputs["skuName"] = args?.skuName;
            resourceInputs["storageAccountType"] = args?.storageAccountType;
            resourceInputs["storageSizeInGb"] = args?.storageSizeInGb;
            resourceInputs["subnetId"] = args?.subnetId;
            resourceInputs["tags"] = args?.tags;
            resourceInputs["timezoneId"] = args?.timezoneId;
            resourceInputs["vcores"] = args?.vcores;
            resourceInputs["zoneRedundantEnabled"] = args?.zoneRedundantEnabled;
            resourceInputs["dnsZone"] = undefined /*out*/;
            resourceInputs["fqdn"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        const aliasOpts = { aliases: [{ type: "azure:sql/managedInstance:ManagedInstance" }] };
        opts = pulumi.mergeOptions(opts, aliasOpts);
        const secretOpts = { additionalSecretOutputs: ["administratorLoginPassword"] };
        opts = pulumi.mergeOptions(opts, secretOpts);
        super(ManagedInstance.__pulumiType, name, resourceInputs, opts);
    }
}
exports.ManagedInstance = ManagedInstance;
//# sourceMappingURL=managedInstance.js.map