"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.RunCommand = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
 * Manages a Virtual Machine Run Command.
 *
 * ## Example Usage
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 *
 * const exampleResourceGroup = new azure.core.ResourceGroup("example", {
 *     name: "example-resources",
 *     location: "West Europe",
 * });
 * const exampleVirtualNetwork = new azure.network.VirtualNetwork("example", {
 *     name: "example-vnet",
 *     addressSpaces: ["10.0.0.0/16"],
 *     location: exampleResourceGroup.location,
 *     resourceGroupName: exampleResourceGroup.name,
 * });
 * const exampleSubnet = new azure.network.Subnet("example", {
 *     name: "internal",
 *     resourceGroupName: exampleResourceGroup.name,
 *     virtualNetworkName: exampleVirtualNetwork.name,
 *     addressPrefixes: ["10.0.2.0/24"],
 * });
 * const exampleNetworkInterface = new azure.network.NetworkInterface("example", {
 *     name: "example-nic",
 *     location: exampleResourceGroup.location,
 *     resourceGroupName: exampleResourceGroup.name,
 *     ipConfigurations: [{
 *         name: "internal",
 *         subnetId: exampleSubnet.id,
 *         privateIpAddressAllocation: "Dynamic",
 *     }],
 * });
 * const exampleUserAssignedIdentity = new azure.authorization.UserAssignedIdentity("example", {
 *     name: "example-uai",
 *     resourceGroupName: exampleResourceGroup.name,
 *     location: exampleResourceGroup.location,
 * });
 * const exampleLinuxVirtualMachine = new azure.compute.LinuxVirtualMachine("example", {
 *     name: "example-VM",
 *     resourceGroupName: exampleResourceGroup.name,
 *     location: exampleResourceGroup.location,
 *     size: "Standard_B2s",
 *     adminUsername: "adminuser",
 *     adminPassword: "P@$$w0rd1234!",
 *     disablePasswordAuthentication: false,
 *     networkInterfaceIds: [exampleNetworkInterface.id],
 *     osDisk: {
 *         caching: "ReadWrite",
 *         storageAccountType: "Premium_LRS",
 *     },
 *     sourceImageReference: {
 *         publisher: "Canonical",
 *         offer: "0001-com-ubuntu-server-jammy",
 *         sku: "22_04-lts",
 *         version: "latest",
 *     },
 *     identity: {
 *         type: "SystemAssigned, UserAssigned",
 *         identityIds: [exampleUserAssignedIdentity.id],
 *     },
 * });
 * const exampleAccount = new azure.storage.Account("example", {
 *     name: "exampleaccount",
 *     resourceGroupName: exampleResourceGroup.name,
 *     location: exampleResourceGroup.location,
 *     accountTier: "Standard",
 *     accountReplicationType: "LRS",
 * });
 * const exampleAssignment = new azure.authorization.Assignment("example", {
 *     scope: exampleAccount.id,
 *     roleDefinitionName: "Storage Blob Data Contributor",
 *     principalId: exampleUserAssignedIdentity.principalId,
 * });
 * const exampleContainer = new azure.storage.Container("example", {
 *     name: "example-sc",
 *     storageAccountName: exampleAccount.name,
 *     containerAccessType: "blob",
 * });
 * const example1 = new azure.storage.Blob("example1", {
 *     name: "script1",
 *     storageAccountName: exampleAccount.name,
 *     storageContainerName: exampleContainer.name,
 *     type: "Block",
 *     sourceContent: "echo 'hello world'",
 * });
 * const example2 = new azure.storage.Blob("example2", {
 *     name: "output",
 *     storageAccountName: exampleAccount.name,
 *     storageContainerName: exampleContainer.name,
 *     type: "Append",
 * });
 * const example3 = new azure.storage.Blob("example3", {
 *     name: "error",
 *     storageAccountName: exampleAccount.name,
 *     storageContainerName: exampleContainer.name,
 *     type: "Append",
 * });
 * const example = azure.storage.getAccountSASOutput({
 *     connectionString: exampleAccount.primaryConnectionString,
 *     httpsOnly: true,
 *     signedVersion: "2019-10-10",
 *     start: "2023-04-01T00:00:00Z",
 *     expiry: "2024-04-01T00:00:00Z",
 *     resourceTypes: {
 *         service: false,
 *         container: false,
 *         object: true,
 *     },
 *     services: {
 *         blob: true,
 *         queue: false,
 *         table: false,
 *         file: false,
 *     },
 *     permissions: {
 *         read: true,
 *         write: true,
 *         "delete": false,
 *         list: false,
 *         add: true,
 *         create: true,
 *         update: false,
 *         process: false,
 *         tag: false,
 *         filter: false,
 *     },
 * });
 * // basic example
 * const exampleRunCommand = new azure.compute.RunCommand("example", {
 *     name: "example-vmrc",
 *     location: exampleResourceGroup.location,
 *     virtualMachineId: exampleLinuxVirtualMachine.id,
 *     source: {
 *         script: "echo 'hello world'",
 *     },
 * });
 * // authorize to storage blob using user assigned identity
 * const example2RunCommand = new azure.compute.RunCommand("example2", {
 *     location: exampleResourceGroup.location,
 *     name: "example2-vmrc",
 *     virtualMachineId: exampleLinuxVirtualMachine.id,
 *     outputBlobUri: example2.id,
 *     errorBlobUri: example3.id,
 *     runAsPassword: "P@$$w0rd1234!",
 *     runAsUser: "adminuser",
 *     source: {
 *         scriptUri: example1.id,
 *         scriptUriManagedIdentity: {
 *             clientId: exampleUserAssignedIdentity.clientId,
 *         },
 *     },
 *     errorBlobManagedIdentity: {
 *         clientId: exampleUserAssignedIdentity.clientId,
 *     },
 *     outputBlobManagedIdentity: {
 *         clientId: exampleUserAssignedIdentity.clientId,
 *     },
 *     parameters: [{
 *         name: "examplev1",
 *         value: "val1",
 *     }],
 *     protectedParameters: [{
 *         name: "examplev2",
 *         value: "val2",
 *     }],
 *     tags: {
 *         environment: "terraform-examples",
 *         some_key: "some-value",
 *     },
 * }, {
 *     dependsOn: [exampleAssignment],
 * });
 * // authorize to storage blob using SAS token
 * const example3RunCommand = new azure.compute.RunCommand("example3", {
 *     location: exampleResourceGroup.location,
 *     name: "example3-vmrc",
 *     virtualMachineId: exampleLinuxVirtualMachine.id,
 *     runAsPassword: "P@$$w0rd1234!",
 *     runAsUser: "adminuser",
 *     errorBlobUri: pulumi.all([example3.id, example]).apply(([id, example]) => `${id}${example.sas}`),
 *     outputBlobUri: pulumi.all([example2.id, example]).apply(([id, example]) => `${id}${example.sas}`),
 *     source: {
 *         scriptUri: pulumi.all([example1.id, example]).apply(([id, example]) => `${id}${example.sas}`),
 *     },
 *     parameters: [{
 *         name: "example-vm1",
 *         value: "val1",
 *     }],
 *     tags: {
 *         environment: "terraform-example-s",
 *         some_key: "some-value",
 *     },
 * });
 * ```
 *
 * ## API Providers
 *
 * <!-- This section is generated, changes will be overwritten -->
 * This resource uses the following Azure API Providers:
 *
 * * `Microsoft.Compute` - 2023-03-01
 *
 * ## Import
 *
 * An existing Virtual Machine Run Command can be imported into Pulumi using the `resource id`, e.g.
 *
 * ```sh
 * $ pulumi import azure:compute/runCommand:RunCommand example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/virtualMachines/vm1/runCommands/rc1
 * ```
 */
class RunCommand extends pulumi.CustomResource {
    /**
     * Get an existing RunCommand 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 RunCommand(name, state, { ...opts, id: id });
    }
    /** @internal */
    static __pulumiType = 'azure:compute/runCommand:RunCommand';
    /**
     * Returns true if the given object is an instance of RunCommand.  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'] === RunCommand.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["errorBlobManagedIdentity"] = state?.errorBlobManagedIdentity;
            resourceInputs["errorBlobUri"] = state?.errorBlobUri;
            resourceInputs["instanceViews"] = state?.instanceViews;
            resourceInputs["location"] = state?.location;
            resourceInputs["name"] = state?.name;
            resourceInputs["outputBlobManagedIdentity"] = state?.outputBlobManagedIdentity;
            resourceInputs["outputBlobUri"] = state?.outputBlobUri;
            resourceInputs["parameters"] = state?.parameters;
            resourceInputs["protectedParameters"] = state?.protectedParameters;
            resourceInputs["runAsPassword"] = state?.runAsPassword;
            resourceInputs["runAsUser"] = state?.runAsUser;
            resourceInputs["source"] = state?.source;
            resourceInputs["tags"] = state?.tags;
            resourceInputs["virtualMachineId"] = state?.virtualMachineId;
        }
        else {
            const args = argsOrState;
            if (args?.source === undefined && !opts.urn) {
                throw new Error("Missing required property 'source'");
            }
            if (args?.virtualMachineId === undefined && !opts.urn) {
                throw new Error("Missing required property 'virtualMachineId'");
            }
            resourceInputs["errorBlobManagedIdentity"] = args?.errorBlobManagedIdentity ? pulumi.secret(args.errorBlobManagedIdentity) : undefined;
            resourceInputs["errorBlobUri"] = args?.errorBlobUri;
            resourceInputs["location"] = args?.location;
            resourceInputs["name"] = args?.name;
            resourceInputs["outputBlobManagedIdentity"] = args?.outputBlobManagedIdentity ? pulumi.secret(args.outputBlobManagedIdentity) : undefined;
            resourceInputs["outputBlobUri"] = args?.outputBlobUri;
            resourceInputs["parameters"] = args?.parameters;
            resourceInputs["protectedParameters"] = args?.protectedParameters ? pulumi.secret(args.protectedParameters) : undefined;
            resourceInputs["runAsPassword"] = args?.runAsPassword ? pulumi.secret(args.runAsPassword) : undefined;
            resourceInputs["runAsUser"] = args?.runAsUser;
            resourceInputs["source"] = args?.source;
            resourceInputs["tags"] = args?.tags;
            resourceInputs["virtualMachineId"] = args?.virtualMachineId;
            resourceInputs["instanceViews"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        const secretOpts = { additionalSecretOutputs: ["errorBlobManagedIdentity", "outputBlobManagedIdentity", "protectedParameters", "runAsPassword"] };
        opts = pulumi.mergeOptions(opts, secretOpts);
        super(RunCommand.__pulumiType, name, resourceInputs, opts);
    }
}
exports.RunCommand = RunCommand;
//# sourceMappingURL=runCommand.js.map