1. Packages
  2. MSSQL
  3. Installation & Configuration
Microsoft SQL Server v0.1.0 published on Tuesday, Oct 8, 2024 by pulumiverse

MSSQL: Installation & Configuration

mssql logo
Microsoft SQL Server v0.1.0 published on Tuesday, Oct 8, 2024 by pulumiverse

    Installation

    The Pulumi MSSQL provider is available as a package in all Pulumi languages:

    Authentication Methods

    SQL auth

    Provider username and password, using sql_auth field:

    const providerMssql = new mssql.Provider("provider-mssql", {
        hostname: "localhost",
        port: 1433,
        sqlAuth: {
            username: "sa",
            password: "sa_password",
        },
    });
    
    provider_mssql = mssql.Provider("provider-mssql",
        hostname="localhost",
        port=1433,
        sql_auth=mssql.ProviderSqlAuthArgs(
            username="sa",
            password="sa_password",
        ))
    
    _, err := mssql.NewProvider(ctx, "provider-mssql", &mssql.ProviderArgs{
      Hostname: pulumi.String("localhost"),
      Port:     pulumi.Int(1433),
      SqlAuth: &mssql.ProviderSqlAuthArgs{
        Username: pulumi.String("sa"),
        Password: pulumi.String("sa_password"),
      },
    })
    if err != nil {
      return err
    }
    
    var providerMssql = new Mssql.Provider("provider-mssql", new()
    {
        Hostname = "localhost",
        Port = 1433,
        SqlAuth = new Mssql.Inputs.ProviderSqlAuthArgs
        {
            Username = "sa",
            Password = "sa_password",
        },
    });
    
    resources:
      provider-mssql:
        type: pulumi:providers:mssql
        properties:
          hostname: "localhost"
          port: 1433
          sqlAuth:
            username: "sa"
            password: "sa_password"
    

    Azure AD

    In case of Azure SQL connections, Azure Active Directory auth tokens can be used to authenticate.

    Service Principal

    Provide client ID (a.k.a. application ID), secret and tenant ID, using azure_auth field:

    const providerMssql = new mssql.Provider("provider-mssql", {
        hostname: "example.database.windows.net",
        port: 1433,
        azureAuth: {
            clientId: "94e8d55d-cbbc-4e41-b21a-8923d83f9a85",
            clientSecret: "client_secret",
            tenantId: "a352c914-bfd9-4b7e-8b1d-554a58353f22",
        },
    });
    
    provider_mssql = mssql.Provider("provider-mssql",
        hostname="example.database.windows.net",
        port=1433,
        azure_auth=mssql.ProviderAzureAuthArgs(
            client_id="94e8d55d-cbbc-4e41-b21a-8923d83f9a85",
            client_secret="client_secret",
            tenant_id="a352c914-bfd9-4b7e-8b1d-554a58353f22",
        ))
    
    _, err := mssql.NewProvider(ctx, "provider-mssql", &mssql.ProviderArgs{
    	Hostname: pulumi.String("example.database.windows.net"),
    	Port:     pulumi.Int(1433),
    	AzureAuth: &mssql.ProviderAzureAuthArgs{
    		ClientId:     pulumi.String("94e8d55d-cbbc-4e41-b21a-8923d83f9a85"),
    		ClientSecret: pulumi.String("client_secret"),
    		TenantId:     pulumi.String("a352c914-bfd9-4b7e-8b1d-554a58353f22"),
    	},
    })
    if err != nil {
    	return err
    }
    return nil
    
    var providerMssql = new Mssql.Provider("provider-mssql", new()
    {
        Hostname = "example.database.windows.net",
        Port = 1433,
        AzureAuth = new Mssql.Inputs.ProviderAzureAuthArgs
        {
            ClientId = "94e8d55d-cbbc-4e41-b21a-8923d83f9a85",
            ClientSecret = "client_secret",
            TenantId = "a352c914-bfd9-4b7e-8b1d-554a58353f22",
        },
    });
    
    resources:
      provider-mssql:
        type: pulumi:providers:mssql
        properties:
          hostname: "example.database.windows.net"
          port: 1433
          azureAuth:
            clientId: "94e8d55d-cbbc-4e41-b21a-8923d83f9a85"
            clientSecret: "client_secret"
            tenantId: "a352c914-bfd9-4b7e-8b1d-554a58353f22"
    
    Default chained credentials

    When azure_auth value is set to empty object ({}), the provider uses chained credentials built from EnvironmentCredential -> ManagedIdentityCredential -> AzureCLICredential. See DefaultAzureCredential docs for details.

    Environment variables

    When azure_auth value is set to empty object ({}) and following environment variables are set, the env variable values will be used for authentication, taking precedence over DefaultAzureCredential.

    • ARM_CLIENT_ID or AZURE_CLIENT_ID
    • ARM_CLIENT_SECRETor AZURE_CLIENT_SECRET
    • ARM_TENANT_IDor AZURE_TENANT_ID
    const providerMssql = new mssql.Provider("provider-mssql", {
        hostname: "example.database.windows.net",
        port: 1433,
        azureAuth: {},
    });
    
    provider_mssql = mssql.Provider("provider-mssql",
        hostname="example.database.windows.net",
        port=1433,
        azure_auth=mssql.ProviderAzureAuthArgs())
    
    _, err := mssql.NewProvider(ctx, "provider-mssql", &mssql.ProviderArgs{
    	Hostname:  pulumi.String("example.database.windows.net"),
    	Port:      pulumi.Int(1433),
    	AzureAuth: AzureAuth: mssql.ProviderAzureAuthArgs{},
    })
    if err != nil {
    	return err
    }
    return nil
    })
    
    var providerMssql = new Mssql.Provider("provider-mssql", new()
    {
        Hostname = "example.database.windows.net",
        Port = 1433,
        AzureAuth = new Mssql.Inputs.ProviderAzureAuthArgs(),
    });
    
    resources:
      provider-mssql:
        type: pulumi:providers:mssql
        properties:
          hostname: "example.database.windows.net"
          port: 1433
          azureAuth: {}
    

    Provider Binary

    The MSSQL provider binary is a third party binary. It can be installed using the pulumi plugin command.

    mssql logo
    Microsoft SQL Server v0.1.0 published on Tuesday, Oct 8, 2024 by pulumiverse