質問
場所はどこでのサービス実行時のことをいれば教えて私は現在実行中に"演出"、"生産'?手動で変更のコンフィグから生産のように見えるビットの煩雑さである。
解決
るべきといない変更を構成でき踏まProdや際集積は異なる場合があります"QA"環境が保有-領域の前に生産が配備されている。
アップロードする時に、その新たな展開、現在の配置スロットがアップロードパッケージが破壊され、10-15分がアップロード開始のVMのことが起こっているのです。場合はアップロードに入り、製造時の15分の生産ダウンタイムの短縮などこのように、集積した:アップロードした演出、テストのものをクリックし"のスワップボタンやリビジョンがステージング環境を魔法が生産(仮想IPットスワップをこのように、段は本当に100%同じものを生産。
どん求めているのは、QA/試験です。べき新たなサービスのための試験環境を独自にProd/際この場合、また維持複数の設定ファイルを設定し、設定した展開環境(生産、試験等)
多くの管理方法についてのコンフィグレーション-地獄に発生する、紺碧る上です。configファイル、自*.cscfgファイルです。のも好きでAzureプロジェクトは、設定小Configプロジェクトをフォルダが一致する展開。内の各フォルダの設定セットの*.config&*.cscfgファイルに一致する特定の展開環境:デバッグ、テスト、リリース...これらの設定Visual Studioなどについては、目標です。私は小念のサービスで確張コマンド時に発生する毎にコンパイルのConfigプロジェクトをコピーしているため、すべてのファイルから構築の対象フォルダのConfigプロジェクトのルートフォルダ内のコンフィグのプロジェクト.
そうすると、あらゆるその他のプロジェクト、ソリューションにリンクします。configいます。cscfgファイルのルートからフォルダのコンフィグのプロジェクト.
出来上がりで、私のconfigs魔法への適応毎ビルド構成さい。また利用します。config変革管理をデバッグのための情報発売前非リリースを構築する。
まっすべて読み取ることが取得したいの 生産対集状況は実行時, とします。得 deploymentId
から RoleEnvironment.DeploymentId
その利用管理APIを正しく X509 certificate
の Azure structure of your Service
を呼び出 GetDeployments
の方法でrest apiがあり抽象化図書館)
武器agiは、dexで下がらないboxerぐ
編集:ブログとして求められますので、設定の設定文字列切り替えと環境@ http://blog.paraleap.com/blog/post/Managing-environments-in-a-distributed-Azure-or-other-cloud-based-NET-solution
他のヒント
時々私は人々がただ質問に答えることを望みます..倫理やベストプラクティスを説明しないでください...
Microsoftは、ここでまさにこれを行っているコードサンプルを投稿しました: https://code.msdn.microsoft.com/windowsazure/csazuredeploymentslot-1ce0e3b5
protected void Page_Load(object sender, EventArgs e)
{
// You basic information of the Deployment of Azure application.
string deploymentId = RoleEnvironment.DeploymentId;
string subscriptionID = "<Your subscription ID>";
string thrumbnail = "<Your certificate thumbnail print>";
string hostedServiceName = "<Your hosted service name>";
string productionString = string.Format(
"https://management.core.windows.net/{0}/services/hostedservices/{1}/deploymentslots/{2}",
subscriptionID, hostedServiceName, "Production");
Uri requestUri = new Uri(productionString);
// Add client certificate.
X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
store.Open(OpenFlags.OpenExistingOnly);
X509Certificate2Collection collection = store.Certificates.Find(
X509FindType.FindByThumbprint, thrumbnail, false);
store.Close();
if (collection.Count != 0)
{
X509Certificate2 certificate = collection[0];
HttpWebRequest httpRequest = (HttpWebRequest)HttpWebRequest.Create(requestUri);
httpRequest.ClientCertificates.Add(certificate);
httpRequest.Headers.Add("x-ms-version", "2011-10-01");
httpRequest.KeepAlive = false;
HttpWebResponse httpResponse = httpRequest.GetResponse() as HttpWebResponse;
// Get response stream from Management API.
Stream stream = httpResponse.GetResponseStream();
string result = string.Empty;
using (StreamReader reader = new StreamReader(stream))
{
result = reader.ReadToEnd();
}
if (result == null || result.Trim() == string.Empty)
{
return;
}
XDocument document = XDocument.Parse(result);
string serverID = string.Empty;
var list = from item
in document.Descendants(XName.Get("PrivateID",
"http://schemas.microsoft.com/windowsazure"))
select item;
serverID = list.First().Value;
Response.Write("Check Production: ");
Response.Write("DeploymentID : " + deploymentId
+ " ServerID :" + serverID);
if (deploymentId.Equals(serverID))
lbStatus.Text = "Production";
else
{
// If the application not in Production slot, try to check Staging slot.
string stagingString = string.Format(
"https://management.core.windows.net/{0}/services/hostedservices/{1}/deploymentslots/{2}",
subscriptionID, hostedServiceName, "Staging");
Uri stagingUri = new Uri(stagingString);
httpRequest = (HttpWebRequest)HttpWebRequest.Create(stagingUri);
httpRequest.ClientCertificates.Add(certificate);
httpRequest.Headers.Add("x-ms-version", "2011-10-01");
httpRequest.KeepAlive = false;
httpResponse = httpRequest.GetResponse() as HttpWebResponse;
stream = httpResponse.GetResponseStream();
result = string.Empty;
using (StreamReader reader = new StreamReader(stream))
{
result = reader.ReadToEnd();
}
if (result == null || result.Trim() == string.Empty)
{
return;
}
document = XDocument.Parse(result);
serverID = string.Empty;
list = from item
in document.Descendants(XName.Get("PrivateID",
"http://schemas.microsoft.com/windowsazure"))
select item;
serverID = list.First().Value;
Response.Write(" Check Staging:");
Response.Write(" DeploymentID : " + deploymentId
+ " ServerID :" + serverID);
if (deploymentId.Equals(serverID))
{
lbStatus.Text = "Staging";
}
else
{
lbStatus.Text = "Do not find this id";
}
}
httpResponse.Close();
stream.Close();
}
}
演出は、一時展開のスロット使用無-ダウンタイム更新をロールバックは、アップグレードを開始します。
しておくといいでしょうなカップルシステム(コードまたはconfig)などAzureは細目。
以来 Windows Azure Managementライブラリ @guaravmantriに感謝します 答え 別の質問にあなたはこのようにそれをすることができます:
using System;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using Microsoft.Azure;
using Microsoft.WindowsAzure.Management.Compute;
using Microsoft.WindowsAzure.Management.Compute.Models;
namespace Configuration
{
public class DeploymentSlotTypeHelper
{
static string subscriptionId = "<subscription-id>";
static string managementCertContents = "<Base64 Encoded Management Certificate String from Publish Setting File>";// copy-paste it
static string cloudServiceName = "<your cloud service name>"; // lowercase
static string ns = "http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration";
public DeploymentSlot GetSlotType()
{
var managementCertificate = new X509Certificate2(Convert.FromBase64String(managementCertContents));
var credentials = new CertificateCloudCredentials(subscriptionId, managementCertificate);
var computeManagementClient = new ComputeManagementClient(credentials);
var response = computeManagementClient.HostedServices.GetDetailed(cloudServiceName);
return response.Deployments.FirstOrDefault(d => d.DeploymentSlot == DeploymentSlot.Production) == null ? DeploymentSlot.Staging : DeploymentSlot.Production;
}
}
}
この問題を解決する簡単な方法は、インスタンスに設定して、実行中の環境を特定するためのキーを設定することです。
1)生産スロットに設定:設定>>アプリケーション設定>>アプリ設定を設定し、slot_nameと値「生産」という名前のキーを作成します。重要:スロット設定を確認します。
2)ステージングスロットで設定:設定>>アプリケーション設定>>アプリ設定を設定し、slot_nameと値「ステージング」という名前のキーを作成します。重要:スロット設定を確認します。
アプリケーションから変数にアクセスし、アプリケーションが実行されている環境を特定します。 Javaでは、アクセスできます。
String slotName = System.getenv("APPSETTING_SLOT_NAME");
考慮すべき4つのポイントがあります
- VIPスワップは、サービスが外の世界に直面している場合にのみ理にかなっています。別名、APIを公開してリクエストに反応する場合。
- あなたのサービスがキューからメッセージを引いてそれらを処理するだけである場合、あなたのサービスは積極的であり、VIPスワップはあなたにとって良い解決策ではありません。
- サービスがリアクティブでプロアクティブな場合は、デザインを再考することをお勧めします。おそらく、サービスを2つの異なるサービスに分割します。
- CSCFGファイルを変更するというエリックの提案は、VIPの前後のスワップを事前およびポストVIPスワップします。サービスのプロアクティブな部分が短時間で時間を取ることができる場合(最初にステージングと制作の両方を設定してメッセージをプルしないように構成し、VIPスワップを実行してから実行してから、プロダクションの構成を更新して、メッセージの引き込みを開始します)。