2016-02-10 33 views
0

我們正在使用azure發佈我們的應用程序,我們有三個不同的網絡應用程序的開發,舞臺和產品。如何爲不同的環境設置不同的天藍色sendgrid帳戶?

通過參考以下鏈接

https://azure.microsoft.com/en-us/documentation/articles/sendgrid-dotnet-how-to-send-email/

我們配置在蔚藍的sendgrid帳戶,我們可以發送電子郵件沒有任何問題,在所有三個環境開發,鹿和刺。

注意:我們使用dev,stage和prod的sendgrid帳戶。

問題:現在

,用於跟蹤和計費目的,我們決定利用開發,雄鹿和生產線不同sendgrid賬戶。即,

Azure的SendGrid賬戶1 - dev的

Azure的SendGrid賬戶2 - 雄鹿

Azure的SendGrid賬戶3 - 督促

但我們不知道如何通過蔚藍門戶目標和時間我們試過這是不允許的。

請建議一些步驟或鏈接來完成此操作,以便我們可以計劃發佈。在此先感謝

+0

究竟是什麼問題,你在哪一部分卡住?創建額外的發送網格帳戶或使用dev/staging來訪問它們? –

+0

@Michael B爲dev,stag和prod創建額外的sendgrid帳戶 – SDK

+0

Forego使用Azure和門戶來設置帳戶。只需在SendGrid中使用/創建它們即可。 –

回答

1

SendGrid支持子用戶,因此您可以擁有您的父帳戶和兩個或三個子用戶,具體取決於您是否也想通過父帳戶發送。您可以在SendGrid文檔上使用read about subusers。如果您有任何問題,請告訴我。

0

關於文章中一半,你提供了一個鏈接,你會看到:

enter image description here

screenshot from article

你可以添加更多的應用程序設置,如:

SENDGRID_DEV_APIKEY,SENDGRID_STAGE_APIKEY,SENDGRID_PROD_APIKEY

然後在您的代碼中檢查代碼正在運行的環境並使用相應的應用設置/ api密鑰。

var apiKey = ""; 

//GetCurrentEnvironment() is a method you would write that contains logic to determine what "environment" is being used. 

if (GetCurrentEnvironment() == "dev") { 
    apiKey = System.Environment.GetEnvironmentVariable("SENDGRID_DEV_APIKEY"); 
} else if (GetCurrentEnvironment() == "stage") { 
    apiKey = System.Environment.GetEnvironmentVariable("SENDGRID_STAGE_APIKEY"); 
} else if (GetCurrentEnvironment() == "prod") { 
    apiKey = System.Environment.GetEnvironmentVariable("SENDGRID_PROD_APIKEY"); 
} 

var transportWeb = new Web(apiKey); 
相關問題