<commit_before>'use strict';

const BbPromise = require('bluebird');
const _ = require('lodash');
const msRestAzure = require('ms-rest-azure');
const resourceManagement = require('azure-arm-resource');
const path = require('path');
const fs = require('fs');
const fse = require('fs-extra');
const https = require('https');
const zipFolder = require('zip-folder');
const request = require('request');
const dns = require('dns');
const parseBindings = require('../shared/parseBindings');

let resourceGroupName;
let deploymentName;
let functionAppName;
let subscriptionId;
let servicePrincipalTenantId;
let servicePrincipalClientId;
let servicePrincipalPassword;
let functionsAdminKey;
let invocationId;
let oldLogs = '';
let principalCredentials;
let functionsFolder;
let existingFunctionApp = false;
let parsedBindings;
const zipArray = [];
const deployedFunctionNames = [];

const constants = {
  'authorizationHeader': 'Authorization',
  'bearer': 'Bearer ',
  'contentTypeHeader': 'Content-Type',
  'functionAppApiPath': '/api/',
  'functionAppDomain': '.azurewebsites.net',
  'functionsAdminApiPath': '.azurewebsites.net/admin/functions/',
  'functionsApiPath': '/api/functions',
  'jsonContentType': 'application/json',
  'logInvocationsApiPath': '/azurejobs/api/functions/definitions/',
  'logOutputApiPath': '/azurejobs/api/log/output/',
  'logStreamApiPath': '/api/logstream/application/functions/function/',
  'masterKeyApiApth': '/api/functions/admin/masterkey',
  'providerName': 'azure',
  'scmCommandApiPath': '/api/command',
  'scmDomain': '.scm.azurewebsites.net',
  'scmVfsPath': '.scm.azurewebsites.net/api/vfs/site/wwwroot/',
  'scmZipApiPath': '.scm.azurewebsites.net/api/zip/site/wwwroot/'
};

const azureCredentials = {
  'azureSubId': 'azureSubId',
  'azureServicePrincipalTenantId': 'azureServicePrincipalTenantId',
  'azureservicePrincipalClientId': 'azureservicePrincipalClientId',
  'azureServicePrincipalPassword': '<PASSWORD>',
};

class AzureProvider {
  static getProviderName () {
return constants.providerName;
  }

  constructor (serverless) {
    this.provider = this;
    this.serverless = serverless;

    this.serverless.setProvider(constants.providerName, this);
  }

  initialize(serverless, options) {
    this.serverless = serverless;
    this.options = options;
    
    subscriptionId = this.getSetting(azureCredentials.azureSubId);
    servicePrincipalTenantId = this.getSetting(azureCredentials.azureServicePrincipalTenantId);
    servicePrincipalClientId = this.getSetting(azureCredentials.azureservicePrincipalClientId);
    servicePrincipalPassword = this.getSetting(azureCredentials.azureServicePrincipalPassword);

    functionAppName = this.serverless.service.service;
    resourceGroupName = `${functionAppName}-rg`;
    deploymentName = `${resourceGroupName}-deployment`;
    functionsFolder = path.join(this.serverless.config.servicePath, 'functions');
    
  }

  getParsedBindings () {
    if (!this.parsedBindings) {
      this.parsedBindings = parseBindings.getBindingsMetaData(this.serverless);
    }

return this.parsedBindings;<commit_msg>Missed commit as part of changes for #53 to change the initialize function to return a promise to allow chaining. (#56)<commit_after>'use strict';

const BbPromise = require('bluebird');
const _ = require('lodash');
const msRestAzure = require('ms-rest-azure');
const resourceManagement = require('azure-arm-resource');
const path = require('path');
const fs = require('fs');
const fse = require('fs-extra');
const https = require('https');
const zipFolder = require('zip-folder');
const request = require('request');
const dns = require('dns');
const parseBindings = require('../shared/parseBindings');

let resourceGroupName;
let deploymentName;
let functionAppName;
let subscriptionId;
let servicePrincipalTenantId;
let servicePrincipalClientId;
let servicePrincipalPassword;
let functionsAdminKey;
let invocationId;
let oldLogs = '';
let principalCredentials;
let functionsFolder;
let existingFunctionApp = false;
let parsedBindings;
const zipArray = [];
const deployedFunctionNames = [];

const constants = {
  'authorizationHeader': 'Authorization',
  'bearer': 'Bearer ',
  'contentTypeHeader': 'Content-Type',
  'functionAppApiPath': '/api/',
  'functionAppDomain': '.azurewebsites.net',
  'functionsAdminApiPath': '.azurewebsites.net/admin/functions/',
  'functionsApiPath': '/api/functions',
  'jsonContentType': 'application/json',
  'logInvocationsApiPath': '/azurejobs/api/functions/definitions/',
  'logOutputApiPath': '/azurejobs/api/log/output/',
  'logStreamApiPath': '/api/logstream/application/functions/function/',
  'masterKeyApiApth': '/api/functions/admin/masterkey',
  'providerName': 'azure',
  'scmCommandApiPath': '/api/command',
  'scmDomain': '.scm.azurewebsites.net',
  'scmVfsPath': '.scm.azurewebsites.net/api/vfs/site/wwwroot/',
  'scmZipApiPath': '.scm.azurewebsites.net/api/zip/site/wwwroot/'
};

const azureCredentials = {
  'azureSubId': 'azureSubId',
  'azureServicePrincipalTenantId': 'azureServicePrincipalTenantId',
  'azureservicePrincipalClientId': 'azureservicePrincipalClientId',
  'azureServicePrincipalPassword': '<PASSWORD>',
};

class AzureProvider {
  static getProviderName () {
return constants.providerName;
  }

  constructor (serverless) {
    this.provider = this;
    this.serverless = serverless;

    this.serverless.setProvider(constants.providerName, this);
  }

  initialize(serverless, options) {
    this.serverless = serverless;
    this.options = options;

    return new BbPromise((resolve, reject) => {
        subscriptionId = this.getSetting(azureCredentials.azureSubId);
        servicePrincipalTenantId = this.getSetting(azureCredentials.azureServicePrincipalTenantId);
        servicePrincipalClientId = this.getSetting(azureCredentials.azureservicePrincipalClientId);
        servicePrincipalPassword = this.getSetting(azureCredentials.azureServicePrincipalPassword);

        functionAppName = this.serverless.service.service;

        resourceGroupName = `${functionAppName}-rg`;
        deploymentName = `${resourceGroupName}-deployment`;
        functionsFolder = path.join(this.serverless.config.servicePath, 'functions');

        if (!servicePrincipalTenantId || !servicePrincipalClientId || !servicePrincipalPassword || !subscriptionId) {
            reject(new Error('Azure credentials not provided'));
        }

        resolve();
    });
  }

  getParsedBindings () {
    if (!this.parsedBindings) {
      this.parsedBindings = parseBindings.getBindingsMetaData(this.serverless);
    }

return this.parsedBindings;
{'fraction_non_alphanumeric': 0.13075757575757577, 'fraction_numerical': 0.0006060606060606061, 'mean_word_length': 5.52917903066271, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5492779', 'n_tokens_mistral': 1951, 'n_tokens_neox': 1903, 'n_words': 354}