Q:

In ms-rest-azure, when I try to get authentication token, how do I specify resource?

So I am trying to get authentication to keyvault:
import * as msRestAzure from 'ms-rest-azure';
msRestAzure.loginWithServicePrincipalSecret(clientID, clientKey, domainID);

How do I specify the resource to be "https://vault.azure.net"?

A:

You could use  msRestAzure.loginWithAppServiceMSImsRestAzure.loginWithAppServiceMSI({resource: 'https://vault.azure.net'});
You could check this link.
function getKeyVaultCredentials(){
    return msRestAzure.loginWithAppServiceMSI({resource: 'https://vault.azure.net'});
}

function getKeyVaultSecret(credentials) {
    let keyVaultClient = new KeyVault.KeyVaultClient(credentials);
    return keyVaultClient.getSecret(KEY_VAULT_URI, 'secret', "");
}

getKeyVaultCredentials().then(
    getKeyVaultSecret
).then(function (secret){
    console.log(`Your secret value is: ${secret.value}.`);
}).catch(function (err) {
    throw (err);
});

