in src/AzureSqlResourceManager.ts [53:85]
public async addFirewallRule(startIpAddress: string, endIpAddress: string): Promise<FirewallRule> {
let today = new Date();
let firewallRuleName = `ClientIPAddress_${today.getFullYear()}-${today.getMonth()}-${today.getDay()}_${startIpAddress}`;
// https://docs.microsoft.com/rest/api/sql/2021-11-01/firewall-rules/create-or-update
let httpRequest: WebRequest = {
method: 'PUT',
uri: this._restClient.getRequestUri(`/${this._resource!.id}/firewallRules/${firewallRuleName}`, {}, [], SqlApiVersion),
body: JSON.stringify({
'properties': {
'startIpAddress': startIpAddress,
'endIpAddress': endIpAddress
}
})
};
try {
let httpResponse = await this._restClient.beginRequest(httpRequest);
if (httpResponse.statusCode !== 200 && httpResponse.statusCode !== 201) {
throw ToError(httpResponse);
}
return httpResponse.body as FirewallRule;
}
catch(error) {
if (error instanceof AzureError) {
throw new Error(JSON.stringify(error));
}
throw error;
}
}