Add SQL User for Azure Function and Pipeline

Contents
    /* add user */
    CREATE USER [fnMyFunctionName] FROM EXTERNAL PROVIDER;
    /* or with slot:
    CREATE USER [fnMyFunctionName/slots/staging] FROM EXTERNAL PROVIDER;
    */
    
    /*allow to read data */
    EXEC sp_addrolemember 'db_datareader', [fnMyFunctionName];
    
    /*allow to write data */
    EXEC sp_addrolemember 'db_datawriter', [fnMyFunctionName];
    
    /* this is the pipeline user */
    CREATE USER [(service connection name)] FROM EXTERNAL PROVIDER;
    
    /*make it an owner so it can modify the db*/
    EXEC sp_addrolemember 'db_owner', [nsweservice connection name];
    Updated on October 14, 2025

    Leave a Reply

    Your email address will not be published. Required fields are marked *