When asking questions like this you need to differentiate your attackers:
- A2) Rogue internet hacker
- A3) A developer in your organization
- A4) A person in your organization who does deployments
Your role binaries are not accessible to A2, however they are very accessible to A3 and A4.
As mentioned in another answer, you can store your secrets in the Role Configuration File.
However, these secrets are still accessible to A4 (anyone with access to the portal).
To defend against A4 you want to encrypt the secrets in the role configuration file with a key that isn't present in the role binaries or the role configuration. Then in your role binaries you decrypt the encrypted role setting, with the decryption key.
The key to use for encrypting the secrets is a certificate, which the Azure SDK will install for you. You can find a post about setting up certificates for azure here.
In summary, for secrets where you need to defend against people in your organization who do deployments/have access to your configuration files you do the following:
Have a trusted party do the following:
- Generate a Certificate/Private Key
- Encrypt secrets with the Certificate, and store the encrypted settings in your configuration files
- Upload the Certificate/Private Key to your service.
Then modify your service to:
- Have the service model install the Certificate/PrivateKey
- Have your application, load the private key for decrypting secrets
- Have your application load the encrypted settings from role configuration, and decrypt them with the private key.