# Install Billing Resource Provider

## HOST VM

On **AzS Development Kits**, sign in to the physical host.&#x20;

On **multi-node integrated systems**, the host must be a system that can access admin and tenant endpoints.

{% hint style="info" %}
All steps in [Prerequisites](https://docs.cloudassert.com/azure-stack-billing/2011.4/installation/prerequisites) should be taken care before proceeding with the deployment steps below.
{% endhint %}

1. Open a new elevated (administrative) PowerShell  console and change to the directory where the files have been extracted (c:\CloudAssert\BillingRP). Use a new window to avoid problems that might arise from incorrect PowerShell modules that are already loaded on the system. If you don't have this installer please [**reach out to our team**](https://www.cloudassert.com/Product/Microsoft-Azure-Stack-Hub/Multi-Stamp-Management-Free-Trial) and we will provide you with latest installer and trial license.&#x20;
2. Ensure 2 certificate files (.pfx and .cer) \[as in [Prerequisites](https://docs.cloudassert.com/azure-stack-billing/2011.4/installation/prerequisites) -> **Certificate** section] are present in the **Cert** folder as follows:
   * &#x20;The file name must not contain any special characters.
   * &#x20;Only a \*.cer and \*.pfx exists in this **Cert** folder.
   * &#x20;The certificates must be placed in in this folder **every time** before retrying the deployment.
3. Backup the **Cert** folder, in case the deployment needs to be retried, the files to be replaced here.
4. Run InstallBilling.ps1 and specify the required parameters

| Parameter Name                   | Description                                                                                                                                                                                                                                                      | Required |
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| DefaultProviderSubscriptionId    | <p>Go to Admin Portal -> Login as Service Admin -> </p><p>Subscriptions -> Default Provider Subscription -> Get the GUID</p>                                                                                                                                     | Required |
| ServiceAdmin                     | <p>Go to Admin Portal -> Login as Service Admin -> </p><p>Subscriptions -> Default Provider Subscription -> </p><p>Check if role is <strong>Owner</strong>                                                 </p><p>Eg: <admin@contosotest.onmicrosoft.com>   </p> | Required |
| AdminPassword                    | Password for the above ServiceAdmin                                                                                                                                                                                                                              | Required |
| AdminArmEndpoint                 | Admin ARM endpoint URL                                                                                                                                                                                                                                           | Required |
| ServiceAdminDirectoryTenantName  | Directory tenant name Of the service admin user                                                                                                                                                                                                                  | Required |
| ServiceTenant                    | <p>Tenant Subscription administrator account login user name. </p><p>If not provided above ServiceAdmin credential can be used. </p>                                                                                                                             | Optional |
| TenantPassword                   | <p>Tenant Subscription administrator account login user password.</p><p>If not provided above ServiceAdmin credential can be used.</p>                                                                                                                           | Optional |
| ServiceTenantDirectoryTenantName | Directory tenant name Of the service tenant user. If not provided, ServiceAdminDirectoryTenantName will be used                                                                                                                                                  | Optional |
| TenantSubscriptionId             | <p>GUID of the Tenant Subscription where Cloud Assert </p><p>components need to be deployed</p>                                                                                                                                                                  | Required |
| VmLocalAdminPass                 | <p>Password for the new VM that will host the resource provider </p><p>IIS components. The user name is .\billingrpadmin.</p>                                                                                                                                    | Required |
| PfxPassword                      | Password for azure stack .pfx file in Step 2                                                                                                                                                                                                                     | Required |
| SqlServerName                    | IP Address. Specify instance if exists. Eg: 192.168.102.32 or 192.168.102.32\CASQL                                                                                                                                                                               | Required |
| SqlDbName                        | Billing Database name Eg: CloudAssert.Billing                                                                                                                                                                                                                    | Required |
| SqlUser                          | SQL Authenticated user name Eg: cadbadmin                                                                                                                                                                                                                        | Required |
| SqlPass                          | SQL Authenticated user password                                                                                                                                                                                                                                  | Required |
| ApiUser                          | <p>Local Web user that will be created and used to access </p><p>the Cloud Assert Billing API service. Eg: admin</p>                                                                                                                                             | Required |
| ApiPassword                      | Password for above Billing ApiUser                                                                                                                                                                                                                               | Required |
| DacmDatabaseName                 | Cost Management database name. Eg: CloudAssert.DACM                                                                                                                                                                                                              | Required |
| ImageSku                         | The default sku is "**2016-Datacenter**" in case you would like to use SQL image for the deployment, set this parameter to "**Standard**". It supports "**SQL Server 2017 Standard on Windows Server 2016**" VM image for deployment.                            | Optional |
| Disconnected                     | <p>If the AzS environment this RP is getting installed is in </p><p>disconnected mode, pass value $True.  </p><p>For normal connected deployments this parameter </p><p>is optional.  </p>                                                                       | Optional |
| Uninstall                        | <p>For installation, no need to pass this parameter. </p><p>For un-install, set it to $<strong>true</strong> to un-install Billing.</p>                                                                                                                          | Optional |
| ExistingBillingApiUrl            | Existing core billing API URL when only RP components are installed in multi stamp environment and the RP components points to existing core billing API                                                                                                         | Optional |

```
.\InstallBilling.ps1 -DefaultProviderSubscriptionId "fill-here" -ServiceAdmin "fill-here" -AdminPassword 'fill-here' -AdminArmEndpoint "fill-here" -ServiceAdminDirectoryTenantName "fill-here" -TenantSubscriptionId "fill-here" -VmLocalAdminPass 'fill-here' -PfxPassword 'fill-here' -SqlServerName "fill-here" -SqlDbName "CloudAssert.Billing" -SqlUser "cadbadmin" -SqlPass 'fill-here' -Apiuser "admin" -ApiPassword 'fill-here' -DacmDatabaseName "CloudAssert.Dacm" 

Example:
.\InstallBilling.ps1 -DefaultProviderSubscriptionId "a088be51-b7e3-47ea-8c83-1ba98e2bbf5f" -ServiceAdmin "cloudassert@contosotest.onmicrosoft.com" -AdminPassword 'TestP@ss1234' -AdminArmEndpoint "https://adminmanagement..local.azurestack.external" -ServiceAdminDirectoryTenantName "contosotest.onmicrosoft.com" -ServiceTenant "cloudassert@contosotest.onmicrosoft.com" -TenantPassword 'TestP@ss1234' -ServiceTenantDirectoryTenantName "contosotest.onmicrosoft.com" -TenantSubscriptionId "00e4fd62-a809-4cd2-a70c-981c97ace666" -VmLocalAdminPass 'TestP@ss1234' -PfxPassword 'TestP@ss1234' -SqlServerName "192.168.102.32" -SqlDbName "CloudAssert.Billing" -SqlUser "cadbadmin" -SqlPass 'TestP@ss1234' -Apiuser "admin" -ApiPassword 'TestP@ss1234' -DacmDatabaseName "CloudAssert.Dacm"
```

To install only RP components in multi-stamp environments,

```
.\InstallBilling.ps1 -DefaultProviderSubscriptionId "fill-here" -ServiceAdmin "fill-here" -AdminPassword 'fill-here' -AdminArmEndpoint "fill-here" -ServiceAdminDirectoryTenantName "fill-here" -TenantSubscriptionId "fill-here" -VmLocalAdminPass 'fill-here' -PfxPassword 'fill-here' -SqlServerName "fill-here" -SqlDbName "CloudAssert.Billing" -SqlUser "cadbadmin" -SqlPass 'fill-here' -Apiuser "admin" -ApiPassword 'fill-here' -ExistingBillingApiUrl "fill-here" 

Example:
.\InstallBilling.ps1 -DefaultProviderSubscriptionId "a088be51-b7e3-47ea-8c83-1ba98e2bbf5f" -ServiceAdmin "cloudassert@contosotest.onmicrosoft.com" -AdminPassword 'TestP@ss1234' -AdminArmEndpoint "https://adminmanagement..local.azurestack.external" -ServiceAdminDirectoryTenantName "contosotest.onmicrosoft.com" -ServiceTenant "cloudassert@contosotest.onmicrosoft.com" -TenantPassword 'TestP@ss1234' -ServiceTenantDirectoryTenantName "contosotest.onmicrosoft.com" -TenantSubscriptionId "00e4fd62-a809-4cd2-a70c-981c97ace666" -VmLocalAdminPass 'TestP@ss1234' -PfxPassword 'TestP@ss1234' -SqlServerName "192.168.102.32" -SqlDbName "CloudAssert.Billing" -SqlUser "cadbadmin" -SqlPass 'TestP@ss1234' -Apiuser "admin" -ApiPassword 'TestP@ss1234' ' -ExistingBillingApiUrl "https://billing.local.mas500.samm.corp.contosotest.com:44306" 
```

5\. A pop up will appear with end user license agreement, once reviewed click **Accept.** The installation will continue and complete once all steps succeed.&#x20;

![](https://3313056274-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LnRvmq3Z7NHbI7KSziq%2F-MBc-xFpyLuQcqpDVHbc%2F-MBcCf1UgPXG4Duiq5HV%2Flicense%20agreement.PNG?alt=media\&token=cbffd70a-8cb7-4a60-b87d-96d3681bea7b)

![](https://3313056274-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LnRvmq3Z7NHbI7KSziq%2F-MBhDeevw1qv92BzHRKz%2F-MBhNCoUNEzvDY5tweXt%2FSuccess.PNG?alt=media\&token=f817aea0-81a8-408b-8e5d-178cd690f604)

{% hint style="info" %}
This RP deployment step for a **Multi node environment** may take 60-75 minutes to complete. For **ASDK**, it may take 90 - 100 minutes.&#x20;
{% endhint %}

## Verifying the Deployment in Azure Stack Portals

* In Admin Portal, click on Resource Groups. Then select the **system.\<location>.cloudassert.billing** resource group and verify if the deployment succeeded.
* In Tenant Portal, click on Resource Groups. Then select the **system.\<location>.cloudassert.billing.rp** resource group and verify if the deployment succeeded.
* In SQL Database Server, ensure the databases **CloudAssert.Billing and CloudAssert.Dacm** are populated with tables
* In **Resource Provider VM**, verify necessary web sites are installed:
  1. Go to **Tenant Portal** -> **All Resources** -> **BillingVM1000** -> **Overview** -> **DNS Name** (last item)
  2. Copy the value and remote into this resource provider VM&#x20;
  3. **User name:** billingrpadmin, **Password:** as specified in the above installation step
  4. Go to **inetmgr**, ensure following 4 **custom web sites** are present.&#x20;

![](https://3313056274-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LnRvmq3Z7NHbI7KSziq%2F-MBc-xFpyLuQcqpDVHbc%2F-MBcEVCM4cX2UTg90rq9%2Fvalidate%20sites.PNG?alt=media\&token=e4a3fd19-dbe8-455c-87cb-300b7730915e)

* In the same **Resource Provider VM**, go to **Control Panel** -> **Programs** -> **Programs and Features** -> verify **3 services** DACM (Cost Management agent service), Billing API and Billing Agent service exist and are running properly.

![](https://3313056274-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LnRvmq3Z7NHbI7KSziq%2F-MBc-xFpyLuQcqpDVHbc%2F-MBcElEddwdLQcmEDw5h%2Fprogram%20files.PNG?alt=media\&token=20a6af73-eb1c-4e10-812b-3e3c4f165df7)

* If any of the above verification steps fail, reach out to us to fix the issues and retry the InstallBilling.ps1 following instructions below.
* If all verification steps passed, proceed to [License Activation](https://docs.cloudassert.com/azure-stack-billing/2011.4/installation/deployment/license-activation).

## Retry Instructions

In case this step of the deployment needs to be re-run:

1. Perform **Step 2** in the above install instructions to place the certificate files in the appropriate folder in the install path
2. Run InstallBilling.ps1 and specify the required parameters.
